Skip to content

Commit

Permalink
Merge branch 'main' into DEV-2767
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman authored Dec 18, 2024
2 parents 3771676 + 1defdce commit c78ab33
Show file tree
Hide file tree
Showing 57 changed files with 1,589 additions and 684 deletions.
10 changes: 5 additions & 5 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Order is important: the last matching pattern has the highest precedence

# These owners will be the default owners for everything
* @cloudposse/engineering @cloudposse/contributors
* @cloudposse/engineering

# Cloud Posse must review any changes to Makefiles
**/Makefile @cloudposse/engineering
Expand All @@ -15,10 +15,10 @@

# Cloud Posse must review any changes to standard context definition,
# but some changes can be rubber-stamped.
**/*.tf @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
README.yaml @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
**/*.tf @cloudposse/engineering @cloudposse/approvers
README.yaml @cloudposse/engineering @cloudposse/approvers
README.md @cloudposse/engineering @cloudposse/approvers
docs/*.md @cloudposse/engineering @cloudposse/approvers

# Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration
.github/mergify.yml @cloudposse/admins
Expand Down
1 change: 1 addition & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: .github
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ jobs:
# - demo-stack-templating
# - demo-multi-cloud
- demo-vendoring
- tests

timeout-minutes: 20
steps:
Expand Down
6 changes: 3 additions & 3 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -404,13 +404,13 @@ func printMessageForMissingAtmosConfig(cliConfig schema.CliConfiguration) {
u.PrintMessageInColor("atmos.yaml", c1)
fmt.Println(" CLI config file was not found.")
fmt.Print("\nThe default Atmos stacks directory is set to ")
u.PrintMessageInColor(path.Join(cliConfig.BasePath, cliConfig.Stacks.BasePath), c1)
u.PrintMessageInColor(filepath.Join(cliConfig.BasePath, cliConfig.Stacks.BasePath), c1)
fmt.Println(",\nbut the directory does not exist in the current path.")
} else {
// If Atmos found an `atmos.yaml` config file, but it defines invalid paths to Atmos stacks and components
u.PrintMessageInColor("atmos.yaml", c1)
fmt.Print(" CLI config file specifies the directory for Atmos stacks as ")
u.PrintMessageInColor(path.Join(cliConfig.BasePath, cliConfig.Stacks.BasePath), c1)
u.PrintMessageInColor(filepath.Join(cliConfig.BasePath, cliConfig.Stacks.BasePath), c1)
fmt.Println(",\nbut the directory does not exist.")
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"

"github.com/charmbracelet/glamour"
Expand Down Expand Up @@ -59,7 +59,7 @@ var docsCmd = &cobra.Command{
}

// Construct the full path to the Terraform component by combining the Atmos base path, Terraform base path, and component name
componentPath := path.Join(cliConfig.BasePath, cliConfig.Components.Terraform.BasePath, info.Component)
componentPath := filepath.Join(cliConfig.BasePath, cliConfig.Components.Terraform.BasePath, info.Component)
componentPathExists, err := u.IsDirectory(componentPath)
if err != nil {
u.LogErrorAndExit(schema.CliConfiguration{}, err)
Expand All @@ -68,7 +68,7 @@ var docsCmd = &cobra.Command{
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("Component '%s' not found in path: '%s'", info.Component, componentPath))
}

readmePath := path.Join(componentPath, "README.md")
readmePath := filepath.Join(componentPath, "README.md")
if _, err := os.Stat(readmePath); err != nil {
if os.IsNotExist(err) {
u.LogErrorAndExit(schema.CliConfiguration{}, fmt.Errorf("No README found for component: %s", info.Component))
Expand Down
2 changes: 1 addition & 1 deletion cmd/vendor_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func init() {
vendorPullCmd.PersistentFlags().StringP("type", "t", "terraform", "atmos vendor pull --component <component> --type=terraform|helmfile")
vendorPullCmd.PersistentFlags().Bool("dry-run", false, "atmos vendor pull --component <component> --dry-run")
vendorPullCmd.PersistentFlags().String("tags", "", "Only vendor the components that have the specified tags: atmos vendor pull --tags=dev,test")

vendorPullCmd.PersistentFlags().Bool("everything", false, "Vendor all components: atmos vendor pull --everything")
vendorCmd.AddCommand(vendorPullCmd)
}
2 changes: 1 addition & 1 deletion examples/demo-component-versions/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ commands:
- name: "test"
description: "Run all tests"
steps:
- atmos vendor pull
- atmos vendor pull --everything
2 changes: 1 addition & 1 deletion examples/demo-vendoring/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ commands:
- name: "test"
description: "Run all tests"
steps:
- atmos vendor pull
- atmos vendor pull --everything
2 changes: 1 addition & 1 deletion examples/quick-start-advanced/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.127.0
ARG ATMOS_VERSION=1.130.0

# Terraform: https://github.com/hashicorp/terraform/releases
ARG TF_VERSION=1.5.7
Expand Down
9 changes: 7 additions & 2 deletions examples/tests/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ logs:

# Custom CLI commands
commands:
# No arguments or flags are required
- name: "test"
description: "Run all tests"
steps:
- atmos vendor pull

- name: tf
description: Execute 'terraform' commands
# subcommands
Expand Down Expand Up @@ -196,7 +202,7 @@ commands:
Example usage:
atmos set-eks-cluster eks/cluster -s tenant1-ue1-dev -r admin
atmos set-eks-cluster eks/cluster -s tenant2-uw2-prod --role reader
verbose: false # Set to `true` to see verbose outputs
verbose: false # Set to `true` to see verbose outputs
arguments:
- name: component
description: Name of the component
Expand Down Expand Up @@ -233,7 +239,6 @@ commands:

# Integrations
integrations:

# Atlantis integration
# https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html
atlantis:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ components:
test_30: !exec atmos terraform output template-functions-test -s {{ .stack }} --skip-init -- -json test_label_id
test_31: !exec atmos terraform output template-functions-test -s {{ .stack }} --skip-init -- -json test_map
test_32: !exec atmos terraform output template-functions-test -s {{ .stack }} --skip-init -- -json test_list
# Call the `!terraform.output` function with two parameters
test_40: !terraform.output template-functions-test test_label_id
test_41: !terraform.output template-functions-test test_list
test_42: !terraform.output template-functions-test test_map
# Component `template-functions-test3` is configured with the remote state backend of type `static`
test_50: !terraform.output template-functions-test3 val1
test_51: !terraform.output template-functions-test3 {{ .stack }} val1
test_52: !terraform.output template-functions-test3 val2
test_53: !terraform.output template-functions-test3 val3
test_54: !terraform.output template-functions-test3 val4
test_55: !terraform.output template-functions-test3 val5
test_56: !terraform.output template-functions-test3 val6
# test_57: !terraform.output does_not_exist val6
# test_57: !terraform.output template-functions-test3 invalid-val
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# yaml-language-server: $schema=https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json

components:
terraform:
template-functions-test3:
remote_state_backend_type: static
remote_state_backend:
static:
val1: true
val2: "2"
val3: 3
val4: null
val5:
- item1
- item2
- item3
val6:
i1: 1
i2: 2
i3: 3
5 changes: 3 additions & 2 deletions examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ 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
# - catalog/terraform/template-functions-test3/defaults

components:
terraform:
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
github.com/jwalton/go-supportscolor v1.2.0
github.com/kubescape/go-git-url v0.0.30
github.com/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e
github.com/mattn/go-isatty v0.0.20
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-wordwrap v1.0.1
github.com/mitchellh/mapstructure v1.5.0
Expand Down Expand Up @@ -98,6 +99,7 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chainguard-dev/git-urls v1.0.2 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.4.5 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
Expand Down Expand Up @@ -175,7 +177,6 @@ require (
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv
github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM=
github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs=
github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8=
github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
Expand Down
3 changes: 1 addition & 2 deletions internal/exec/atlantis_generate_repo_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package exec

import (
"fmt"
"path"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -339,7 +338,7 @@ func ExecuteAtlantisGenerateRepoConfig(
}

// Absolute path to the terraform component
terraformComponentPath := path.Join(
terraformComponentPath := filepath.Join(
cliConfig.BasePath,
cliConfig.Components.Terraform.BasePath,
terraformComponent,
Expand Down
9 changes: 5 additions & 4 deletions internal/exec/aws_eks_update_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package exec

import (
"fmt"
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"path"
"strings"

cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/schema"
Expand Down Expand Up @@ -157,11 +158,11 @@ func ExecuteAwsEksUpdateKubeconfig(kubeconfigContext schema.AwsEksUpdateKubeconf

configAndStacksInfo.ComponentType = "terraform"
configAndStacksInfo, err = ProcessStacks(cliConfig, configAndStacksInfo, true, true)
shellCommandWorkingDir = path.Join(cliConfig.TerraformDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent)
shellCommandWorkingDir = filepath.Join(cliConfig.TerraformDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent)
if err != nil {
configAndStacksInfo.ComponentType = "helmfile"
configAndStacksInfo, err = ProcessStacks(cliConfig, configAndStacksInfo, true, true)
shellCommandWorkingDir = path.Join(cliConfig.HelmfileDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent)
shellCommandWorkingDir = filepath.Join(cliConfig.HelmfileDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent)
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions internal/exec/describe_affected_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,12 @@ func executeDescribeAffected(
}

// Update paths to point to the cloned remote repo dir
cliConfig.StacksBaseAbsolutePath = path.Join(remoteRepoFileSystemPath, basePath, cliConfig.Stacks.BasePath)
cliConfig.TerraformDirAbsolutePath = path.Join(remoteRepoFileSystemPath, basePath, cliConfig.Components.Terraform.BasePath)
cliConfig.HelmfileDirAbsolutePath = path.Join(remoteRepoFileSystemPath, basePath, cliConfig.Components.Helmfile.BasePath)
cliConfig.StacksBaseAbsolutePath = filepath.Join(remoteRepoFileSystemPath, basePath, cliConfig.Stacks.BasePath)
cliConfig.TerraformDirAbsolutePath = filepath.Join(remoteRepoFileSystemPath, basePath, cliConfig.Components.Terraform.BasePath)
cliConfig.HelmfileDirAbsolutePath = filepath.Join(remoteRepoFileSystemPath, basePath, cliConfig.Components.Helmfile.BasePath)

cliConfig.StackConfigFilesAbsolutePaths, err = u.JoinAbsolutePathWithPaths(
path.Join(remoteRepoFileSystemPath, basePath, cliConfig.Stacks.BasePath),
filepath.Join(remoteRepoFileSystemPath, basePath, cliConfig.Stacks.BasePath),
cliConfig.StackConfigFilesRelativePaths,
)
if err != nil {
Expand Down Expand Up @@ -1182,9 +1182,9 @@ func isComponentFolderChanged(

switch componentType {
case "terraform":
componentPath = path.Join(cliConfig.BasePath, cliConfig.Components.Terraform.BasePath, component)
componentPath = filepath.Join(cliConfig.BasePath, cliConfig.Components.Terraform.BasePath, component)
case "helmfile":
componentPath = path.Join(cliConfig.BasePath, cliConfig.Components.Helmfile.BasePath, component)
componentPath = filepath.Join(cliConfig.BasePath, cliConfig.Components.Helmfile.BasePath, component)
}

componentPathAbs, err := filepath.Abs(componentPath)
Expand Down Expand Up @@ -1220,7 +1220,7 @@ func areTerraformComponentModulesChanged(
changedFiles []string,
) (bool, error) {

componentPath := path.Join(cliConfig.BasePath, cliConfig.Components.Terraform.BasePath, component)
componentPath := filepath.Join(cliConfig.BasePath, cliConfig.Components.Terraform.BasePath, component)

componentPathAbs, err := filepath.Abs(componentPath)
if err != nil {
Expand All @@ -1241,7 +1241,7 @@ func areTerraformComponentModulesChanged(
continue
}

modulePath := path.Join(path.Dir(moduleConfig.Pos.Filename), moduleConfig.Source)
modulePath := filepath.Join(path.Dir(moduleConfig.Pos.Filename), moduleConfig.Source)

modulePathAbs, err := filepath.Abs(modulePath)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/describe_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func ExecuteDescribeStacks(
u.LogErrorAndExit(cliConfig, err)
}

componentSectionFinal, err := ProcessCustomYamlTags(cliConfig, componentSectionConverted)
componentSectionFinal, err := ProcessCustomYamlTags(cliConfig, componentSectionConverted, stackName)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -547,7 +547,7 @@ func ExecuteDescribeStacks(
u.LogErrorAndExit(cliConfig, err)
}

componentSectionFinal, err := ProcessCustomYamlTags(cliConfig, componentSectionConverted)
componentSectionFinal, err := ProcessCustomYamlTags(cliConfig, componentSectionConverted, stackName)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/exec/helmfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package exec
import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -78,20 +78,20 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error {
}

// Check if the component exists as a helmfile component
componentPath := path.Join(cliConfig.HelmfileDirAbsolutePath, info.ComponentFolderPrefix, info.FinalComponent)
componentPath := filepath.Join(cliConfig.HelmfileDirAbsolutePath, info.ComponentFolderPrefix, info.FinalComponent)
componentPathExists, err := u.IsDirectory(componentPath)
if err != nil || !componentPathExists {
return fmt.Errorf("'%s' points to the Helmfile component '%s', but it does not exist in '%s'",
info.ComponentFromArg,
info.FinalComponent,
path.Join(cliConfig.Components.Helmfile.BasePath, info.ComponentFolderPrefix),
filepath.Join(cliConfig.Components.Helmfile.BasePath, info.ComponentFolderPrefix),
)
}

// Check if the component is allowed to be provisioned (`metadata.type` attribute)
if (info.SubCommand == "sync" || info.SubCommand == "apply" || info.SubCommand == "deploy") && info.ComponentIsAbstract {
return fmt.Errorf("abstract component '%s' cannot be provisioned since it's explicitly prohibited from being deployed "+
"by 'metadata.type: abstract' attribute", path.Join(info.ComponentFolderPrefix, info.Component))
"by 'metadata.type: abstract' attribute", filepath.Join(info.ComponentFolderPrefix, info.Component))
}

// Print component variables
Expand Down Expand Up @@ -196,7 +196,7 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error {
u.LogDebug(cliConfig, "Stack: "+info.StackFromArg)
} else {
u.LogDebug(cliConfig, "Stack: "+info.StackFromArg)
u.LogDebug(cliConfig, "Stack path: "+path.Join(cliConfig.BasePath, cliConfig.Stacks.BasePath, info.Stack))
u.LogDebug(cliConfig, "Stack path: "+filepath.Join(cliConfig.BasePath, cliConfig.Stacks.BasePath, info.Stack))
}

workingDir := constructHelmfileComponentWorkingDir(cliConfig, info)
Expand Down
Loading

0 comments on commit c78ab33

Please sign in to comment.