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

Disable component inheritance chain #85

Merged
merged 1 commit into from Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/spacelift/spacelift_stack_processor_test.go
Expand Up @@ -15,7 +15,7 @@ func TestSpaceliftStackProcessor(t *testing.T) {

var spaceliftStacks, err = CreateSpaceliftStacks("", nil, processStackDeps, processComponentDeps, processImports, stackConfigPathTemplate)
assert.Nil(t, err)
assert.Equal(t, 30, len(spaceliftStacks))
assert.Equal(t, 24, len(spaceliftStacks))

tenant1Ue2DevInfraVpcStack := spaceliftStacks["tenant1-ue2-dev-infra-vpc"].(map[string]interface{})
tenant1Ue2DevInfraVpcStackInfrastructureStackName := tenant1Ue2DevInfraVpcStack["stack"].(string)
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestLegacySpaceliftStackProcessor(t *testing.T) {

var spaceliftStacks, err = CreateSpaceliftStacks(basePath, filePaths, processStackDeps, processComponentDeps, processImports, stackConfigPathTemplate)
assert.Nil(t, err)
assert.Equal(t, 30, len(spaceliftStacks))
assert.Equal(t, 24, len(spaceliftStacks))

tenant1Ue2DevInfraVpcStack := spaceliftStacks["tenant1-ue2-dev-infra-vpc"].(map[string]interface{})
tenant1Ue2DevInfraVpcStackBackend := tenant1Ue2DevInfraVpcStack["backend"].(map[interface{}]interface{})
Expand Down
27 changes: 14 additions & 13 deletions pkg/stack/stack_processor.go
Expand Up @@ -669,19 +669,20 @@ func processBaseComponentConfig(
baseComponentMap = baseComponentSection.(map[interface{}]interface{})

// First, process the base component of this base component
if baseComponentOfBaseComponent, baseComponentOfBaseComponentExist := baseComponentMap["component"]; baseComponentOfBaseComponentExist {
err := processBaseComponentConfig(
baseComponentConfig,
allTerraformComponentsMap,
baseComponent,
stack,
baseComponentOfBaseComponent.(string),
)

if err != nil {
return err
}
}
// TODO: Review/fix this for some edge cases of stacks config
//if baseComponentOfBaseComponent, baseComponentOfBaseComponentExist := baseComponentMap["component"]; baseComponentOfBaseComponentExist {
// err := processBaseComponentConfig(
// baseComponentConfig,
// allTerraformComponentsMap,
// baseComponent,
// stack,
// baseComponentOfBaseComponent.(string),
// )
//
// if err != nil {
// return err
// }
//}

if baseComponentVarsSection, baseComponentVarsSectionExist := baseComponentMap["vars"]; baseComponentVarsSectionExist {
baseComponentVars = baseComponentVarsSection.(map[interface{}]interface{})
Expand Down
27 changes: 14 additions & 13 deletions pkg/stack/stack_processor_test.go
Expand Up @@ -124,19 +124,20 @@ func TestStackProcessor(t *testing.T) {
assert.Equal(t, "top-level-component1", topLevelComponent1BackendWorkspaceKeyPrefix)
assert.Equal(t, "top-level-component1", topLevelComponent1RemoteStateBackendWorkspaceKeyPrefix)

testTestComponentOverrideComponent2 := terraformComponents["test/test-component-override-2"].(map[interface{}]interface{})
testTestComponentOverrideComponentBackend2 := testTestComponentOverrideComponent2["backend"].(map[interface{}]interface{})
testTestComponentOverrideComponentBackendType2 := testTestComponentOverrideComponent2["backend_type"]
testTestComponentOverrideComponentBackendWorkspaceKeyPrefix2 := testTestComponentOverrideComponentBackend2["workspace_key_prefix"]
testTestComponentOverrideComponentBackendBucket2 := testTestComponentOverrideComponentBackend2["bucket"]
testTestComponentOverrideComponentBaseComponent2 := testTestComponentOverrideComponent2["component"]
testTestComponentOverrideInheritance2 := testTestComponentOverrideComponent2["inheritance"].([]interface{})
assert.Equal(t, "test-test-component", testTestComponentOverrideComponentBackendWorkspaceKeyPrefix2)
assert.Equal(t, "eg-ue2-root-tfstate", testTestComponentOverrideComponentBackendBucket2)
assert.Equal(t, "test/test-component", testTestComponentOverrideComponentBaseComponent2)
assert.Equal(t, "s3", testTestComponentOverrideComponentBackendType2)
assert.Equal(t, "test/test-component-override", testTestComponentOverrideInheritance2[0])
assert.Equal(t, "test/test-component", testTestComponentOverrideInheritance2[1])
// TODO: uncomment after the inheritance chain is fixed
//testTestComponentOverrideComponent2 := terraformComponents["test/test-component-override-2"].(map[interface{}]interface{})
//testTestComponentOverrideComponentBackend2 := testTestComponentOverrideComponent2["backend"].(map[interface{}]interface{})
//testTestComponentOverrideComponentBackendType2 := testTestComponentOverrideComponent2["backend_type"]
//testTestComponentOverrideComponentBackendWorkspaceKeyPrefix2 := testTestComponentOverrideComponentBackend2["workspace_key_prefix"]
//testTestComponentOverrideComponentBackendBucket2 := testTestComponentOverrideComponentBackend2["bucket"]
//testTestComponentOverrideComponentBaseComponent2 := testTestComponentOverrideComponent2["component"]
//testTestComponentOverrideInheritance2 := testTestComponentOverrideComponent2["inheritance"].([]interface{})
//assert.Equal(t, "test-test-component", testTestComponentOverrideComponentBackendWorkspaceKeyPrefix2)
//assert.Equal(t, "eg-ue2-root-tfstate", testTestComponentOverrideComponentBackendBucket2)
//assert.Equal(t, "test/test-component", testTestComponentOverrideComponentBaseComponent2)
//assert.Equal(t, "s3", testTestComponentOverrideComponentBackendType2)
//assert.Equal(t, "test/test-component-override", testTestComponentOverrideInheritance2[0])
//assert.Equal(t, "test/test-component", testTestComponentOverrideInheritance2[1])

yamlConfig, err := yaml.Marshal(mapConfig1)
assert.Nil(t, err)
Expand Down