cliconfig

package
v0.57.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal added in v0.57.6

func Marshal(current interface{}) ([]byte, error)

Marshal marshals object into HCL string

func MarshalLevel added in v0.57.6

func MarshalLevel(current interface{}, level int) ([]byte, error)

func UserProviderDir

func UserProviderDir() (string, error)

Types

type Config

type Config struct {
	PluginCacheDir       string                           `hcl:"plugin_cache_dir"`
	Hosts                map[string]*cliconfig.ConfigHost `hcl:"host"`
	ProviderInstallation *ProviderInstallation            `hcl:"provider_installation"`
	// 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]any)

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 ProviderInstallation

type ProviderInstallation struct {
	FilesystemMirror *ProviderInstallationFilesystemMirror `hcl:"filesystem_mirror"`
	Direct           *ProviderInstallationDirect           `hcl:"direct"`
}

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

type ProviderInstallationDirect

type ProviderInstallationDirect struct {
	*ProviderInstallationMethod
}

func NewProviderInstallationDirect

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

type ProviderInstallationFilesystemMirror

type ProviderInstallationFilesystemMirror struct {
	Location string `hcl:"path"`
	*ProviderInstallationMethod
}

func NewProviderInstallationFilesystemMirror

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

type ProviderInstallationMethod

type ProviderInstallationMethod struct {
	Include []string `hcl:"include"`
	Exclude []string `hcl:"exclude"`
}

ProviderInstallationMethod represents an installation method block inside a provider_installation block.

Jump to

Keyboard shortcuts

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