codegen

package
v0.58.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Overview

Contains routines for generating terraform code

Index

Constants

View Source
const (
	// A comment that is added to the top of the generated file to indicate that this file was generated by Terragrunt.
	// We use a hardcoded random string at the end to make the string further unique.
	TerragruntGeneratedSignature = "Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa"

	// The default prefix to use for comments in the generated file
	DefaultCommentPrefix = "# "
)
View Source
const (
	ExistsErrorStr               = "error"
	ExistsSkipStr                = "skip"
	ExistsOverwriteStr           = "overwrite"
	ExistsOverwriteTerragruntStr = "overwrite_terragrunt"

	DisabledSkipStr             = "skip"
	DisabledRemoveStr           = "remove"
	DisabledRemoveTerragruntStr = "remove_terragrunt"
)

Variables

This section is empty.

Functions

func RemoteStateConfigToTerraformCode

func RemoteStateConfigToTerraformCode(backend string, config map[string]interface{}) ([]byte, error)

Convert the arbitrary map that represents a remote state config into HCL code to configure that remote state.

func WriteToFile

func WriteToFile(terragruntOptions *options.TerragruntOptions, basePath string, config GenerateConfig) error

WriteToFile will generate a new file at the given target path with the given contents. If a file already exists at the target path, the behavior depends on the value of IfExists: - if ExistsError, return an error. - if ExistsSkip, do nothing and return - if ExistsOverwrite, overwrite the existing file

Types

type GenerateConfig

type GenerateConfig struct {
	Path             string `cty:"path"`
	IfExists         GenerateConfigExists
	IfExistsStr      string `cty:"if_exists"`
	IfDisabled       GenerateConfigDisabled
	IfDisabledStr    string `cty:"if_disabled"`
	CommentPrefix    string `cty:"comment_prefix"`
	Contents         string `cty:"contents"`
	DisableSignature bool   `cty:"disable_signature"`
	Disable          bool   `cty:"disable"`
}

Configuration for generating code

type GenerateConfigDisabled added in v0.58.1

type GenerateConfigDisabled int

An enum to represent valid values for if_disabled

const (
	DisabledSkip GenerateConfigDisabled = iota
	DisabledRemove
	DisabledRemoveTerragrunt
	DisabledUnknown
)

func GenerateConfigDisabledFromString added in v0.58.1

func GenerateConfigDisabledFromString(val string) (GenerateConfigDisabled, error)

GenerateConfigDisabledFromString converts a string representation of if_disabled into the enum, returning an error if it is not set to one of the known values.

type GenerateConfigExists

type GenerateConfigExists int

An enum to represent valid values for if_exists

const (
	ExistsError GenerateConfigExists = iota
	ExistsSkip
	ExistsOverwrite
	ExistsOverwriteTerragrunt
	ExistsUnknown
)

func GenerateConfigExistsFromString

func GenerateConfigExistsFromString(val string) (GenerateConfigExists, error)

GenerateConfigExistsFromString converts a string representation of if_exists into the enum, returning an error if it is not set to one of the known values.

type GenerateFileExistsError

type GenerateFileExistsError struct {
	// contains filtered or unexported fields
}

func (GenerateFileExistsError) Error

func (err GenerateFileExistsError) Error() string

type GenerateFileRemoveError added in v0.58.1

type GenerateFileRemoveError struct {
	// contains filtered or unexported fields
}

func (GenerateFileRemoveError) Error added in v0.58.1

func (err GenerateFileRemoveError) Error() string

type UnknownGenerateIfDisabledVal added in v0.58.1

type UnknownGenerateIfDisabledVal struct {
	// contains filtered or unexported fields
}

func (UnknownGenerateIfDisabledVal) Error added in v0.58.1

type UnknownGenerateIfExistsVal

type UnknownGenerateIfExistsVal struct {
	// contains filtered or unexported fields
}

func (UnknownGenerateIfExistsVal) Error

func (err UnknownGenerateIfExistsVal) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL