From 9cbe49986aad541ae2589891492fa10df66c5c0c Mon Sep 17 00:00:00 2001 From: Andriy Knysh Date: Thu, 31 Oct 2024 16:46:32 -0400 Subject: [PATCH] Update Atmos manifests validation JSON schema. Improve help for Atmos commands. Deep-merge the `settings.integrations.github` section from stack manifests with the `integrations.github` section from `atmos.yaml` (#755) * updates * updates * updates * updates * updates * updates * updates * updates --- atmos.yaml | 7 ++ .../demo-context/schemas/atmos-manifest.json | 104 +----------------- .../demo-helmfile/schemas/atmos-manifest.json | 104 +----------------- .../schemas/atmos-manifest.json | 104 +----------------- examples/quick-start-advanced/Dockerfile | 4 +- .../atmos-manifest/1.0/atmos-manifest.json | 104 +----------------- examples/tests/atmos.yaml | 7 ++ .../tests/stacks/catalog/terraform/vpc.yaml | 5 + go.mod | 2 +- go.sum | 17 ++- internal/exec/helmfile.go | 2 +- internal/exec/help.go | 23 +--- internal/exec/stack_processor_utils.go | 58 +++++++++- internal/exec/terraform.go | 2 +- internal/exec/utils.go | 10 +- pkg/config/const.go | 35 +++--- website/docs/integrations/atlantis.mdx | 2 +- website/package-lock.json | 53 +++++---- website/package.json | 10 +- .../atmos-manifest/1.0/atmos-manifest.json | 104 +----------------- 20 files changed, 182 insertions(+), 575 deletions(-) diff --git a/atmos.yaml b/atmos.yaml index 5fa3fb3c0..f9dcbd370 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -297,6 +297,13 @@ integrations: steps: - run: terraform apply $PLANFILE + # GitHub integration + github: + gitops: + opentofu-version: 1.8.4 + terraform-version: 1.9.8 + infracost-enabled: false + # Validation schemas (for validating atmos stacks and components) schemas: # https://json-schema.org diff --git a/examples/demo-context/schemas/atmos-manifest.json b/examples/demo-context/schemas/atmos-manifest.json index 012ad9559..0baea98b5 100644 --- a/examples/demo-context/schemas/atmos-manifest.json +++ b/examples/demo-context/schemas/atmos-manifest.json @@ -477,107 +477,13 @@ "description": "Backend manifest", "additionalProperties": false, "properties": { + "local": { + "type": "object", + "additionalProperties": true + }, "s3": { "type": "object", - "additionalProperties": false, - "properties": { - "encrypt": { - "type": "boolean" - }, - "bucket": { - "type": "string" - }, - "key": { - "type": "string" - }, - "dynamodb_table": { - "type": "string" - }, - "acl": { - "type": "string" - }, - "region": { - "type": "string" - }, - "assume_role": { - "type": "object", - "additionalProperties": false, - "properties": { - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "duration": { - "type": [ - "string", - "null" - ] - }, - "external_id": { - "type": [ - "string", - "null" - ] - }, - "policy": { - "type": [ - "string", - "null" - ] - }, - "policy_arns": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "session_name": { - "type": [ - "string", - "null" - ] - }, - "source_identity": { - "type": [ - "string", - "null" - ] - }, - "tags": { - "type": [ - "object", - "null" - ], - "additionalProperties": true - }, - "transitive_tag_keys": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - } - } - }, - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "profile": { - "type": [ - "string", - "null" - ] - }, - "workspace_key_prefix": { - "type": "string" - } - } + "additionalProperties": true }, "remote": { "type": "object", diff --git a/examples/demo-helmfile/schemas/atmos-manifest.json b/examples/demo-helmfile/schemas/atmos-manifest.json index 012ad9559..0baea98b5 100644 --- a/examples/demo-helmfile/schemas/atmos-manifest.json +++ b/examples/demo-helmfile/schemas/atmos-manifest.json @@ -477,107 +477,13 @@ "description": "Backend manifest", "additionalProperties": false, "properties": { + "local": { + "type": "object", + "additionalProperties": true + }, "s3": { "type": "object", - "additionalProperties": false, - "properties": { - "encrypt": { - "type": "boolean" - }, - "bucket": { - "type": "string" - }, - "key": { - "type": "string" - }, - "dynamodb_table": { - "type": "string" - }, - "acl": { - "type": "string" - }, - "region": { - "type": "string" - }, - "assume_role": { - "type": "object", - "additionalProperties": false, - "properties": { - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "duration": { - "type": [ - "string", - "null" - ] - }, - "external_id": { - "type": [ - "string", - "null" - ] - }, - "policy": { - "type": [ - "string", - "null" - ] - }, - "policy_arns": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "session_name": { - "type": [ - "string", - "null" - ] - }, - "source_identity": { - "type": [ - "string", - "null" - ] - }, - "tags": { - "type": [ - "object", - "null" - ], - "additionalProperties": true - }, - "transitive_tag_keys": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - } - } - }, - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "profile": { - "type": [ - "string", - "null" - ] - }, - "workspace_key_prefix": { - "type": "string" - } - } + "additionalProperties": true }, "remote": { "type": "object", diff --git a/examples/demo-localstack/schemas/atmos-manifest.json b/examples/demo-localstack/schemas/atmos-manifest.json index 012ad9559..0baea98b5 100644 --- a/examples/demo-localstack/schemas/atmos-manifest.json +++ b/examples/demo-localstack/schemas/atmos-manifest.json @@ -477,107 +477,13 @@ "description": "Backend manifest", "additionalProperties": false, "properties": { + "local": { + "type": "object", + "additionalProperties": true + }, "s3": { "type": "object", - "additionalProperties": false, - "properties": { - "encrypt": { - "type": "boolean" - }, - "bucket": { - "type": "string" - }, - "key": { - "type": "string" - }, - "dynamodb_table": { - "type": "string" - }, - "acl": { - "type": "string" - }, - "region": { - "type": "string" - }, - "assume_role": { - "type": "object", - "additionalProperties": false, - "properties": { - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "duration": { - "type": [ - "string", - "null" - ] - }, - "external_id": { - "type": [ - "string", - "null" - ] - }, - "policy": { - "type": [ - "string", - "null" - ] - }, - "policy_arns": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "session_name": { - "type": [ - "string", - "null" - ] - }, - "source_identity": { - "type": [ - "string", - "null" - ] - }, - "tags": { - "type": [ - "object", - "null" - ], - "additionalProperties": true - }, - "transitive_tag_keys": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - } - } - }, - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "profile": { - "type": [ - "string", - "null" - ] - }, - "workspace_key_prefix": { - "type": "string" - } - } + "additionalProperties": true }, "remote": { "type": "object", diff --git a/examples/quick-start-advanced/Dockerfile b/examples/quick-start-advanced/Dockerfile index 91ef605a5..bdfa09dc0 100644 --- a/examples/quick-start-advanced/Dockerfile +++ b/examples/quick-start-advanced/Dockerfile @@ -1,12 +1,12 @@ # Geodesic: https://github.com/cloudposse/geodesic/ -ARG GEODESIC_VERSION=3.3.0 +ARG GEODESIC_VERSION=3.4.0 ARG GEODESIC_OS=debian # Atmos # https://atmos.tools/ # https://github.com/cloudposse/atmos # https://github.com/cloudposse/atmos/releases -ARG ATMOS_VERSION=1.97.0 +ARG ATMOS_VERSION=1.99.0 # Terraform: https://github.com/hashicorp/terraform/releases ARG TF_VERSION=1.9.8 diff --git a/examples/quick-start-advanced/stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json b/examples/quick-start-advanced/stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json index 012ad9559..0baea98b5 100644 --- a/examples/quick-start-advanced/stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json +++ b/examples/quick-start-advanced/stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json @@ -477,107 +477,13 @@ "description": "Backend manifest", "additionalProperties": false, "properties": { + "local": { + "type": "object", + "additionalProperties": true + }, "s3": { "type": "object", - "additionalProperties": false, - "properties": { - "encrypt": { - "type": "boolean" - }, - "bucket": { - "type": "string" - }, - "key": { - "type": "string" - }, - "dynamodb_table": { - "type": "string" - }, - "acl": { - "type": "string" - }, - "region": { - "type": "string" - }, - "assume_role": { - "type": "object", - "additionalProperties": false, - "properties": { - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "duration": { - "type": [ - "string", - "null" - ] - }, - "external_id": { - "type": [ - "string", - "null" - ] - }, - "policy": { - "type": [ - "string", - "null" - ] - }, - "policy_arns": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "session_name": { - "type": [ - "string", - "null" - ] - }, - "source_identity": { - "type": [ - "string", - "null" - ] - }, - "tags": { - "type": [ - "object", - "null" - ], - "additionalProperties": true - }, - "transitive_tag_keys": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - } - } - }, - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "profile": { - "type": [ - "string", - "null" - ] - }, - "workspace_key_prefix": { - "type": "string" - } - } + "additionalProperties": true }, "remote": { "type": "object", diff --git a/examples/tests/atmos.yaml b/examples/tests/atmos.yaml index fada5eef8..fbbc8bc91 100644 --- a/examples/tests/atmos.yaml +++ b/examples/tests/atmos.yaml @@ -339,6 +339,13 @@ integrations: - on: [publish] workflow: atmos-apply.yaml + # GitHub integration + github: + gitops: + opentofu-version: 1.8.4 + terraform-version: 1.9.8 + infracost-enabled: false + # Validation schemas (for validating atmos stacks and components) schemas: # https://json-schema.org diff --git a/examples/tests/stacks/catalog/terraform/vpc.yaml b/examples/tests/stacks/catalog/terraform/vpc.yaml index dcc71d050..42a42a03a 100644 --- a/examples/tests/stacks/catalog/terraform/vpc.yaml +++ b/examples/tests/stacks/catalog/terraform/vpc.yaml @@ -33,6 +33,11 @@ components: disabled: false # Validation timeout in seconds timeout: 10 + integrations: + github: + gitops: + infracost-enabled: true + test_enabled: true vars: enabled: true name: "common" diff --git a/go.mod b/go.mod index 6e2aad3d2..c4262a9f3 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/arsham/figurine v1.3.0 github.com/bmatcuk/doublestar/v4 v4.7.1 github.com/charmbracelet/bubbles v0.20.0 - github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/bubbletea v1.1.2 + github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/lipgloss v0.13.1 github.com/elewis787/boa v0.1.2 github.com/fatih/color v1.18.0 diff --git a/go.sum b/go.sum index 86f3deea3..f541d2b47 100644 --- a/go.sum +++ b/go.sum @@ -263,10 +263,14 @@ github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXva github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY= github.com/agnivade/levenshtein v1.2.0/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= +github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= +github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E= github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -359,6 +363,8 @@ github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8= +github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -389,14 +395,16 @@ github.com/chainguard-dev/git-urls v1.0.2 h1:pSpT7ifrpc5X55n4aTTm7FFUE+ZQHKiqpiw github.com/chainguard-dev/git-urls v1.0.2/go.mod h1:rbGgj10OS7UgZlbzdUQIQpT0k/D4+An04HJY7Ol+Y/o= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= -github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= -github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/bubbletea v1.1.2 h1:naQXF2laRxyLyil/i7fxdpiz1/k06IKquhm4vBfHsIc= github.com/charmbracelet/bubbletea v1.1.2/go.mod h1:9HIU/hBV24qKjlehyj8z1r/tR9TYTQEag+cWZnuXo8E= +github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= +github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU= github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= +github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= @@ -460,7 +468,6 @@ github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7c github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= -github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -819,6 +826,8 @@ github.com/hashicorp/vault/sdk v0.5.0/go.mod h1:UJZHlfwj7qUJG8g22CuxUgkdJouFrBNv github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J+x6AzmKuVM/JWCQwkWm6GW/MUR6I= github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -1008,8 +1017,6 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= -github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= -github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a/go.mod h1:hxSnBBYLK21Vtq/PHd0S2FYCxBXzBua8ov5s1RobyRQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= diff --git a/internal/exec/helmfile.go b/internal/exec/helmfile.go index 757349ced..4b2c8d303 100644 --- a/internal/exec/helmfile.go +++ b/internal/exec/helmfile.go @@ -45,7 +45,7 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error { return err } - err = processHelp("helmfile", "") + err = processHelp(cliConfig, "helmfile", "") if err != nil { return err } diff --git a/internal/exec/help.go b/internal/exec/help.go index 91b2b4e74..6ea39c856 100644 --- a/internal/exec/help.go +++ b/internal/exec/help.go @@ -9,9 +9,11 @@ import ( ) // processHelp processes help commands -func processHelp(componentType string, command string) error { - cliConfig := schema.CliConfiguration{} - +func processHelp( + cliConfig schema.CliConfiguration, + componentType string, + command string, +) error { if len(command) == 0 { u.PrintMessage(fmt.Sprintf("'atmos' supports all native '%s' commands.\n", componentType)) u.PrintMessage("In addition, the 'component' argument and 'stack' flag are required to generate the variables and backend config for the component in the stack.\n") @@ -46,11 +48,9 @@ func processHelp(componentType string, command string) error { u.PrintMessage(" - double-dash '--' can be used to signify the end of the options for Atmos and the start of the additional " + "native arguments and flags for the 'terraform' commands. " + "For example: atmos terraform plan -s -- -refresh=false -lock=false") - u.PrintMessage(fmt.Sprintf(" - '--append-user-agent' flag sets the TF_APPEND_USER_AGENT environment variable to customize the User-Agent string in Terraform provider requests. "+ "Example: 'Atmos/%s (Cloud Posse; +https://atmos.tools)'. "+ "If not specified, defaults to 'atmos %s'\n", version.Version, version.Version)) - } if componentType == "helmfile" { @@ -64,13 +64,6 @@ func processHelp(componentType string, command string) error { u.PrintMessage(" - double-dash '--' can be used to signify the end of the options for Atmos and the start of the additional " + "native arguments and flags for the 'helmfile' commands") } - - fmt.Println() - err := ExecuteShellCommand(cliConfig, componentType, []string{"--help"}, "", nil, false, "") - if err != nil { - return err - } - } else if componentType == "terraform" && command == "clean" { u.PrintMessage("\n'atmos terraform clean' command deletes the following folders and files from the component's directory:\n\n" + " - '.terraform' folder\n" + @@ -115,12 +108,6 @@ func processHelp(componentType string, command string) error { u.PrintMessage("In addition, 'component' and 'stack' are required in order to generate variables for the component in the stack.\n") u.PrintMessage(fmt.Sprintf("atmos %s %s -s [options]", componentType, command)) u.PrintMessage(fmt.Sprintf("atmos %s %s --stack [options]", componentType, command)) - - fmt.Println() - err := ExecuteShellCommand(cliConfig, componentType, []string{command, "--help"}, "", nil, false, "") - if err != nil { - return err - } } return nil diff --git a/internal/exec/stack_processor_utils.go b/internal/exec/stack_processor_utils.go index 9b3f70a18..b6c6f4d0e 100644 --- a/internal/exec/stack_processor_utils.go +++ b/internal/exec/stack_processor_utils.go @@ -1184,16 +1184,21 @@ func ProcessStackConfig( } } + finalSettings, err := processSettingsIntegrationsGithub(cliConfig, finalComponentSettings) + if err != nil { + return nil, err + } + comp := map[string]any{} comp[cfg.VarsSectionName] = finalComponentVars - comp[cfg.SettingsSectionName] = finalComponentSettings + comp[cfg.SettingsSectionName] = finalSettings comp[cfg.EnvSectionName] = finalComponentEnv comp[cfg.BackendTypeSectionName] = finalComponentBackendType comp[cfg.BackendSectionName] = finalComponentBackend - comp["remote_state_backend_type"] = finalComponentRemoteStateBackendType - comp["remote_state_backend"] = finalComponentRemoteStateBackend + comp[cfg.RemoteStateBackendTypeSectionName] = finalComponentRemoteStateBackendType + comp[cfg.RemoteStateBackendSectionName] = finalComponentRemoteStateBackend comp[cfg.CommandSectionName] = finalComponentTerraformCommand - comp["inheritance"] = componentInheritanceChain + comp[cfg.InheritanceSectionName] = componentInheritanceChain comp[cfg.MetadataSectionName] = componentMetadata comp[cfg.OverridesSectionName] = componentOverrides comp[cfg.ProvidersSectionName] = finalComponentProviders @@ -1472,9 +1477,14 @@ func ProcessStackConfig( finalComponentHelmfileCommand = componentOverridesHelmfileCommand } + finalSettings, err := processSettingsIntegrationsGithub(cliConfig, finalComponentSettings) + if err != nil { + return nil, err + } + comp := map[string]any{} comp[cfg.VarsSectionName] = finalComponentVars - comp[cfg.SettingsSectionName] = finalComponentSettings + comp[cfg.SettingsSectionName] = finalSettings comp[cfg.EnvSectionName] = finalComponentEnv comp[cfg.CommandSectionName] = finalComponentHelmfileCommand comp["inheritance"] = componentInheritanceChain @@ -1500,6 +1510,44 @@ func ProcessStackConfig( return result, nil } +// processSettingsIntegrationsGithub deep-merges the `settings.integrations.github` section from stack manifests with +// the `integrations.github` section from `atmos.yaml` +func processSettingsIntegrationsGithub(cliConfig schema.CliConfiguration, settings map[string]any) (map[string]any, error) { + settingsIntegrationsSection := make(map[string]any) + settingsIntegrationsGithubSection := make(map[string]any) + + // Find `settings.integrations.github` section from stack manifests + if settingsIntegrations, ok := settings[cfg.IntegrationsSectionName]; ok { + if settingsIntegrationsMap, ok := settingsIntegrations.(map[string]any); ok { + settingsIntegrationsSection = settingsIntegrationsMap + if settingsIntegrationsGithub, ok := settingsIntegrationsMap[cfg.GithubSectionName]; ok { + if settingsIntegrationsGithubMap, ok := settingsIntegrationsGithub.(map[string]any); ok { + settingsIntegrationsGithubSection = settingsIntegrationsGithubMap + } + } + } + } + + // deep-merge the `settings.integrations.github` section from stack manifests with the `integrations.github` section from `atmos.yaml` + settingsIntegrationsGithubMerged, err := m.Merge( + cliConfig, + []map[string]any{ + cliConfig.Integrations.GitHub, + settingsIntegrationsGithubSection, + }) + if err != nil { + return nil, err + } + + // Update the `settings.integrations.github` section + if len(settingsIntegrationsGithubMerged) > 0 { + settingsIntegrationsSection[cfg.GithubSectionName] = settingsIntegrationsGithubMerged + settings[cfg.IntegrationsSectionName] = settingsIntegrationsSection + } + + return settings, nil +} + // FindComponentStacks finds all infrastructure stack manifests where the component or the base component is defined func FindComponentStacks( componentType string, diff --git a/internal/exec/terraform.go b/internal/exec/terraform.go index 93b272e1a..b782d325e 100644 --- a/internal/exec/terraform.go +++ b/internal/exec/terraform.go @@ -52,7 +52,7 @@ func ExecuteTerraform(info schema.ConfigAndStacksInfo) error { return err } - err = processHelp("terraform", "") + err = processHelp(cliConfig, "terraform", "") if err != nil { return err } diff --git a/internal/exec/utils.go b/internal/exec/utils.go index bf82b2ea4..93697c0b6 100644 --- a/internal/exec/utils.go +++ b/internal/exec/utils.go @@ -219,7 +219,7 @@ func processCommandLineArgs( // Check if `-h` or `--help` flags are specified if argsAndFlagsInfo.NeedHelp { - err = processHelp(componentType, argsAndFlagsInfo.SubCommand) + err = processHelp(schema.CliConfiguration{}, componentType, argsAndFlagsInfo.SubCommand) if err != nil { return configAndStacksInfo, err } @@ -630,12 +630,18 @@ func processArgsAndFlags(componentType string, inputArgsAndFlags []string) (sche var info schema.ArgsAndFlagsInfo var additionalArgsAndFlags []string var globalOptions []string - var indexesToRemove []int // https://github.com/roboll/helmfile#cli-reference var globalOptionsFlagIndex int + // For commands like `atmos terraform clean` and `atmos terraform plan`, show the command help + if len(inputArgsAndFlags) == 1 { + info.SubCommand = inputArgsAndFlags[0] + info.NeedHelp = true + return info, nil + } + for i, arg := range inputArgsAndFlags { if arg == cfg.GlobalOptionsFlag { globalOptionsFlagIndex = i + 1 diff --git a/pkg/config/const.go b/pkg/config/const.go index 924d97249..8852349de 100644 --- a/pkg/config/const.go +++ b/pkg/config/const.go @@ -42,21 +42,26 @@ const ( ComponentVendorConfigFileName = "component.yaml" AtmosVendorConfigFileName = "vendor" - ImportSectionName = "import" - OverridesSectionName = "overrides" - ProvidersSectionName = "providers" - VarsSectionName = "vars" - SettingsSectionName = "settings" - EnvSectionName = "env" - BackendSectionName = "backend" - BackendTypeSectionName = "backend_type" - MetadataSectionName = "metadata" - ComponentSectionName = "component" - ComponentsSectionName = "components" - CommandSectionName = "command" - TerraformSectionName = "terraform" - HelmfileSectionName = "helmfile" - WorkspaceSectionName = "workspace" + ImportSectionName = "import" + OverridesSectionName = "overrides" + ProvidersSectionName = "providers" + VarsSectionName = "vars" + SettingsSectionName = "settings" + EnvSectionName = "env" + BackendSectionName = "backend" + BackendTypeSectionName = "backend_type" + RemoteStateBackendSectionName = "remote_state_backend" + RemoteStateBackendTypeSectionName = "remote_state_backend_type" + MetadataSectionName = "metadata" + ComponentSectionName = "component" + ComponentsSectionName = "components" + CommandSectionName = "command" + TerraformSectionName = "terraform" + HelmfileSectionName = "helmfile" + WorkspaceSectionName = "workspace" + InheritanceSectionName = "inheritance" + IntegrationsSectionName = "integrations" + GithubSectionName = "github" LogsLevelFlag = "--logs-level" LogsFileFlag = "--logs-file" diff --git a/website/docs/integrations/atlantis.mdx b/website/docs/integrations/atlantis.mdx index 1c55430b2..7efdcbfad 100644 --- a/website/docs/integrations/atlantis.mdx +++ b/website/docs/integrations/atlantis.mdx @@ -673,7 +673,7 @@ on: branches: [ main ] env: - ATMOS_VERSION: 1.97.0 + ATMOS_VERSION: 1.99.0 ATMOS_CLI_CONFIG_PATH: ./ jobs: diff --git a/website/package-lock.json b/website/package-lock.json index c15719c34..8ffdc2112 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -21,24 +21,24 @@ "@fortawesome/free-solid-svg-icons": "^6.6.0", "@fortawesome/react-fontawesome": "^0.2.2", "@grnet/docusaurus-terminology": "^2.0.0-rc.1", - "@mdx-js/react": "^3.0.1", + "@mdx-js/react": "^3.1.0", "clsx": "^2.1.1", "custom-loaders": "file:plugins/custom-loaders", "docusaurus-plugin-image-zoom": "^2.0.0", "docusaurus-plugin-sentry": "^2.0.0", "html-loader": "^5.1.0", - "marked": "^14.0.0", + "marked": "^14.1.3", "node-fetch": "^3.3.2", "posthog-docusaurus": "^2.0.1", - "posthog-js": "^1.157.2", - "prism-react-renderer": "^2.3.1", + "posthog-js": "^1.178.0", + "prism-react-renderer": "^2.4.0", "raw-loader": "^4.0.2", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hubspot-form": "^1.3.7", "react-image-gallery": "^1.3.0", "react-player": "^2.16.0", - "react-social-media-embed": "^2.5.13", + "react-social-media-embed": "^2.5.17", "react-table": "^7.8.0", "remark-html": "^16.0.1", "remark-parse": "^11.0.0", @@ -3443,9 +3443,10 @@ } }, "node_modules/@mdx-js/react": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.0.1.tgz", - "integrity": "sha512-9ZrPIU4MGf6et1m1ov3zKf+q9+deetI51zprKB1D/z3NOb+rUxxtEl3mCjW5wTGh6VhRdwPueh1oRzi6ezkA8A==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.1.0.tgz", + "integrity": "sha512-QjHtSaoameoalGnKDT3FoIl4+9RwyTmo9ZJGBdLOks/YOiWHoRDI3PUwEzOE7kEmGcV3AFcp9K6dYu9rEuKLAQ==", + "license": "MIT", "dependencies": { "@types/mdx": "^2.0.0" }, @@ -5712,10 +5713,11 @@ } }, "node_modules/core-js": { - "version": "3.37.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.1.tgz", - "integrity": "sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==", + "version": "3.38.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", "hasInstallScript": true, + "license": "MIT", "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" @@ -9577,9 +9579,9 @@ } }, "node_modules/marked": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz", - "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==", + "version": "14.1.3", + "resolved": "https://registry.npmjs.org/marked/-/marked-14.1.3.tgz", + "integrity": "sha512-ZibJqTULGlt9g5k4VMARAktMAjXoVnnr+Y3aCqW1oDftcV4BA3UmrBifzXoZyenHRk75csiPu9iwsTj4VNBT0g==", "license": "MIT", "bin": { "marked": "bin/marked.js" @@ -13650,14 +13652,15 @@ } }, "node_modules/posthog-js": { - "version": "1.157.2", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.157.2.tgz", - "integrity": "sha512-ATYKGs+Q51u26nHHhrhWNh1whqFm7j/rwQQYw+y6/YzNmRlo+YsqrGZji9nqXb9/4fo0ModDr+ZmuOI3hKkUXA==", + "version": "1.178.0", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.178.0.tgz", + "integrity": "sha512-ILD4flNh72d5dycc4ZouKORlaVr+pDzl5TlZr1JgP0NBAoduHjhE7XZYwk7zdYkry7u0qAIpfv2306zJCW2vGg==", "license": "MIT", "dependencies": { + "core-js": "^3.38.1", "fflate": "^0.4.8", "preact": "^10.19.3", - "web-vitals": "^4.0.1" + "web-vitals": "^4.2.0" } }, "node_modules/preact": { @@ -13703,9 +13706,10 @@ } }, "node_modules/prism-react-renderer": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/prism-react-renderer/-/prism-react-renderer-2.3.1.tgz", - "integrity": "sha512-Rdf+HzBLR7KYjzpJ1rSoxT9ioO85nZngQEoFIhL07XhtJHlCU3SOz0GJ6+qvMyQe0Se+BV3qpe6Yd/NmQF5Juw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/prism-react-renderer/-/prism-react-renderer-2.4.0.tgz", + "integrity": "sha512-327BsVCD/unU4CNLZTWVHyUHKnsqcvj2qbPlQ8MiBE2eq2rgctjigPA1Gp9HLF83kZ20zNN6jgizHJeEsyFYOw==", + "license": "MIT", "dependencies": { "@types/prismjs": "^1.26.0", "clsx": "^2.0.0" @@ -14427,9 +14431,10 @@ } }, "node_modules/react-social-media-embed": { - "version": "2.5.13", - "resolved": "https://registry.npmjs.org/react-social-media-embed/-/react-social-media-embed-2.5.13.tgz", - "integrity": "sha512-9udbyUZpG8lXhDzDHH6ceDZfhW7QGg2WoVjJD6F8PTOXJoULZTkvLV7vYpqeWthqP33iwagLEHo7goJVDuL7ug==", + "version": "2.5.17", + "resolved": "https://registry.npmjs.org/react-social-media-embed/-/react-social-media-embed-2.5.17.tgz", + "integrity": "sha512-MBSVbpMv3Uyy3KOJ+K7j1rwGunK6t+U2Wqhq7ee1u/LTS2bOYlCuvrxUDhCIRYoRzxs4p8zckZozS0RLqpaJDA==", + "license": "MIT", "dependencies": { "@types/youtube-player": "^5.5.5", "classnames": "^2.5.1", diff --git a/website/package.json b/website/package.json index 5e58a779e..bdec0e610 100644 --- a/website/package.json +++ b/website/package.json @@ -27,24 +27,24 @@ "@fortawesome/free-solid-svg-icons": "^6.6.0", "@fortawesome/react-fontawesome": "^0.2.2", "@grnet/docusaurus-terminology": "^2.0.0-rc.1", - "@mdx-js/react": "^3.0.1", + "@mdx-js/react": "^3.1.0", "clsx": "^2.1.1", "custom-loaders": "file:plugins/custom-loaders", "docusaurus-plugin-image-zoom": "^2.0.0", "docusaurus-plugin-sentry": "^2.0.0", "html-loader": "^5.1.0", - "marked": "^14.0.0", + "marked": "^14.1.3", "node-fetch": "^3.3.2", "posthog-docusaurus": "^2.0.1", - "posthog-js": "^1.157.2", - "prism-react-renderer": "^2.3.1", + "posthog-js": "^1.178.0", + "prism-react-renderer": "^2.4.0", "raw-loader": "^4.0.2", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hubspot-form": "^1.3.7", "react-image-gallery": "^1.3.0", "react-player": "^2.16.0", - "react-social-media-embed": "^2.5.13", + "react-social-media-embed": "^2.5.17", "react-table": "^7.8.0", "remark-html": "^16.0.1", "remark-parse": "^11.0.0", diff --git a/website/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json b/website/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json index 012ad9559..0baea98b5 100644 --- a/website/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json +++ b/website/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json @@ -477,107 +477,13 @@ "description": "Backend manifest", "additionalProperties": false, "properties": { + "local": { + "type": "object", + "additionalProperties": true + }, "s3": { "type": "object", - "additionalProperties": false, - "properties": { - "encrypt": { - "type": "boolean" - }, - "bucket": { - "type": "string" - }, - "key": { - "type": "string" - }, - "dynamodb_table": { - "type": "string" - }, - "acl": { - "type": "string" - }, - "region": { - "type": "string" - }, - "assume_role": { - "type": "object", - "additionalProperties": false, - "properties": { - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "duration": { - "type": [ - "string", - "null" - ] - }, - "external_id": { - "type": [ - "string", - "null" - ] - }, - "policy": { - "type": [ - "string", - "null" - ] - }, - "policy_arns": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "session_name": { - "type": [ - "string", - "null" - ] - }, - "source_identity": { - "type": [ - "string", - "null" - ] - }, - "tags": { - "type": [ - "object", - "null" - ], - "additionalProperties": true - }, - "transitive_tag_keys": { - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - } - } - }, - "role_arn": { - "type": [ - "string", - "null" - ] - }, - "profile": { - "type": [ - "string", - "null" - ] - }, - "workspace_key_prefix": { - "type": "string" - } - } + "additionalProperties": true }, "remote": { "type": "object",