mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-27 17:06:27 -06:00
Compile
This commit is contained in:
parent
9183068489
commit
0e88867052
25
command/config.go
Normal file
25
command/config.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
"github.com/mitchellh/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config is a structure used to configure many commands with Terraform
|
||||||
|
// configurations.
|
||||||
|
type Config struct {
|
||||||
|
Hooks []terraform.Hook
|
||||||
|
Providers map[string]terraform.ResourceProviderFactory
|
||||||
|
Ui cli.Ui
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Config) ContextOpts() *terraform.ContextOpts {
|
||||||
|
hooks := make([]terraform.Hook, len(c.Hooks)+1)
|
||||||
|
copy(hooks, c.Hooks)
|
||||||
|
hooks[len(c.Hooks)] = &UiHook{Ui: c.Ui}
|
||||||
|
|
||||||
|
return &terraform.ContextOpts{
|
||||||
|
Hooks: hooks,
|
||||||
|
Providers: c.Providers,
|
||||||
|
}
|
||||||
|
}
|
@ -30,28 +30,28 @@ func init() {
|
|||||||
"apply": func() (cli.Command, error) {
|
"apply": func() (cli.Command, error) {
|
||||||
return &command.ApplyCommand{
|
return &command.ApplyCommand{
|
||||||
ShutdownCh: makeShutdownCh(),
|
ShutdownCh: makeShutdownCh(),
|
||||||
TFConfig: &TFConfig,
|
ContextOpts: &ContextOpts,
|
||||||
Ui: Ui,
|
Ui: Ui,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
"graph": func() (cli.Command, error) {
|
"graph": func() (cli.Command, error) {
|
||||||
return &command.GraphCommand{
|
return &command.GraphCommand{
|
||||||
TFConfig: &TFConfig,
|
ContextOpts: &ContextOpts,
|
||||||
Ui: Ui,
|
Ui: Ui,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
"plan": func() (cli.Command, error) {
|
"plan": func() (cli.Command, error) {
|
||||||
return &command.PlanCommand{
|
return &command.PlanCommand{
|
||||||
TFConfig: &TFConfig,
|
ContextOpts: &ContextOpts,
|
||||||
Ui: Ui,
|
Ui: Ui,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
"refresh": func() (cli.Command, error) {
|
"refresh": func() (cli.Command, error) {
|
||||||
return &command.RefreshCommand{
|
return &command.RefreshCommand{
|
||||||
TFConfig: &TFConfig,
|
ContextOpts: &ContextOpts,
|
||||||
Ui: Ui,
|
Ui: Ui,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
@ -23,6 +23,9 @@ type Config struct {
|
|||||||
// can be overridden by user configurations.
|
// can be overridden by user configurations.
|
||||||
var BuiltinConfig Config
|
var BuiltinConfig Config
|
||||||
|
|
||||||
|
// ContextOpts are the global ContextOpts we use to initialize the CLI.
|
||||||
|
var ContextOpts terraform.ContextOpts
|
||||||
|
|
||||||
// Put the parse flags we use for libucl in a constant so we can get
|
// Put the parse flags we use for libucl in a constant so we can get
|
||||||
// equally behaving parsing everywhere.
|
// equally behaving parsing everywhere.
|
||||||
const libuclParseFlags = libucl.ParserKeyLowercase
|
const libuclParseFlags = libucl.ParserKeyLowercase
|
||||||
|
2
main.go
2
main.go
@ -84,7 +84,7 @@ func wrappedMain() int {
|
|||||||
defer plugin.CleanupClients()
|
defer plugin.CleanupClients()
|
||||||
|
|
||||||
// Initialize the TFConfig settings for the commands...
|
// Initialize the TFConfig settings for the commands...
|
||||||
TFConfig.Providers = config.ProviderFactories()
|
ContextOpts.Providers = config.ProviderFactories()
|
||||||
|
|
||||||
// Get the command line args. We shortcut "--version" and "-v" to
|
// Get the command line args. We shortcut "--version" and "-v" to
|
||||||
// just show the version.
|
// just show the version.
|
||||||
|
Loading…
Reference in New Issue
Block a user