Documentation ¶
Overview ¶
Package cliconfig provides methods to create an OpenTofu/Terraform CLI configuration file.
Index ¶
- func UserProviderDir() (string, error)
- type Config
- func (cfg *Config) AddHost(name string, services map[string]string)
- func (cfg *Config) AddProviderInstallationMethods(newMethods ...ProviderInstallationMethod)
- func (cfg *Config) Clone() *Config
- func (cfg *Config) CredentialsSource() *CredentialsSource
- func (cfg *Config) Save(configPath string) error
- type ConfigCredentials
- type ConfigCredentialsHelper
- type ConfigHost
- type CredentialsSource
- type ProviderInstallation
- type ProviderInstallationDirect
- func (method *ProviderInstallationDirect) AppendExclude(addrs []string)
- func (method *ProviderInstallationDirect) AppendInclude(addrs []string)
- func (method *ProviderInstallationDirect) Merge(with ProviderInstallationMethod) bool
- func (method *ProviderInstallationDirect) RemoveExclude(addrs []string)
- func (method *ProviderInstallationDirect) RemoveInclude(addrs []string)
- func (method *ProviderInstallationDirect) String() string
- type ProviderInstallationFilesystemMirror
- func (method *ProviderInstallationFilesystemMirror) AppendExclude(addrs []string)
- func (method *ProviderInstallationFilesystemMirror) AppendInclude(addrs []string)
- func (method *ProviderInstallationFilesystemMirror) Merge(with ProviderInstallationMethod) bool
- func (method *ProviderInstallationFilesystemMirror) RemoveExclude(addrs []string)
- func (method *ProviderInstallationFilesystemMirror) RemoveInclude(addrs []string)
- func (method *ProviderInstallationFilesystemMirror) String() string
- type ProviderInstallationMethod
- type ProviderInstallationMethods
- type ProviderInstallationNetworkMirror
- func (method *ProviderInstallationNetworkMirror) AppendExclude(addrs []string)
- func (method *ProviderInstallationNetworkMirror) AppendInclude(addrs []string)
- func (method *ProviderInstallationNetworkMirror) Merge(with ProviderInstallationMethod) bool
- func (method *ProviderInstallationNetworkMirror) RemoveExclude(addrs []string)
- func (method *ProviderInstallationNetworkMirror) RemoveInclude(addrs []string)
- func (method *ProviderInstallationNetworkMirror) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UserProviderDir ¶
Types ¶
type Config ¶
type Config struct { DisableCheckpoint bool `hcl:"disable_checkpoint"` DisableCheckpointSignature bool `hcl:"disable_checkpoint_signature"` Credentials []ConfigCredentials `hcl:"credentials,block"` CredentialsHelpers *ConfigCredentialsHelper `hcl:"credentials_helper,block"` PluginCacheDir string `hcl:"plugin_cache_dir"` Hosts []ConfigHost `hcl:"host,block"` ProviderInstallation *ProviderInstallation `hcl:"provider_installation,block"` }
Config provides methods to create a terraform [CLI config file](https://developer.hashicorp.com/terraform/cli/config/config-file). The main purpose of which is to create a local config that will inherit the default user CLI config and adding new sections to force Terraform to send requests through the Terragrunt Cache server and use the provider cache directory.
func LoadUserConfig ¶
LoadUserConfig loads the user configuration is read as raw data and stored at the top of the saved configuration file. The location of the default config is different for each OS https://developer.hashicorp.com/terraform/cli/config/config-file#locations
func (*Config) AddHost ¶
AddHost adds a host (officially undocumented), https://github.com/hashicorp/terraform/issues/28309 It gives us opportunity rewrite path to the remote registry and the most important thing is that it works smoothly with HTTP (without HTTPS)
host "registry.terraform.io" { services = { "providers.v1" = "http://localhost:5758/v1/providers/registry.terraform.io/", } }
func (*Config) AddProviderInstallationMethods ¶
func (cfg *Config) AddProviderInstallationMethods(newMethods ...ProviderInstallationMethod)
func (*Config) CredentialsSource ¶
func (cfg *Config) CredentialsSource() *CredentialsSource
CredentialsSource creates and returns a service credentials source whose behavior depends on which "credentials" if are present in the receiving config.
type ConfigCredentials ¶
ConfigCredentials is the structure of the "credentials" nested block within the CLI configuration.
type ConfigCredentialsHelper ¶
ConfigCredentialsHelper is the structure of the "credentials_helper" nested block within the CLI configuration.
type ConfigHost ¶
type ConfigHost struct { Name string `hcl:",label"` Services map[string]string `hcl:"services,attr"` }
ConfigHost is the structure of the "host" nested block within the CLI configuration, which can be used to override the default service host discovery behavior for a particular hostname.
type CredentialsSource ¶
type CredentialsSource struct {
// contains filtered or unexported fields
}
func (*CredentialsSource) ForHost ¶
func (s *CredentialsSource) ForHost(host svchost.Hostname) svcauth.HostCredentials
type ProviderInstallation ¶
type ProviderInstallation struct {
Methods ProviderInstallationMethods `hcl:",block"`
}
ProviderInstallation is the structure of the "provider_installation" nested block within the CLI configuration.
type ProviderInstallationDirect ¶
type ProviderInstallationDirect struct { Name string `hcl:",label" json:"Name"` Include *[]string `hcl:"include,optional" json:"Include"` Exclude *[]string `hcl:"exclude,optional" json:"Exclude"` }
func NewProviderInstallationDirect ¶
func NewProviderInstallationDirect(include, exclude []string) *ProviderInstallationDirect
func (*ProviderInstallationDirect) AppendExclude ¶
func (method *ProviderInstallationDirect) AppendExclude(addrs []string)
func (*ProviderInstallationDirect) AppendInclude ¶
func (method *ProviderInstallationDirect) AppendInclude(addrs []string)
func (*ProviderInstallationDirect) Merge ¶
func (method *ProviderInstallationDirect) Merge(with ProviderInstallationMethod) bool
func (*ProviderInstallationDirect) RemoveExclude ¶
func (method *ProviderInstallationDirect) RemoveExclude(addrs []string)
func (*ProviderInstallationDirect) RemoveInclude ¶
func (method *ProviderInstallationDirect) RemoveInclude(addrs []string)
func (*ProviderInstallationDirect) String ¶
func (method *ProviderInstallationDirect) String() string
type ProviderInstallationFilesystemMirror ¶
type ProviderInstallationFilesystemMirror struct { Name string `hcl:",label" json:"Name"` Path string `hcl:"path,attr" json:"Path"` Include *[]string `hcl:"include,optional" json:"Include"` Exclude *[]string `hcl:"exclude,optional" json:"Exclude"` }
func NewProviderInstallationFilesystemMirror ¶
func NewProviderInstallationFilesystemMirror(path string, include, exclude []string) *ProviderInstallationFilesystemMirror
func (*ProviderInstallationFilesystemMirror) AppendExclude ¶
func (method *ProviderInstallationFilesystemMirror) AppendExclude(addrs []string)
func (*ProviderInstallationFilesystemMirror) AppendInclude ¶
func (method *ProviderInstallationFilesystemMirror) AppendInclude(addrs []string)
func (*ProviderInstallationFilesystemMirror) Merge ¶
func (method *ProviderInstallationFilesystemMirror) Merge(with ProviderInstallationMethod) bool
func (*ProviderInstallationFilesystemMirror) RemoveExclude ¶
func (method *ProviderInstallationFilesystemMirror) RemoveExclude(addrs []string)
func (*ProviderInstallationFilesystemMirror) RemoveInclude ¶
func (method *ProviderInstallationFilesystemMirror) RemoveInclude(addrs []string)
func (*ProviderInstallationFilesystemMirror) String ¶
func (method *ProviderInstallationFilesystemMirror) String() string
type ProviderInstallationMethod ¶
type ProviderInstallationMethod interface { fmt.Stringer AppendInclude(addrs []string) AppendExclude(addrs []string) RemoveInclude(addrs []string) RemoveExclude(addrs []string) Merge(with ProviderInstallationMethod) bool }
ProviderInstallationMethod is an interface type representing the different installation path types and represents an installation method block inside a provider_installation block. The concrete implementations of this interface are:
ProviderInstallationDirect: install from the provider's origin registry ProviderInstallationFilesystemMirror: install from a local filesystem mirror
type ProviderInstallationMethods ¶
type ProviderInstallationMethods []ProviderInstallationMethod
func (ProviderInstallationMethods) Merge ¶
func (methods ProviderInstallationMethods) Merge(withMethods ...ProviderInstallationMethod) ProviderInstallationMethods
type ProviderInstallationNetworkMirror ¶
type ProviderInstallationNetworkMirror struct { Name string `hcl:",label" json:"Name"` URL string `hcl:"url,attr" json:"URL"` Include *[]string `hcl:"include,optional" json:"Include"` Exclude *[]string `hcl:"exclude,optional" json:"Exclude"` }
func NewProviderInstallationNetworkMirror ¶
func NewProviderInstallationNetworkMirror(url string, include, exclude []string) *ProviderInstallationNetworkMirror
func (*ProviderInstallationNetworkMirror) AppendExclude ¶
func (method *ProviderInstallationNetworkMirror) AppendExclude(addrs []string)
func (*ProviderInstallationNetworkMirror) AppendInclude ¶
func (method *ProviderInstallationNetworkMirror) AppendInclude(addrs []string)
func (*ProviderInstallationNetworkMirror) Merge ¶
func (method *ProviderInstallationNetworkMirror) Merge(with ProviderInstallationMethod) bool
func (*ProviderInstallationNetworkMirror) RemoveExclude ¶
func (method *ProviderInstallationNetworkMirror) RemoveExclude(addrs []string)
func (*ProviderInstallationNetworkMirror) RemoveInclude ¶
func (method *ProviderInstallationNetworkMirror) RemoveInclude(addrs []string)
func (*ProviderInstallationNetworkMirror) String ¶
func (method *ProviderInstallationNetworkMirror) String() string