Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ability to disable backend init so that validate-all can be run without a backend #761

Merged
merged 4 commits into from Jul 1, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Move to disable_init over enabled

  • Loading branch information...
stefansedich committed Jun 25, 2019
commit d8600fcf50df96b61ebf837bffcd5dba9461b166
@@ -54,9 +54,9 @@ type terragruntInclude struct {

// Configuration for Terraform remote state as parsed from a terragrunt.hcl config file
type remoteStateConfigFile struct {
Backend string `hcl:"backend,attr"`
Enabled *bool `hcl:"enabled,attr"`
Config cty.Value `hcl:"config,attr"`
Backend string `hcl:"backend,attr"`
DisableInit *bool `hcl:"disable_init,attr"`
Config cty.Value `hcl:"config,attr"`
}

func (remoteState *remoteStateConfigFile) String() string {
@@ -521,15 +521,14 @@ func convertToTerragruntConfig(terragruntConfigFromFile *terragruntConfigFile, c
}

remoteState := &remote.RemoteState{}
remoteState.FillDefaults()

remoteState.Backend = terragruntConfigFromFile.RemoteState.Backend
remoteState.Config = remoteStateConfig

if terragruntConfigFromFile.RemoteState.Enabled != nil {
remoteState.Enabled = *terragruntConfigFromFile.RemoteState.Enabled
if terragruntConfigFromFile.RemoteState.DisableInit != nil {
remoteState.DisableInit = *terragruntConfigFromFile.RemoteState.DisableInit
}

remoteState.FillDefaults()
if err := remoteState.Validate(); err != nil {
return nil, err
}
@@ -9,13 +9,13 @@ import (

// Configuration for Terraform remote state
type RemoteState struct {
Backend string
Enabled bool
Config map[string]interface{}
Backend string
DisableInit bool
Config map[string]interface{}
}

func (remoteState *RemoteState) String() string {
return fmt.Sprintf("RemoteState{Backend = %v, Enabled = %v, Config = %v}", remoteState.Backend, remoteState.Enabled, remoteState.Config)
return fmt.Sprintf("RemoteState{Backend = %v, DisableInit = %v, Config = %v}", remoteState.Backend, remoteState.DisableInit, remoteState.Config)
}

type RemoteStateInitializer interface {
@@ -37,7 +37,7 @@ var remoteStateInitializers = map[string]RemoteStateInitializer{

// Fill in any default configuration for remote state
func (remoteState *RemoteState) FillDefaults() {
remoteState.Enabled = true
// Nothing to do
}

// Validate that the remote state is configured correctly
@@ -72,7 +72,7 @@ func (remoteState *RemoteState) NeedsInit(terragruntOptions *options.TerragruntO
return false, err
}

if !remoteState.Enabled {
if remoteState.DisableInit {
return false, nil
}

@@ -133,7 +133,7 @@ func terraformStateConfigEqual(existingConfig map[string]interface{}, newConfig
// Convert the RemoteState config into the format used by the terraform init command
func (remoteState RemoteState) ToTerraformInitArgs() []string {
config := remoteState.Config
if !remoteState.Enabled {
if remoteState.DisableInit {
return []string{"-backend=false"}
}

@@ -96,7 +96,7 @@ type S3Initializer struct{}
// 1. Any of the existing backend settings are different than the current config
// 2. The configured S3 bucket or DynamoDB table does not exist
func (s3Initializer S3Initializer) NeedsInitialization(remoteState *RemoteState, existingBackend *TerraformBackend, terragruntOptions *options.TerragruntOptions) (bool, error) {
if !remoteState.Enabled {
if remoteState.DisableInit {
return false, nil
}

BIN +30.1 MB terragrunt
Binary file not shown.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.