mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 08:00:17 -06:00
Remove config.go and update things using its aliases
This commit is contained in:
parent
37d16b2f79
commit
78b1220558
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/go-checkpoint"
|
||||
"github.com/hashicorp/terraform/command"
|
||||
"github.com/hashicorp/terraform/command/cliconfig"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -17,7 +18,7 @@ var checkpointResult chan *checkpoint.CheckResponse
|
||||
|
||||
// runCheckpoint runs a HashiCorp Checkpoint request. You can read about
|
||||
// Checkpoint here: https://github.com/hashicorp/go-checkpoint.
|
||||
func runCheckpoint(c *Config) {
|
||||
func runCheckpoint(c *cliconfig.Config) {
|
||||
// If the user doesn't want checkpoint at all, then return.
|
||||
if c.DisableCheckpoint {
|
||||
log.Printf("[INFO] Checkpoint disabled. Not running.")
|
||||
@ -25,7 +26,7 @@ func runCheckpoint(c *Config) {
|
||||
return
|
||||
}
|
||||
|
||||
configDir, err := ConfigDir()
|
||||
configDir, err := cliconfig.ConfigDir()
|
||||
if err != nil {
|
||||
log.Printf("[ERR] Checkpoint setup error: %s", err)
|
||||
checkpointResult <- nil
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
|
||||
"github.com/hashicorp/terraform-svchost"
|
||||
svchost "github.com/hashicorp/terraform-svchost"
|
||||
"github.com/hashicorp/terraform-svchost/auth"
|
||||
"github.com/hashicorp/terraform-svchost/disco"
|
||||
"github.com/hashicorp/terraform/command"
|
||||
@ -37,7 +37,7 @@ const (
|
||||
OutputPrefix = "o:"
|
||||
)
|
||||
|
||||
func initCommands(config *Config, services *disco.Disco) {
|
||||
func initCommands(config *cliconfig.Config, services *disco.Disco) {
|
||||
var inAutomation bool
|
||||
if v := os.Getenv(runningInAutomationEnvName); v != "" {
|
||||
inAutomation = true
|
||||
@ -390,7 +390,7 @@ func makeShutdownCh() <-chan struct{} {
|
||||
return resultCh
|
||||
}
|
||||
|
||||
func credentialsSource(config *Config) (auth.CredentialsSource, error) {
|
||||
func credentialsSource(config *cliconfig.Config) (auth.CredentialsSource, error) {
|
||||
helperPlugins := pluginDiscovery.FindPlugins("credentials", globalPluginDirs())
|
||||
return config.CredentialsSource(helperPlugins)
|
||||
}
|
||||
|
37
config.go
37
config.go
@ -1,37 +0,0 @@
|
||||
package main
|
||||
|
||||
// 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.
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/command/cliconfig"
|
||||
"github.com/hashicorp/terraform/tfdiags"
|
||||
)
|
||||
|
||||
//go:generate go run ./scripts/generate-plugins.go
|
||||
|
||||
// Config is the structure of the configuration for the Terraform CLI.
|
||||
//
|
||||
// This is not the configuration for Terraform itself. That is in the
|
||||
// "configs" package.
|
||||
type Config = cliconfig.Config
|
||||
|
||||
// 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 ConfigHost = cliconfig.ConfigHost
|
||||
|
||||
// ConfigDir returns the configuration directory for Terraform.
|
||||
func ConfigDir() (string, error) {
|
||||
return cliconfig.ConfigDir()
|
||||
}
|
||||
|
||||
// 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) {
|
||||
return cliconfig.LoadConfig()
|
||||
}
|
3
main.go
3
main.go
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/terraform-svchost/disco"
|
||||
"github.com/hashicorp/terraform/command/cliconfig"
|
||||
"github.com/hashicorp/terraform/command/format"
|
||||
"github.com/hashicorp/terraform/helper/logging"
|
||||
"github.com/hashicorp/terraform/httpclient"
|
||||
@ -125,7 +126,7 @@ func wrappedMain() int {
|
||||
log.Printf("[INFO] Go runtime version: %s", runtime.Version())
|
||||
log.Printf("[INFO] CLI args: %#v", os.Args)
|
||||
|
||||
config, diags := LoadConfig()
|
||||
config, diags := cliconfig.LoadConfig()
|
||||
if len(diags) > 0 {
|
||||
// Since we haven't instantiated a command.Meta yet, we need to do
|
||||
// some things manually here and use some "safe" defaults for things
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/hashicorp/terraform/command/cliconfig"
|
||||
)
|
||||
|
||||
// globalPluginDirs returns directories that should be searched for
|
||||
@ -16,7 +18,7 @@ import (
|
||||
func globalPluginDirs() []string {
|
||||
var ret []string
|
||||
// Look in ~/.terraform.d/plugins/ , or its equivalent on non-UNIX
|
||||
dir, err := ConfigDir()
|
||||
dir, err := cliconfig.ConfigDir()
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Error finding global config directory: %s", err)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user