2014-05-26 02:39:44 +02:00
|
|
|
package main
|
|
|
|
|
2019-07-31 01:54:48 +02:00
|
|
|
// This file has some compatibility aliases/wrappers for functionality that
|
|
|
|
// has now moved into command/cliconfig .
|
|
|
|
//
|
|
|
|
// Don't add anything new here! If new functionality is needed, better to just
|
|
|
|
// add it in command/cliconfig and then call there directly.
|
2017-10-20 01:43:18 +02:00
|
|
|
|
2019-07-31 01:54:48 +02:00
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/command/cliconfig"
|
2017-10-20 01:43:18 +02:00
|
|
|
"github.com/hashicorp/terraform/tfdiags"
|
2014-05-26 02:39:44 +02:00
|
|
|
)
|
|
|
|
|
2019-07-31 01:54:48 +02:00
|
|
|
//go:generate go run ./scripts/generate-plugins.go
|
2017-09-02 01:20:25 +02:00
|
|
|
|
2014-05-26 02:39:44 +02:00
|
|
|
// Config is the structure of the configuration for the Terraform CLI.
|
|
|
|
//
|
|
|
|
// This is not the configuration for Terraform itself. That is in the
|
2019-07-31 01:54:48 +02:00
|
|
|
// "configs" package.
|
|
|
|
type Config = cliconfig.Config
|
2017-10-20 02:40:20 +02:00
|
|
|
|
2017-10-26 01:00:08 +02:00
|
|
|
// 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.
|
2019-07-31 01:54:48 +02:00
|
|
|
type ConfigHost = cliconfig.ConfigHost
|
2017-10-26 01:00:08 +02:00
|
|
|
|
2017-10-20 02:40:20 +02:00
|
|
|
// ConfigCredentialsHelper is the structure of the "credentials_helper"
|
|
|
|
// nested block within the CLI configuration.
|
2019-07-31 01:54:48 +02:00
|
|
|
type ConfigCredentialsHelper = cliconfig.ConfigCredentialsHelper
|
2014-05-26 02:39:44 +02:00
|
|
|
|
2014-06-10 06:44:13 +02:00
|
|
|
// BuiltinConfig is the built-in defaults for the configuration. These
|
|
|
|
// can be overridden by user configurations.
|
2019-07-31 01:54:48 +02:00
|
|
|
var BuiltinConfig = cliconfig.BuiltinConfig
|
2014-07-03 21:01:20 +02:00
|
|
|
|
2014-08-19 19:58:23 +02:00
|
|
|
// ConfigFile returns the default path to the configuration file.
|
|
|
|
//
|
|
|
|
// On Unix-like systems this is the ".terraformrc" file in the home directory.
|
|
|
|
// On Windows, this is the "terraform.rc" file in the application data
|
|
|
|
// directory.
|
|
|
|
func ConfigFile() (string, error) {
|
2019-07-31 01:54:48 +02:00
|
|
|
return cliconfig.ConfigFile()
|
2014-08-19 19:58:23 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 21:36:13 +02:00
|
|
|
// ConfigDir returns the configuration directory for Terraform.
|
|
|
|
func ConfigDir() (string, error) {
|
2019-07-31 01:54:48 +02:00
|
|
|
return cliconfig.ConfigDir()
|
2014-09-27 21:36:13 +02:00
|
|
|
}
|
|
|
|
|
2017-10-20 02:01:02 +02:00
|
|
|
// LoadConfig reads the CLI configuration from the various filesystem locations
|
|
|
|
// and from the environment, returning a merged configuration along with any
|
|
|
|
// diagnostics (errors and warnings) encountered along the way.
|
|
|
|
func LoadConfig() (*Config, tfdiags.Diagnostics) {
|
2019-07-31 01:54:48 +02:00
|
|
|
return cliconfig.LoadConfig()
|
2017-10-20 02:28:44 +02:00
|
|
|
}
|
|
|
|
|
2017-09-02 01:20:25 +02:00
|
|
|
// EnvConfig returns a Config populated from environment variables.
|
|
|
|
//
|
|
|
|
// Any values specified in this config should override those set in the
|
|
|
|
// configuration file.
|
|
|
|
func EnvConfig() *Config {
|
2019-07-31 01:54:48 +02:00
|
|
|
return cliconfig.EnvConfig()
|
2014-06-10 06:57:37 +02:00
|
|
|
}
|