config

package
v0.3.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileMain = "main.tf"
	FileVars = "terraform.tfvars"
)

Variables

This section is empty.

Functions

func CreateConfigToBytes

func CreateConfigToBytes(opts CreateOptions) ([]byte, error)

func Format

func Format(hcl []byte) []byte

Format formats the hcl with the transformations.

func ToModuleBlock

func ToModuleBlock(mc *ModuleConfig) (*block.Block, error)

ToModuleBlock returns module block for the given module and variables.

Types

type Config

type Config struct {

	// Attributes is the attributes of the Config.
	// E.g.
	// Attr1 = "xxx"
	// attr2 = 1
	// attr3 = true.
	Attributes map[string]any

	// Blocks blocks like terraform, provider, module, etc.
	/**
	  terraform {
	  	backend "http" {
	  		xxx
	  	}
	  	xxx
	  }
	  provider "aws" {
	  	region = "us-east-1"
	  }

	  module "aws" {
	  	source = "xxx"
	  	region = "us-east-1"
	  }
	*/
	Blocks block.Blocks
	// contains filtered or unexported fields
}

Config handles the configuration of application to terraform config.

func NewConfig

func NewConfig(opts CreateOptions) (*Config, error)

NewConfig returns a new Config.

func (*Config) AddBlocks

func (c *Config) AddBlocks(blocks block.Blocks) error

AddBlocks adds a block to the configuration.

func (*Config) Bytes

func (c *Config) Bytes() ([]byte, error)

Bytes returns the bytes of the config.

func (*Config) Reader

func (c *Config) Reader() (io.Reader, error)

Reader returns a reader of the config.

func (*Config) WriteTo

func (c *Config) WriteTo(w io.Writer) (int64, error)

WriteTo writes the config to the writer.

type CreateOptions

type CreateOptions struct {
	Attributes       map[string]any
	TerraformOptions *TerraformOptions
	ProviderOptions  *ProviderOptions
	ModuleOptions    *ModuleOptions
	VariableOptions  *VariableOptions
	OutputOptions    OutputOptions
}

CreateOptions represents the CreateOptions of the Config.

type ModuleConfig

type ModuleConfig struct {
	// Name is the module name.
	Name string
	// Source is the module source.
	Source string
	// Schema is the variable schema.
	Schema *types.TemplateSchema
	// Attributes is the attributes of the module.
	Attributes map[string]any
	// Outputs is the module outputs.
	Outputs []Output
}

ModuleConfig is a struct with model.Template and its variables.

type ModuleOptions

type ModuleOptions struct {
	// ModuleConfigs is the module configs of the deployment.
	ModuleConfigs []*ModuleConfig
}

ModuleOptions is the options to create module blocks.

type Output

type Output struct {
	ServiceName string
	Name        string
	Sensitive   bool
	Value       []byte
}

Output indicate the output name and module.

type OutputOptions

type OutputOptions []Output

OutputOptions is the options to create outputs blocks.

type ProviderOptions

type ProviderOptions struct {
	// SecretMountPath is the mount path of the secret in the terraform config.
	SecretMonthPath string
	// ConnectorSeparator is the separator of the terraform provider alias name and id.
	ConnectorSeparator string
	// RequiredProviderNames is the required providers of the terraform config.
	// E.g. ["kubernetes", "helm"].
	RequiredProviderNames []string
	Connectors            model.Connectors
}

ProviderOptions is the options to create provider blocks.

type TerraformOptions

type TerraformOptions struct {
	// Token is the backend token to authenticate with the Seal Server of the terraform config.
	Token string
	// Address is the backend address of the terraform config.
	Address string
	// SkipTLSVerify is the backend cert verification of the terraform config.
	SkipTLSVerify bool

	// ProviderRequirements is the required providers of the terraform config.
	ProviderRequirements map[string]*tfconfig.ProviderRequirement
}

TerraformOptions is the options to create terraform block.

type VariableOptions

type VariableOptions struct {
	// VariablePrefix is the prefix of the variable name.
	VariablePrefix string
	// SecretServicePrefix is the prefix of the secret service name.
	ServicePrefix string
	// Variables is map with name in key and sensitive flag in value.
	Variables map[string]bool
	// DependencyOutputs is the map of the variable name and value.
	DependencyOutputs map[string]parser.OutputState
}

VariableOptions is the options to create variables blocks.

Jump to

Keyboard shortcuts

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