From cb1b68e3c9e902e427c00d767d647d99ab73cd49 Mon Sep 17 00:00:00 2001 From: aknysh Date: Thu, 5 Dec 2024 17:39:13 -0500 Subject: [PATCH 1/4] updates --- atmos.yaml | 2 +- .../template-functions-test2/defaults.yaml | 1 + examples/tests/stacks/orgs/cp/_defaults.yaml | 56 +++++++++---------- .../orgs/cp/tenant1/prod/us-east-2.yaml | 4 +- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/atmos.yaml b/atmos.yaml index 7b887ca23..d5ccc2aef 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -15,7 +15,7 @@ # are independent settings (supporting both absolute and relative paths). # If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path' # are considered paths relative to 'base_path'. -base_path: "." +base_path: "./examples/tests" vendor: # Path to vendor configuration file or directory containing vendor files diff --git a/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml b/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml index e7e37468a..71c90f590 100644 --- a/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml +++ b/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml @@ -6,6 +6,7 @@ components: metadata: # Point to the Terraform component component: "test/template-functions-test2" + terraform_workspace: '{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}' settings: spacelift: workspace_enabled: false diff --git a/examples/tests/stacks/orgs/cp/_defaults.yaml b/examples/tests/stacks/orgs/cp/_defaults.yaml index e432023a0..ad996d4d5 100644 --- a/examples/tests/stacks/orgs/cp/_defaults.yaml +++ b/examples/tests/stacks/orgs/cp/_defaults.yaml @@ -56,34 +56,34 @@ terraform: s3: role_arn: "arn:aws:iam::123456789012:role/cp-gbl-root-terraform" - providers: - context: - enabled: true - delimiter: "-" - properties: - namespace: - required: true - min_length: 2 - max_length: 4 - tenant: - required: true - min_length: 2 - max_length: 10 - environment: - required: true - min_length: 2 - max_length: 6 - stage: - required: true - min_length: 2 - max_length: 20 - values: - namespace: "{{ .vars.namespace }}" - tenant: "{{ .vars.tenant }}" - environment: "{{ .vars.environment }}" - stage: "{{ .vars.stage }}" - atmos_component: "{{ .atmos_component }}" - atmos_stack: "{{ .atmos_stack }}" +# providers: +# context: +# enabled: true +# delimiter: "-" +# properties: +# namespace: +# required: true +# min_length: 2 +# max_length: 4 +# tenant: +# required: true +# min_length: 2 +# max_length: 10 +# environment: +# required: true +# min_length: 2 +# max_length: 6 +# stage: +# required: true +# min_length: 2 +# max_length: 20 +# values: +# namespace: "{{ .vars.namespace }}" +# tenant: "{{ .vars.tenant }}" +# environment: "{{ .vars.environment }}" +# stage: "{{ .vars.stage }}" +# atmos_component: "{{ .atmos_component }}" +# atmos_stack: "{{ .atmos_stack }}" helmfile: vars: {} diff --git a/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml b/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml index bc33175c1..2d41dd54c 100644 --- a/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml +++ b/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml @@ -15,8 +15,8 @@ import: - catalog/terraform/spacelift/infrastructure-tenant1 # Configurations to test `atmos.Component` template function - # - catalog/terraform/template-functions-test/defaults - # - catalog/terraform/template-functions-test2/defaults + - catalog/terraform/template-functions-test/defaults + - catalog/terraform/template-functions-test2/defaults components: terraform: From 09da6dcd338e57714c0855120018650adf8bb3e2 Mon Sep 17 00:00:00 2001 From: aknysh Date: Thu, 5 Dec 2024 20:02:55 -0500 Subject: [PATCH 2/4] updates --- .../catalog/terraform/template-functions-test2/defaults.yaml | 2 +- internal/exec/terraform.go | 2 ++ internal/exec/utils.go | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml b/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml index 71c90f590..0042836e7 100644 --- a/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml +++ b/examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml @@ -6,7 +6,7 @@ components: metadata: # Point to the Terraform component component: "test/template-functions-test2" - terraform_workspace: '{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}' + terraform_workspace: '{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}-test' settings: spacelift: workspace_enabled: false diff --git a/internal/exec/terraform.go b/internal/exec/terraform.go index 0c0021ff8..4747cda29 100644 --- a/internal/exec/terraform.go +++ b/internal/exec/terraform.go @@ -121,8 +121,10 @@ func ExecuteTerraform(info schema.ConfigAndStacksInfo) error { } return nil } + varFile := constructTerraformComponentVarfileName(info) planFile := constructTerraformComponentPlanfileName(info) + // Print component variables and write to file // Don't process variables when executing `terraform workspace` commands if info.SubCommand != "workspace" { diff --git a/internal/exec/utils.go b/internal/exec/utils.go index 6dea676bb..0d0b327bc 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -563,6 +563,10 @@ func ProcessStacks( if i, ok := configAndStacksInfo.ComponentSection[cfg.CommandSectionName].(string); ok { configAndStacksInfo.Command = i } + + if i, ok := configAndStacksInfo.ComponentSection[cfg.WorkspaceSectionName].(string); ok { + configAndStacksInfo.TerraformWorkspace = i + } } // Spacelift stack From ab32dda7e9498ed06cba6e954ff445c9e2b29b12 Mon Sep 17 00:00:00 2001 From: aknysh Date: Thu, 5 Dec 2024 20:09:26 -0500 Subject: [PATCH 3/4] updates --- atmos.yaml | 2 +- examples/quick-start-advanced/Dockerfile | 2 +- examples/tests/stacks/orgs/cp/_defaults.yaml | 56 +++++++++---------- .../orgs/cp/tenant1/prod/us-east-2.yaml | 4 +- go.mod | 4 +- go.sum | 12 ++-- website/docs/integrations/atlantis.mdx | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/atmos.yaml b/atmos.yaml index d5ccc2aef..7b887ca23 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -15,7 +15,7 @@ # are independent settings (supporting both absolute and relative paths). # If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path' # are considered paths relative to 'base_path'. -base_path: "./examples/tests" +base_path: "." vendor: # Path to vendor configuration file or directory containing vendor files diff --git a/examples/quick-start-advanced/Dockerfile b/examples/quick-start-advanced/Dockerfile index 264c37cb0..022bf1359 100644 --- a/examples/quick-start-advanced/Dockerfile +++ b/examples/quick-start-advanced/Dockerfile @@ -6,7 +6,7 @@ ARG GEODESIC_OS=debian # https://atmos.tools/ # https://github.com/cloudposse/atmos # https://github.com/cloudposse/atmos/releases -ARG ATMOS_VERSION=1.111.0 +ARG ATMOS_VERSION=1.118.0 # Terraform: https://github.com/hashicorp/terraform/releases ARG TF_VERSION=1.5.7 diff --git a/examples/tests/stacks/orgs/cp/_defaults.yaml b/examples/tests/stacks/orgs/cp/_defaults.yaml index ad996d4d5..e432023a0 100644 --- a/examples/tests/stacks/orgs/cp/_defaults.yaml +++ b/examples/tests/stacks/orgs/cp/_defaults.yaml @@ -56,34 +56,34 @@ terraform: s3: role_arn: "arn:aws:iam::123456789012:role/cp-gbl-root-terraform" -# providers: -# context: -# enabled: true -# delimiter: "-" -# properties: -# namespace: -# required: true -# min_length: 2 -# max_length: 4 -# tenant: -# required: true -# min_length: 2 -# max_length: 10 -# environment: -# required: true -# min_length: 2 -# max_length: 6 -# stage: -# required: true -# min_length: 2 -# max_length: 20 -# values: -# namespace: "{{ .vars.namespace }}" -# tenant: "{{ .vars.tenant }}" -# environment: "{{ .vars.environment }}" -# stage: "{{ .vars.stage }}" -# atmos_component: "{{ .atmos_component }}" -# atmos_stack: "{{ .atmos_stack }}" + providers: + context: + enabled: true + delimiter: "-" + properties: + namespace: + required: true + min_length: 2 + max_length: 4 + tenant: + required: true + min_length: 2 + max_length: 10 + environment: + required: true + min_length: 2 + max_length: 6 + stage: + required: true + min_length: 2 + max_length: 20 + values: + namespace: "{{ .vars.namespace }}" + tenant: "{{ .vars.tenant }}" + environment: "{{ .vars.environment }}" + stage: "{{ .vars.stage }}" + atmos_component: "{{ .atmos_component }}" + atmos_stack: "{{ .atmos_stack }}" helmfile: vars: {} diff --git a/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml b/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml index 2d41dd54c..bc33175c1 100644 --- a/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml +++ b/examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml @@ -15,8 +15,8 @@ import: - catalog/terraform/spacelift/infrastructure-tenant1 # Configurations to test `atmos.Component` template function - - catalog/terraform/template-functions-test/defaults - - catalog/terraform/template-functions-test2/defaults + # - catalog/terraform/template-functions-test/defaults + # - catalog/terraform/template-functions-test2/defaults components: terraform: diff --git a/go.mod b/go.mod index 927f0c009..ef51bcbdf 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 github.com/zclconf/go-cty v1.15.1 - golang.org/x/term v0.26.0 + golang.org/x/term v0.27.0 gopkg.in/yaml.v3 v3.0.1 mvdan.cc/sh/v3 v3.10.0 ) @@ -247,7 +247,7 @@ require ( golang.org/x/net v0.30.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sync v0.9.0 // indirect - golang.org/x/sys v0.27.0 // indirect + golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.22.0 // indirect diff --git a/go.sum b/go.sum index cafcf5969..f557e9bc6 100644 --- a/go.sum +++ b/go.sum @@ -995,10 +995,10 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= -github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -1543,15 +1543,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= -golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/website/docs/integrations/atlantis.mdx b/website/docs/integrations/atlantis.mdx index 3d3fab182..924bacad0 100644 --- a/website/docs/integrations/atlantis.mdx +++ b/website/docs/integrations/atlantis.mdx @@ -673,7 +673,7 @@ on: branches: [ main ] env: - ATMOS_VERSION: 1.111.0 + ATMOS_VERSION: 1.118.0 ATMOS_CLI_CONFIG_PATH: ./ jobs: From f5e894e390c99fda0a712ceb66ebed601aa2966a Mon Sep 17 00:00:00 2001 From: aknysh Date: Thu, 5 Dec 2024 20:12:23 -0500 Subject: [PATCH 4/4] updates --- website/docs/core-concepts/stacks/templates/templates.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/core-concepts/stacks/templates/templates.mdx b/website/docs/core-concepts/stacks/templates/templates.mdx index b77419e6d..ad6781b8b 100644 --- a/website/docs/core-concepts/stacks/templates/templates.mdx +++ b/website/docs/core-concepts/stacks/templates/templates.mdx @@ -244,8 +244,8 @@ You can use `Go` templates in the following Atmos sections to refer to values in - `overrides` - `backend` - `backend_type` + - `metadata` - `component` - - `metadata.component` - `command` :::tip