codegen

package
v0.23.28 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 12 Imported by: 0

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"
)

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(logger *log.Logger, 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"`
	CommentPrefix    string `cty:"comment_prefix"`
	Contents         string `cty:"contents"`
	DisableSignature bool   `cty:"disable_signature"`
}

Configuration for generating code

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 converst 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 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