Compile
This commit is contained in:
parent
9183068489
commit
0e88867052
|
@ -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,
|
||||
}
|
||||
}
|
18
commands.go
18
commands.go
|
@ -29,30 +29,30 @@ func init() {
|
|||
Commands = map[string]cli.CommandFactory{
|
||||
"apply": func() (cli.Command, error) {
|
||||
return &command.ApplyCommand{
|
||||
ShutdownCh: makeShutdownCh(),
|
||||
TFConfig: &TFConfig,
|
||||
Ui: Ui,
|
||||
ShutdownCh: makeShutdownCh(),
|
||||
ContextOpts: &ContextOpts,
|
||||
Ui: Ui,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"graph": func() (cli.Command, error) {
|
||||
return &command.GraphCommand{
|
||||
TFConfig: &TFConfig,
|
||||
Ui: Ui,
|
||||
ContextOpts: &ContextOpts,
|
||||
Ui: Ui,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"plan": func() (cli.Command, error) {
|
||||
return &command.PlanCommand{
|
||||
TFConfig: &TFConfig,
|
||||
Ui: Ui,
|
||||
ContextOpts: &ContextOpts,
|
||||
Ui: Ui,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"refresh": func() (cli.Command, error) {
|
||||
return &command.RefreshCommand{
|
||||
TFConfig: &TFConfig,
|
||||
Ui: Ui,
|
||||
ContextOpts: &ContextOpts,
|
||||
Ui: Ui,
|
||||
}, nil
|
||||
},
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ type Config struct {
|
|||
// can be overridden by user configurations.
|
||||
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
|
||||
// equally behaving parsing everywhere.
|
||||
const libuclParseFlags = libucl.ParserKeyLowercase
|
||||
|
|
2
main.go
2
main.go
|
@ -84,7 +84,7 @@ func wrappedMain() int {
|
|||
defer plugin.CleanupClients()
|
||||
|
||||
// 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
|
||||
// just show the version.
|
||||
|
|
Loading…
Reference in New Issue