2014-05-25 19:39:44 -05:00
|
|
|
package main
|
|
|
|
|
2019-07-30 18:54:48 -05: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-19 18:43:18 -05:00
|
|
|
|
2019-07-30 18:54:48 -05:00
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/command/cliconfig"
|
2017-10-19 18:43:18 -05:00
|
|
|
"github.com/hashicorp/terraform/tfdiags"
|
2014-05-25 19:39:44 -05:00
|
|
|
)
|
|
|
|
|
2019-07-30 18:54:48 -05:00
|
|
|
//go:generate go run ./scripts/generate-plugins.go
|
2017-09-01 18:20:25 -05:00
|
|
|
|
2014-05-25 19:39:44 -05: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-30 18:54:48 -05:00
|
|
|
// "configs" package.
|
|
|
|
type Config = cliconfig.Config
|
2017-10-19 19:40:20 -05:00
|
|
|
|
2017-10-25 18:00:08 -05: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-30 18:54:48 -05:00
|
|
|
type ConfigHost = cliconfig.ConfigHost
|
2017-10-25 18:00:08 -05:00
|
|
|
|
2017-10-19 19:40:20 -05:00
|
|
|
// ConfigCredentialsHelper is the structure of the "credentials_helper"
|
|
|
|
// nested block within the CLI configuration.
|
2019-07-30 18:54:48 -05:00
|
|
|
type ConfigCredentialsHelper = cliconfig.ConfigCredentialsHelper
|
2014-05-25 19:39:44 -05:00
|
|
|
|
2014-06-09 23:44:13 -05:00
|
|
|
// BuiltinConfig is the built-in defaults for the configuration. These
|
|
|
|
// can be overridden by user configurations.
|
2019-07-30 18:54:48 -05:00
|
|
|
var BuiltinConfig = cliconfig.BuiltinConfig
|
2014-07-03 14:01:20 -05:00
|
|
|
|
2014-08-19 12:58:23 -05: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-30 18:54:48 -05:00
|
|
|
return cliconfig.ConfigFile()
|
2014-08-19 12:58:23 -05:00
|
|
|
}
|
|
|
|
|
2014-09-27 14:36:13 -05:00
|
|
|
// ConfigDir returns the configuration directory for Terraform.
|
|
|
|
func ConfigDir() (string, error) {
|
2019-07-30 18:54:48 -05:00
|
|
|
return cliconfig.ConfigDir()
|
2014-09-27 14:36:13 -05:00
|
|
|
}
|
|
|
|
|
2017-10-19 19:01:02 -05: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-30 18:54:48 -05:00
|
|
|
return cliconfig.LoadConfig()
|
2017-10-19 19:28:44 -05:00
|
|
|
}
|
|
|
|
|
2017-09-01 18:20:25 -05: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-30 18:54:48 -05:00
|
|
|
return cliconfig.EnvConfig()
|
2014-06-09 23:57:37 -05:00
|
|
|
}
|