cliconfig

package
v0.60.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserProviderDir

func UserProviderDir() (string, error)

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

func LoadUserConfig() (*Config, error)

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

func (cfg *Config) AddHost(name string, services map[string]string)

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 added in v0.58.7

func (cfg *Config) AddProviderInstallationMethods(methods ...ProviderInstallationMethod)

AddProviderInstallationMethods adds installation methods, https://developer.hashicorp.com/terraform/cli/config/config-file#provider-installation

provider_installation {
	filesystem_mirror {
		path    = "/path/to/the/provider/cache"
		include = ["example.com/*/*"]
	}
	direct {
		exclude = ["example.com/*/*"]
	}
}

func (*Config) Clone added in v0.58.7

func (cfg *Config) Clone() *Config

func (*Config) Save

func (cfg *Config) Save(configPath string) error

Save marshalls and saves CLI config with the given config path.

type ConfigCredentials added in v0.58.7

type ConfigCredentials struct {
	Name  string `hcl:",label"`
	Token string `hcl:"token"`
}

ConfigCredentials is the structure of the "credentials" nested block within the CLI configuration.

type ConfigCredentialsHelper added in v0.58.7

type ConfigCredentialsHelper struct {
	Name string   `hcl:",label"`
	Args []string `hcl:"args"`
}

ConfigCredentialsHelper is the structure of the "credentials_helper" nested block within the CLI configuration.

type ConfigHost added in v0.58.2

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 ProviderInstallation

type ProviderInstallation struct {
	Methods []ProviderInstallationMethod `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"`
	Include *[]string `hcl:"include,optional"`
	Exclude *[]string `hcl:"exclude,optional"`
}

func NewProviderInstallationDirect

func NewProviderInstallationDirect(include, exclude []string) *ProviderInstallationDirect

func (*ProviderInstallationDirect) AppendExclude added in v0.58.7

func (method *ProviderInstallationDirect) AppendExclude(addrs []string)

type ProviderInstallationFilesystemMirror

type ProviderInstallationFilesystemMirror struct {
	Name    string    `hcl:",label"`
	Path    string    `hcl:"path,attr"`
	Include *[]string `hcl:"include,optional"`
	Exclude *[]string `hcl:"exclude,optional"`
}

func NewProviderInstallationFilesystemMirror

func NewProviderInstallationFilesystemMirror(path string, include, exclude []string) *ProviderInstallationFilesystemMirror

func (*ProviderInstallationFilesystemMirror) AppendExclude added in v0.58.7

func (method *ProviderInstallationFilesystemMirror) AppendExclude(addrs []string)

type ProviderInstallationMethod

type ProviderInstallationMethod interface {
	AppendExclude(addrs []string)
}

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 ProviderInstallationNetworkMirror added in v0.58.7

type ProviderInstallationNetworkMirror struct {
	Name    string    `hcl:",label"`
	URL     string    `hcl:"url,attr"`
	Include *[]string `hcl:"include,optional"`
	Exclude *[]string `hcl:"exclude,optional"`
}

func NewProviderInstallationNetworkMirror added in v0.58.7

func NewProviderInstallationNetworkMirror(url string, include, exclude []string) *ProviderInstallationNetworkMirror

func (*ProviderInstallationNetworkMirror) AppendExclude added in v0.58.7

func (method *ProviderInstallationNetworkMirror) AppendExclude(addrs []string)

Jump to

Keyboard shortcuts

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