From 5a06a42aa70f25ed41813a54f37ff06a45f2be9f Mon Sep 17 00:00:00 2001 From: "Erik Osterman (CEO @ Cloud Posse)" Date: Tue, 4 Feb 2025 06:15:02 -0600 Subject: [PATCH] Sanitize snapshots (#1002) * sanitize snapshots * [autofix.ci] apply automated fixes * check for empty repo root * normalize slashes * normalize slashes * try to fix windows snapshots with windows paths * handle multiple slashes * handle multiple slashes * changed strategy for removing double slashes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../scenarios/mock-terraform/atmos.yaml | 1 + .../components/terraform/mock/backend.tf | 2 +- .../components/terraform/mock/main.tf | 28 +++++++++++++++++++ .../components/terraform/mock/mock.json | 2 +- .../components/terraform/mock/versions.tf | 3 +- .../mock-terraform/stacks/catalog/mock.yaml | 17 ----------- .../stacks/catalog/terraform/mock.yaml | 13 +++++++++ .../stacks/{deploy/dev.yaml => dev/mock.yaml} | 15 +++++----- .../{deploy/prod.yaml => prod/mock.yaml} | 15 +++++----- 9 files changed, 60 insertions(+), 36 deletions(-) delete mode 100644 tests/fixtures/scenarios/mock-terraform/stacks/catalog/mock.yaml create mode 100644 tests/fixtures/scenarios/mock-terraform/stacks/catalog/terraform/mock.yaml rename tests/fixtures/scenarios/mock-terraform/stacks/{deploy/dev.yaml => dev/mock.yaml} (52%) rename tests/fixtures/scenarios/mock-terraform/stacks/{deploy/prod.yaml => prod/mock.yaml} (52%) diff --git a/tests/fixtures/scenarios/mock-terraform/atmos.yaml b/tests/fixtures/scenarios/mock-terraform/atmos.yaml index 96fab075f..b91af8fe4 100644 --- a/tests/fixtures/scenarios/mock-terraform/atmos.yaml +++ b/tests/fixtures/scenarios/mock-terraform/atmos.yaml @@ -18,6 +18,7 @@ stacks: - "**/*" excluded_paths: - "**/templates/**/*" + name_pattern: "{environment}-{component}" logs: file: "/dev/stderr" diff --git a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/backend.tf b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/backend.tf index ba96c695b..3c533e6bf 100644 --- a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/backend.tf +++ b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/backend.tf @@ -1,5 +1,5 @@ terraform { backend "local" { - workspace_dir = "terraform.tfstate.d" + path = "terraform.tfstate" } } diff --git a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/main.tf b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/main.tf index 35d0bc935..59159f5e2 100644 --- a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/main.tf +++ b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/main.tf @@ -1,3 +1,15 @@ +variable "stage" { + type = string +} + +variable "environment" { + type = string +} + +variable "tenant" { + type = string +} + variable "foo" { type = string default = "foo" @@ -13,11 +25,15 @@ variable "baz" { default = "baz" } +# Mock resource for testing resource "local_file" "mock" { content = jsonencode({ foo = var.foo bar = var.bar baz = var.baz + stage = var.stage + environment = var.environment + tenant = var.tenant }) filename = "${path.module}/mock.json" } @@ -33,3 +49,15 @@ output "bar" { output "baz" { value = var.baz } + +output "stage" { + value = var.stage +} + +output "environment" { + value = var.environment +} + +output "tenant" { + value = var.tenant +} diff --git a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/mock.json b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/mock.json index 2ae9db6ae..c2b421146 100755 --- a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/mock.json +++ b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/mock.json @@ -1 +1 @@ -{"bar":"dev-bar","baz":"dev-baz","foo":"dev-foo"} \ No newline at end of file +{"bar":"dev-bar","baz":"dev-baz","environment":"dev","foo":"dev-foo","stage":"dev","tenant":"test"} \ No newline at end of file diff --git a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/versions.tf b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/versions.tf index da53755d4..ee57aa1d3 100644 --- a/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/versions.tf +++ b/tests/fixtures/scenarios/mock-terraform/components/terraform/mock/versions.tf @@ -1,5 +1,6 @@ terraform { - required_version = ">= 1.0.0" + + required_providers { local = { source = "hashicorp/local" diff --git a/tests/fixtures/scenarios/mock-terraform/stacks/catalog/mock.yaml b/tests/fixtures/scenarios/mock-terraform/stacks/catalog/mock.yaml deleted file mode 100644 index 739272ba3..000000000 --- a/tests/fixtures/scenarios/mock-terraform/stacks/catalog/mock.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# yaml-language-server: $schema=https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json - -components: - terraform: - mock: - metadata: - type: terraform - component: mock - backend: - type: local - workspace_dir: terraform.tfstate.d - settings: - component: mock - vars: - foo: "test-foo" - bar: "test-bar" - baz: "test-baz" diff --git a/tests/fixtures/scenarios/mock-terraform/stacks/catalog/terraform/mock.yaml b/tests/fixtures/scenarios/mock-terraform/stacks/catalog/terraform/mock.yaml new file mode 100644 index 000000000..330768518 --- /dev/null +++ b/tests/fixtures/scenarios/mock-terraform/stacks/catalog/terraform/mock.yaml @@ -0,0 +1,13 @@ +components: + terraform: + mock: + metadata: + component: mock + backend: + type: local + settings: + component: mock + vars: + foo: "catalog-foo" + bar: "catalog-bar" + baz: "catalog-baz" \ No newline at end of file diff --git a/tests/fixtures/scenarios/mock-terraform/stacks/deploy/dev.yaml b/tests/fixtures/scenarios/mock-terraform/stacks/dev/mock.yaml similarity index 52% rename from tests/fixtures/scenarios/mock-terraform/stacks/deploy/dev.yaml rename to tests/fixtures/scenarios/mock-terraform/stacks/dev/mock.yaml index b82f7ba46..5d3d50405 100644 --- a/tests/fixtures/scenarios/mock-terraform/stacks/deploy/dev.yaml +++ b/tests/fixtures/scenarios/mock-terraform/stacks/dev/mock.yaml @@ -1,9 +1,5 @@ import: - - catalog/mock - -vars: - environment: dev - component: mock + - ../catalog/terraform/mock components: terraform: @@ -11,9 +7,12 @@ components: metadata: component: mock environment: dev - settings: - component: mock + backend: + type: local vars: + stage: dev + environment: dev + tenant: test foo: "dev-foo" bar: "dev-bar" - baz: "dev-baz" + baz: "dev-baz" \ No newline at end of file diff --git a/tests/fixtures/scenarios/mock-terraform/stacks/deploy/prod.yaml b/tests/fixtures/scenarios/mock-terraform/stacks/prod/mock.yaml similarity index 52% rename from tests/fixtures/scenarios/mock-terraform/stacks/deploy/prod.yaml rename to tests/fixtures/scenarios/mock-terraform/stacks/prod/mock.yaml index d4549de8b..239572a49 100644 --- a/tests/fixtures/scenarios/mock-terraform/stacks/deploy/prod.yaml +++ b/tests/fixtures/scenarios/mock-terraform/stacks/prod/mock.yaml @@ -1,9 +1,5 @@ import: - - catalog/mock - -vars: - environment: prod - component: mock + - ../catalog/terraform/mock components: terraform: @@ -11,9 +7,12 @@ components: metadata: component: mock environment: prod - settings: - component: mock + backend: + type: local vars: + stage: prod + environment: prod + tenant: test foo: "prod-foo" bar: "prod-bar" - baz: "prod-baz" + baz: "prod-baz" \ No newline at end of file