diff --git a/cmd/describe_affected.go b/cmd/describe_affected.go index ad12db842..b4664094d 100644 --- a/cmd/describe_affected.go +++ b/cmd/describe_affected.go @@ -37,6 +37,7 @@ func init() { describeAffectedCmd.PersistentFlags().String("ssh-key-password", "", "Encryption password for the PEM-encoded private key if the key contains a password-encrypted PEM block: atmos describe affected --ssh-key --ssh-key-password ") describeAffectedCmd.PersistentFlags().Bool("include-spacelift-admin-stacks", false, "Include the Spacelift admin stack of any stack that is affected by config changes: atmos describe affected --include-spacelift-admin-stacks=true") describeAffectedCmd.PersistentFlags().Bool("include-dependents", false, "Include the dependent components and stacks: atmos describe affected --include-dependents=true") + describeAffectedCmd.PersistentFlags().Bool("include-settings", false, "Include the 'settings' section for each affected component: atmos describe affected --include-settings=true") describeAffectedCmd.PersistentFlags().Bool("clone-target-ref", false, "Clone the target reference with which to compare the current branch: atmos describe affected --clone-target-ref=true\n"+ "If set to 'false' (default), the target reference will be checked out instead\n"+ "This requires that the target reference is already cloned by Git, and the information about it exists in the '.git' directory") diff --git a/examples/quick-start/Dockerfile b/examples/quick-start/Dockerfile index 4f10dd4e7..15c9da304 100644 --- a/examples/quick-start/Dockerfile +++ b/examples/quick-start/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.79.0 +ARG ATMOS_VERSION=1.80.0 # Terraform: https://github.com/hashicorp/terraform/releases ARG TF_VERSION=1.8.5 diff --git a/go.mod b/go.mod index 9153ff7d3..ae7ffc487 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/ivanpirog/coloredcobra v1.0.1 github.com/json-iterator/go v1.1.12 github.com/jwalton/go-supportscolor v1.2.0 - github.com/lrstanley/bubblezone v0.0.0-20240602193536-d14e6b69d7f9 + github.com/lrstanley/bubblezone v0.0.0-20240609171605-b723e5c0b1af github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.5.0 github.com/open-policy-agent/opa v0.65.0 @@ -90,9 +90,9 @@ require ( github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/charmbracelet/x/ansi v0.1.2 // indirect - github.com/charmbracelet/x/input v0.1.0 // indirect + github.com/charmbracelet/x/input v0.1.2 // indirect github.com/charmbracelet/x/term v0.1.1 // indirect - github.com/charmbracelet/x/windows v0.1.0 // indirect + github.com/charmbracelet/x/windows v0.1.2 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect github.com/containerd/containerd v1.7.17 // indirect @@ -229,15 +229,15 @@ require ( gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect golang.org/x/crypto v0.23.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/mod v0.14.0 // indirect + golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.20.0 // indirect + golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/api v0.171.0 // indirect google.golang.org/appengine v1.6.8 // indirect diff --git a/go.sum b/go.sum index 11f25374d..0bd2ca92c 100644 --- a/go.sum +++ b/go.sum @@ -392,12 +392,12 @@ github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/Zq github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8= github.com/charmbracelet/x/ansi v0.1.2 h1:6+LR39uG8DE6zAmbu023YlqjJHkYXDF1z36ZwzO4xZY= github.com/charmbracelet/x/ansi v0.1.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/input v0.1.0 h1:TEsGSfZYQyOtp+STIjyBq6tpRaorH0qpwZUj8DavAhQ= -github.com/charmbracelet/x/input v0.1.0/go.mod h1:ZZwaBxPF7IG8gWWzPUVqHEtWhc1+HXJPNuerJGRGZ28= +github.com/charmbracelet/x/input v0.1.2 h1:QJAZr33eOhDowkkEQ24rsJy4Llxlm+fRDf/cQrmqJa0= +github.com/charmbracelet/x/input v0.1.2/go.mod h1:LGBim0maUY4Pitjn/4fHnuXb4KirU3DODsyuHuXdOyA= github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= -github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wph7Ika2k4= -github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= +github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg= +github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -912,8 +912,8 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lrstanley/bubblezone v0.0.0-20240602193536-d14e6b69d7f9 h1:LHU+iKAPCi7vJh19V0LPQ3ZfwHP/+wWW+dmpqXYCGJg= -github.com/lrstanley/bubblezone v0.0.0-20240602193536-d14e6b69d7f9/go.mod h1:v5lEwWaguF1o2MW/ucO0ZIA/IZymdBYJJ+2cMRLE7LU= +github.com/lrstanley/bubblezone v0.0.0-20240609171605-b723e5c0b1af h1:ElLxMeBKoghsTLsrDyZGLcEz6WcPZcBzYvAK9CIHDyA= +github.com/lrstanley/bubblezone v0.0.0-20240609171605-b723e5c0b1af/go.mod h1:k7GwzSav+E8Isx3+2d5z5EJhIQrbC7mIOAFvV0TylSI= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -1306,8 +1306,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1513,8 +1513,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.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= @@ -1538,8 +1538,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1609,8 +1609,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/exec/atlantis_generate_repo_config.go b/internal/exec/atlantis_generate_repo_config.go index 08be730c5..f2845f541 100644 --- a/internal/exec/atlantis_generate_repo_config.go +++ b/internal/exec/atlantis_generate_repo_config.go @@ -154,11 +154,11 @@ func ExecuteAtlantisGenerateRepoConfigAffectedOnly( var err error if repoPath != "" { - affected, err = ExecuteDescribeAffectedWithTargetRepoPath(cliConfig, repoPath, verbose, false) + affected, err = ExecuteDescribeAffectedWithTargetRepoPath(cliConfig, repoPath, verbose, false, false) } else if cloneTargetRef { - affected, err = ExecuteDescribeAffectedWithTargetRefClone(cliConfig, ref, sha, sshKeyPath, sshKeyPassword, verbose, false) + affected, err = ExecuteDescribeAffectedWithTargetRefClone(cliConfig, ref, sha, sshKeyPath, sshKeyPassword, verbose, false, false) } else { - affected, err = ExecuteDescribeAffectedWithTargetRefCheckout(cliConfig, ref, sha, verbose, false) + affected, err = ExecuteDescribeAffectedWithTargetRefCheckout(cliConfig, ref, sha, verbose, false, false) } if err != nil { diff --git a/internal/exec/describe_affected.go b/internal/exec/describe_affected.go index dc3834f36..67f401440 100644 --- a/internal/exec/describe_affected.go +++ b/internal/exec/describe_affected.go @@ -89,6 +89,11 @@ func ExecuteDescribeAffectedCmd(cmd *cobra.Command, args []string) error { return err } + includeSettings, err := flags.GetBool("include-settings") + if err != nil { + return err + } + cloneTargetRef, err := flags.GetBool("clone-target-ref") if err != nil { return err @@ -101,11 +106,11 @@ func ExecuteDescribeAffectedCmd(cmd *cobra.Command, args []string) error { var affected []schema.Affected if repoPath != "" { - affected, err = ExecuteDescribeAffectedWithTargetRepoPath(cliConfig, repoPath, verbose, includeSpaceliftAdminStacks) + affected, err = ExecuteDescribeAffectedWithTargetRepoPath(cliConfig, repoPath, verbose, includeSpaceliftAdminStacks, includeSettings) } else if cloneTargetRef { - affected, err = ExecuteDescribeAffectedWithTargetRefClone(cliConfig, ref, sha, sshKeyPath, sshKeyPassword, verbose, includeSpaceliftAdminStacks) + affected, err = ExecuteDescribeAffectedWithTargetRefClone(cliConfig, ref, sha, sshKeyPath, sshKeyPassword, verbose, includeSpaceliftAdminStacks, includeSettings) } else { - affected, err = ExecuteDescribeAffectedWithTargetRefCheckout(cliConfig, ref, sha, verbose, includeSpaceliftAdminStacks) + affected, err = ExecuteDescribeAffectedWithTargetRefCheckout(cliConfig, ref, sha, verbose, includeSpaceliftAdminStacks, includeSettings) } if err != nil { diff --git a/internal/exec/describe_affected_utils.go b/internal/exec/describe_affected_utils.go index d53b1c79d..4feb3ce16 100644 --- a/internal/exec/describe_affected_utils.go +++ b/internal/exec/describe_affected_utils.go @@ -38,6 +38,7 @@ func ExecuteDescribeAffectedWithTargetRefClone( sshKeyPassword string, verbose bool, includeSpaceliftAdminStacks bool, + includeSettings bool, ) ([]schema.Affected, error) { if verbose { @@ -187,7 +188,16 @@ func ExecuteDescribeAffectedWithTargetRefClone( u.LogTrace(cliConfig, fmt.Sprintf("\nChecked out commit SHA '%s'\n", sha)) } - affected, err := executeDescribeAffected(cliConfig, localRepoPath, tempDir, localRepo, remoteRepo, verbose, includeSpaceliftAdminStacks) + affected, err := executeDescribeAffected( + cliConfig, + localRepoPath, + tempDir, + localRepo, + remoteRepo, + verbose, + includeSpaceliftAdminStacks, + includeSettings, + ) if err != nil { return nil, err } @@ -203,6 +213,7 @@ func ExecuteDescribeAffectedWithTargetRefCheckout( sha string, verbose bool, includeSpaceliftAdminStacks bool, + includeSettings bool, ) ([]schema.Affected, error) { if verbose { @@ -330,7 +341,16 @@ func ExecuteDescribeAffectedWithTargetRefCheckout( u.LogTrace(cliConfig, fmt.Sprintf("Checked out Git ref '%s'\n", ref)) } - affected, err := executeDescribeAffected(cliConfig, localRepoPath, tempDir, localRepo, remoteRepo, verbose, includeSpaceliftAdminStacks) + affected, err := executeDescribeAffected( + cliConfig, + localRepoPath, + tempDir, + localRepo, + remoteRepo, + verbose, + includeSpaceliftAdminStacks, + includeSettings, + ) if err != nil { return nil, err } @@ -345,6 +365,7 @@ func ExecuteDescribeAffectedWithTargetRepoPath( targetRefPath string, verbose bool, includeSpaceliftAdminStacks bool, + includeSettings bool, ) ([]schema.Affected, error) { localPath := "." @@ -384,7 +405,16 @@ func ExecuteDescribeAffectedWithTargetRepoPath( return nil, errors.Join(err, remoteRepoIsNotGitRepoError) } - affected, err := executeDescribeAffected(cliConfig, localRepoPath, targetRefPath, localRepo, remoteRepo, verbose, includeSpaceliftAdminStacks) + affected, err := executeDescribeAffected( + cliConfig, + localRepoPath, + targetRefPath, + localRepo, + remoteRepo, + verbose, + includeSpaceliftAdminStacks, + includeSettings, + ) if err != nil { return nil, err } @@ -400,6 +430,7 @@ func executeDescribeAffected( remoteRepo *git.Repository, verbose bool, includeSpaceliftAdminStacks bool, + includeSettings bool, ) ([]schema.Affected, error) { if verbose { @@ -515,7 +546,14 @@ func executeDescribeAffected( u.LogTrace(cliConfig, fmt.Sprintf("The current working branch and remote target branch are the same")) } - affected, err := findAffected(currentStacks, remoteStacks, cliConfig, changedFiles, includeSpaceliftAdminStacks) + affected, err := findAffected( + currentStacks, + remoteStacks, + cliConfig, + changedFiles, + includeSpaceliftAdminStacks, + includeSettings, + ) if err != nil { return nil, err } @@ -530,6 +568,7 @@ func findAffected( cliConfig schema.CliConfiguration, changedFiles []string, includeSpaceliftAdminStacks bool, + includeSettings bool, ) ([]schema.Affected, error) { res := []schema.Affected{} @@ -567,6 +606,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -599,6 +639,7 @@ func findAffected( affected, false, nil, + includeSettings, ) if err != nil { return nil, err @@ -628,6 +669,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -653,6 +695,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -678,6 +721,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -686,8 +730,8 @@ func findAffected( } } // Check `settings` section - if settingsSection, ok := componentSection["settings"].(map[any]any); ok { - if !isEqual(remoteStacks, stackName, "terraform", componentName, settingsSection, "settings") { + if settingsSection, ok := componentSection[cfg.SettingsSectionName].(map[any]any); ok { + if !isEqual(remoteStacks, stackName, "terraform", componentName, settingsSection, cfg.SettingsSectionName) { affected := schema.Affected{ ComponentType: "terraform", Component: componentName, @@ -703,6 +747,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -761,6 +806,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -800,6 +846,7 @@ func findAffected( affected, false, nil, + includeSettings, ) if err != nil { return nil, err @@ -832,6 +879,7 @@ func findAffected( affected, false, nil, + includeSettings, ) if err != nil { return nil, err @@ -857,6 +905,7 @@ func findAffected( affected, false, nil, + includeSettings, ) if err != nil { return nil, err @@ -882,6 +931,7 @@ func findAffected( affected, false, nil, + includeSettings, ) if err != nil { return nil, err @@ -890,8 +940,8 @@ func findAffected( } } // Check `settings` section - if settingsSection, ok := componentSection["settings"].(map[any]any); ok { - if !isEqual(remoteStacks, stackName, "helmfile", componentName, settingsSection, "settings") { + if settingsSection, ok := componentSection[cfg.SettingsSectionName].(map[any]any); ok { + if !isEqual(remoteStacks, stackName, "helmfile", componentName, settingsSection, cfg.SettingsSectionName) { affected := schema.Affected{ ComponentType: "helmfile", Component: componentName, @@ -907,6 +957,7 @@ func findAffected( affected, false, nil, + includeSettings, ) if err != nil { return nil, err @@ -965,6 +1016,7 @@ func findAffected( affected, includeSpaceliftAdminStacks, currentStacks, + includeSettings, ) if err != nil { return nil, err @@ -992,6 +1044,7 @@ func appendToAffected( affected schema.Affected, includeSpaceliftAdminStacks bool, stacks map[string]any, + includeSettings bool, ) ([]schema.Affected, error) { // If the affected component in the stack was already added to the result, don't add it again @@ -1001,18 +1054,23 @@ func appendToAffected( } } + settingsSection := map[any]any{} + + if i, ok2 := componentSection[cfg.SettingsSectionName]; ok2 { + settingsSection = i.(map[any]any) + + if includeSettings { + affected.Settings = settingsSection + } + } + if affected.ComponentType == "terraform" { varSection := map[any]any{} - settingsSection := map[any]any{} - if i, ok2 := componentSection["vars"]; ok2 { + if i, ok2 := componentSection[cfg.VarsSectionName]; ok2 { varSection = i.(map[any]any) } - if i, ok2 := componentSection["settings"]; ok2 { - settingsSection = i.(map[any]any) - } - configAndStacksInfo := schema.ConfigAndStacksInfo{ ComponentFromArg: componentName, Stack: stackName, @@ -1039,7 +1097,16 @@ func appendToAffected( affected.AtlantisProject = atlantisProjectName if includeSpaceliftAdminStacks { - affectedList, err = addAffectedSpaceliftAdminStack(cliConfig, affectedList, settingsSection, stacks, stackName, componentName, configAndStacksInfo) + affectedList, err = addAffectedSpaceliftAdminStack( + cliConfig, + affectedList, + settingsSection, + stacks, + stackName, + componentName, + configAndStacksInfo, + includeSettings, + ) if err != nil { return nil, err } @@ -1241,6 +1308,7 @@ func addAffectedSpaceliftAdminStack( currentStackName string, currentComponentName string, configAndStacksInfo schema.ConfigAndStacksInfo, + includeSettings bool, ) ([]schema.Affected, error) { // Convert the `settings` section to the `Settings` structure @@ -1326,7 +1394,7 @@ func addAffectedSpaceliftAdminStack( } if adminStackContext.Component == componentName && adminStackContextPrefix == contextPrefix { - if componentSettingsSection, ok = componentSection["settings"].(map[any]any); !ok { + if componentSettingsSection, ok = componentSection[cfg.SettingsSectionName].(map[any]any); !ok { return affectedList, nil } @@ -1364,6 +1432,7 @@ func addAffectedSpaceliftAdminStack( affectedSpaceliftAdminStack, false, nil, + includeSettings, ) if err != nil { return nil, err diff --git a/pkg/describe/describe_affected_test.go b/pkg/describe/describe_affected_test.go index 660ed7a03..41910af82 100644 --- a/pkg/describe/describe_affected_test.go +++ b/pkg/describe/describe_affected_test.go @@ -28,7 +28,7 @@ func TestDescribeAffectedWithTargetRefClone(t *testing.T) { ref := "refs/heads/main" sha := "" - affected, err := e.ExecuteDescribeAffectedWithTargetRefClone(cliConfig, ref, sha, "", "", true, true) + affected, err := e.ExecuteDescribeAffectedWithTargetRefClone(cliConfig, ref, sha, "", "", true, true, true) assert.Nil(t, err) affectedYaml, err := yaml.Marshal(affected) @@ -52,7 +52,7 @@ func TestDescribeAffectedWithTargetRepoPath(t *testing.T) { // This will compare this local repository with itself as the remote target, which should result in an empty `affected` list repoPath := "../../" - affected, err := e.ExecuteDescribeAffectedWithTargetRepoPath(cliConfig, repoPath, true, true) + affected, err := e.ExecuteDescribeAffectedWithTargetRepoPath(cliConfig, repoPath, true, true, true) assert.Nil(t, err) affectedYaml, err := yaml.Marshal(affected) diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index 79e72678e..9f1904f7e 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -436,6 +436,7 @@ type Affected struct { Folder string `yaml:"folder,omitempty" json:"folder,omitempty" mapstructure:"folder"` Dependents []Dependent `yaml:"dependents,omitempty" json:"dependents,omitempty" mapstructure:"dependents"` IncludedInDependents bool `yaml:"included_in_dependents" json:"included_in_dependents" mapstructure:"included_in_dependents"` + Settings map[any]any `yaml:"settings,omitempty" json:"settings,omitempty" mapstructure:"settings"` } type BaseComponentConfig struct { diff --git a/website/docs/cli/commands/describe/describe-affected.mdx b/website/docs/cli/commands/describe/describe-affected.mdx index 7349414f1..0ee463f84 100644 --- a/website/docs/cli/commands/describe/describe-affected.mdx +++ b/website/docs/cli/commands/describe/describe-affected.mdx @@ -112,9 +112,9 @@ atmos describe affected --repo-path atmos describe affected --include-spacelift-admin-stacks=true atmos describe affected --clone-target-ref=true atmos describe affected --include-dependents=true +atmos describe affected --include-settings=true ``` - # Example Output @@ -213,6 +213,7 @@ Affected components and stacks: | `--include-spacelift-admin-stacks` | Include the Spacelift admin stack of any stack
that is affected by config changes | no | | `--clone-target-ref` | Clone the target reference with which to compare the current branch.
`atmos describe affected --clone-target-ref=true`

If set to `false` (default), the target reference will be checked out instead
This requires that the target reference is already cloned by Git,
and the information about it exists in the `.git` directory | no | | `--include-dependents` | Include the dependent components and stacks.
`atmos describe affected --include-dependents=true` | no | +| `--include-settings` | Include the `settings` section for each affected component.
`atmos describe affected --include-settings=true` | no | ## Output @@ -234,6 +235,7 @@ Each object has the following schema: "folder": ".....", "dependents": [], "included_in_dependents": "true | false" + "settings": {} } ``` @@ -269,6 +271,10 @@ where: hierarchical - each component in the list will also contain a `dependents` property if that component has dependent components as well +- `settings` - the `settings` section of the component in the stack. It will be included only if the + command-line flag `--include-settings=true` is passed. The `settings` sections is a free-form map used to pass + configuration information to [integrations](/integrations) + - `included_in_dependents` - a boolean flag indicating if the affected component in the stack is also present in any of the `dependents` properties of the other affected components. It will be included only if the command-line flag `--include-dependents=true` is passed. If `included_in_dependents` is set to `true`, it indicates that the affected component in the stack is also diff --git a/website/docs/integrations/atlantis.mdx b/website/docs/integrations/atlantis.mdx index 3dc694e47..30882836c 100644 --- a/website/docs/integrations/atlantis.mdx +++ b/website/docs/integrations/atlantis.mdx @@ -687,7 +687,7 @@ on: branches: [ main ] env: - ATMOS_VERSION: 1.79.0 + ATMOS_VERSION: 1.80.0 ATMOS_CLI_CONFIG_PATH: ./ jobs: diff --git a/website/docs/integrations/github-actions/setup-atmos.mdx b/website/docs/integrations/github-actions/setup-atmos.mdx index 69da44378..ff2240d5a 100644 --- a/website/docs/integrations/github-actions/setup-atmos.mdx +++ b/website/docs/integrations/github-actions/setup-atmos.mdx @@ -30,6 +30,6 @@ jobs: uses: cloudposse/github-action-setup-atmos with: # Make sure to pin to the latest version of atmos - atmos_version: 1.79.0 + atmos_version: 1.80.0 ```