Merge branch 'jrnt30-checkpoint-disable'

This commit is contained in:
Mitchell Hashimoto 2016-11-23 09:34:26 -08:00
commit e43f981662
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 58 additions and 18 deletions

View File

@ -183,6 +183,8 @@ func (c1 *Config) Merge(c2 *Config) *Config {
}
result.Provisioners[k] = v
}
result.DisableCheckpoint = c1.DisableCheckpoint || c2.DisableCheckpoint
result.DisableCheckpointSignature = c1.DisableCheckpointSignature || c2.DisableCheckpointSignature
return &result
}

View File

@ -66,3 +66,41 @@ func TestConfig_Merge(t *testing.T) {
t.Fatalf("bad: %#v", actual)
}
}
func TestConfig_Merge_disableCheckpoint(t *testing.T) {
c1 := &Config{
DisableCheckpoint: true,
}
c2 := &Config{}
expected := &Config{
Providers: map[string]string{},
Provisioners: map[string]string{},
DisableCheckpoint: true,
}
actual := c1.Merge(c2)
if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual)
}
}
func TestConfig_Merge_disableCheckpointSignature(t *testing.T) {
c1 := &Config{
DisableCheckpointSignature: true,
}
c2 := &Config{}
expected := &Config{
Providers: map[string]string{},
Provisioners: map[string]string{},
DisableCheckpointSignature: true,
}
actual := c1.Merge(c2)
if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual)
}
}

36
main.go
View File

@ -103,6 +103,24 @@ func wrappedMain() int {
return 1
}
// Load the configuration file if we have one, that can be used to
// define extra providers and provisioners.
clicfgFile, err := cliConfigFile()
if err != nil {
Ui.Error(fmt.Sprintf("Error loading CLI configuration: \n\n%s", err))
return 1
}
if clicfgFile != "" {
usrcfg, err := LoadConfig(clicfgFile)
if err != nil {
Ui.Error(fmt.Sprintf("Error loading CLI configuration: \n\n%s", err))
return 1
}
config = *config.Merge(usrcfg)
}
// Run checkpoint
go runCheckpoint(&config)
@ -129,24 +147,6 @@ func wrappedMain() int {
HelpWriter: os.Stdout,
}
// Load the configuration file if we have one, that can be used to
// define extra providers and provisioners.
clicfgFile, err := cliConfigFile()
if err != nil {
Ui.Error(fmt.Sprintf("Error loading CLI configuration: \n\n%s", err))
return 1
}
if clicfgFile != "" {
usrcfg, err := LoadConfig(clicfgFile)
if err != nil {
Ui.Error(fmt.Sprintf("Error loading CLI configuration: \n\n%s", err))
return 1
}
config = *config.Merge(usrcfg)
}
// Initialize the TFConfig settings for the commands...
ContextOpts.Providers = config.ProviderFactories()
ContextOpts.Provisioners = config.ProvisionerFactories()