config

package
v1.8.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncryptionConfig

type EncryptionConfig struct {
	KeyProviderConfigs []KeyProviderConfig `hcl:"key_provider,block"`
	MethodConfigs      []MethodConfig      `hcl:"method,block"`

	State  *EnforcableTargetConfig `hcl:"state,block"`
	Plan   *EnforcableTargetConfig `hcl:"plan,block"`
	Remote *RemoteConfig           `hcl:"remote_state_data_sources,block"`

	// Not preserved through merge operations
	DeclRange hcl.Range
}

EncryptionConfig describes the terraform.encryption HCL block you can use to configure the state and plan encryption. The individual fields of this struct match the HCL structure directly.

func DecodeConfig

func DecodeConfig(body hcl.Body, rng hcl.Range) (*EncryptionConfig, hcl.Diagnostics)

DecodeConfig takes a hcl.Body and decodes it into a Config struct. This method is here as an example for how someone using this library might want to decode a configuration. if they were not using gohcl directly. Right now for real world use this is only intended to be used in tests, until we publish this publicly.

func LoadConfigFromString

func LoadConfigFromString(sourceName string, rawInput string) (*EncryptionConfig, hcl.Diagnostics)

LoadConfigFromString loads a configuration from a string. The sourceName is used to identify the source of the configuration in error messages. This method serves as an example for how someone using this library might want to load a configuration. if they were not using gohcl directly. However! Right now, this method should only be used in tests, as OpenTofu should be using gohcl to parse the configuration.

func MergeConfigs

func MergeConfigs(cfg *EncryptionConfig, override *EncryptionConfig) *EncryptionConfig

MergeConfigs merges two Configs together, with the override taking precedence.

func (*EncryptionConfig) GetKeyProvider added in v1.8.0

func (c *EncryptionConfig) GetKeyProvider(kpType, kpName string) (KeyProviderConfig, bool)

GetKeyProvider takes type and name arguments to find a respective KeyProviderConfig in the list.

func (*EncryptionConfig) Merge

func (c *EncryptionConfig) Merge(override *EncryptionConfig) *EncryptionConfig

Merge returns a merged configuration with the current config and the specified override combined, the override taking precedence.

type EnforcableTargetConfig

type EnforcableTargetConfig struct {
	Enforced bool           `hcl:"enforced,optional"`
	Method   hcl.Expression `hcl:"method,optional"`
	Fallback *TargetConfig  `hcl:"fallback,block"`
}

EnforcableTargetConfig is an extension of the TargetConfig that supports the enforced form.

Note: This struct is copied because gohcl does not support embedding.

func (EnforcableTargetConfig) AsTargetConfig

func (e EnforcableTargetConfig) AsTargetConfig() *TargetConfig

AsTargetConfig converts the struct into its parent TargetConfig.

type KeyProviderConfig

type KeyProviderConfig struct {
	Type string   `hcl:"type,label"`
	Name string   `hcl:"name,label"`
	Body hcl.Body `hcl:",remain"`
}

KeyProviderConfig describes the terraform.encryption.key_provider.* block you can use to declare a key provider for encryption. The Body field will contain the remaining undeclared fields the key provider can consume.

func (KeyProviderConfig) Addr

func (k KeyProviderConfig) Addr() (keyprovider.Addr, hcl.Diagnostics)

Addr returns a keyprovider.Addr from the current configuration.

type MethodConfig

type MethodConfig struct {
	Type string   `hcl:"type,label"`
	Name string   `hcl:"name,label"`
	Body hcl.Body `hcl:",remain"`
}

MethodConfig describes the terraform.encryption.method.* block you can use to declare the encryption method. The Body field will contain the remaining undeclared fields the method can consume.

func (MethodConfig) Addr

func (m MethodConfig) Addr() (method.Addr, hcl.Diagnostics)

type NamedTargetConfig

type NamedTargetConfig struct {
	Name     string         `hcl:"name,label"`
	Method   hcl.Expression `hcl:"method,optional"`
	Fallback *TargetConfig  `hcl:"fallback,block"`
}

NamedTargetConfig is an extension of the TargetConfig that describes a terraform.encryption.remote.remote_state_data.* block.

Note: This struct is copied because gohcl does not support embedding.

func (NamedTargetConfig) AsTargetConfig

func (n NamedTargetConfig) AsTargetConfig() *TargetConfig

AsTargetConfig converts the struct into its parent TargetConfig.

type RemoteConfig

type RemoteConfig struct {
	Default *TargetConfig       `hcl:"default,block"`
	Targets []NamedTargetConfig `hcl:"remote_state_data_source,block"`
}

RemoteConfig describes the terraform.encryption.remote block you can use to declare encryption for remote state data sources.

type TargetConfig

type TargetConfig struct {
	Method   hcl.Expression `hcl:"method,optional"`
	Fallback *TargetConfig  `hcl:"fallback,block"`
}

TargetConfig describes the target.encryption.state, target.encryption.plan, etc blocks.

Jump to

Keyboard shortcuts

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