cliconfig

package
v0.58.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 9 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 {
	PluginCacheDir       string                `hcl:"plugin_cache_dir"`
	Hosts                []ConfigHost          `hcl:"host,block"`
	ProviderInstallation *ProviderInstallation `hcl:"provider_installation,block"`
	// contains filtered or unexported fields
}

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

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

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

func (*Config) SetProviderInstallation

func (cfg *Config) SetProviderInstallation(filesystemMethod *ProviderInstallationFilesystemMirror, directMethod *ProviderInstallationDirect)

SetProviderInstallation sets an installation method, 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/*/*"]
	}
}

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 {
	FilesystemMirror *ProviderInstallationFilesystemMirror `hcl:"filesystem_mirror,block"`
	Direct           *ProviderInstallationDirect           `hcl:"direct,block"`
}

ProviderInstallation is the structure of the "provider_installation" nested block within the CLI configuration.

type ProviderInstallationDirect

type ProviderInstallationDirect struct {
	Include *[]string `hcl:"include,attr"`
	Exclude *[]string `hcl:"exclude,attr"`
}

func NewProviderInstallationDirect

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

type ProviderInstallationFilesystemMirror

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

func NewProviderInstallationFilesystemMirror

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

Jump to

Keyboard shortcuts

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