Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not process stack configs when executing command atmos vendor pull and the --stack flag is not specified #740

Merged
merged 13 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ import (
u "github.com/cloudposse/atmos/pkg/utils"
)

// ValidateConfig holds configuration options for Atmos validation.
// CheckStack determines whether stack configuration validation should be performed.
type ValidateConfig struct {
CheckStack bool
// Other configuration fields
}

type AtmosValidateOption func(*ValidateConfig)

func WithStackValidation(check bool) AtmosValidateOption {
return func(cfg *ValidateConfig) {
cfg.CheckStack = check
}
}

// processCustomCommands processes and executes custom commands
func processCustomCommands(
cliConfig schema.CliConfiguration,
Expand Down Expand Up @@ -323,17 +338,27 @@ func cloneCommand(orig *schema.Command) (*schema.Command, error) {
}

// checkAtmosConfig checks Atmos config
func checkAtmosConfig() {
func checkAtmosConfig(opts ...AtmosValidateOption) {
vCfg := &ValidateConfig{
CheckStack: true, // Default value true to check the stack
}

// Apply options
for _, opt := range opts {
opt(vCfg)
}

cliConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)
if err != nil {
u.LogErrorAndExit(cliConfig, err)
}

atmosConfigExists, err := u.IsDirectory(cliConfig.StacksBaseAbsolutePath)

if !atmosConfigExists || err != nil {
printMessageForMissingAtmosConfig(cliConfig)
os.Exit(0)
if vCfg.CheckStack {
atmosConfigExists, err := u.IsDirectory(cliConfig.StacksBaseAbsolutePath)
if !atmosConfigExists || err != nil {
printMessageForMissingAtmosConfig(cliConfig)
os.Exit(0)
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/vendor_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ var vendorPullCmd = &cobra.Command{
Long: `This command executes 'atmos vendor pull' CLI commands`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Run: func(cmd *cobra.Command, args []string) {
// Check Atmos configuration
checkAtmosConfig()
haitham911 marked this conversation as resolved.
Show resolved Hide resolved
haitham911 marked this conversation as resolved.
Show resolved Hide resolved
// WithStackValidation is a functional option that enables/disables stack configuration validation
// based on whether the --stack flag is provided
checkAtmosConfig(WithStackValidation(cmd.Flag("stack").Changed))

err := e.ExecuteVendorPullCmd(cmd, args)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions examples/quick-start-advanced/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Geodesic: https://github.com/cloudposse/geodesic/
ARG GEODESIC_VERSION=3.2.0
ARG GEODESIC_VERSION=3.3.0
ARG GEODESIC_OS=debian

# Atmos
# https://atmos.tools/
# https://github.com/cloudposse/atmos
# https://github.com/cloudposse/atmos/releases
ARG ATMOS_VERSION=1.93.0
ARG ATMOS_VERSION=1.97.0

# Terraform: https://github.com/hashicorp/terraform/releases
ARG TF_VERSION=1.9.8
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ 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/bubbletea v1.1.1
github.com/charmbracelet/lipgloss v0.13.0
github.com/charmbracelet/bubbletea v1.1.2
github.com/charmbracelet/lipgloss v0.13.1
github.com/elewis787/boa v0.1.2
github.com/fatih/color v1.17.0
github.com/fatih/color v1.18.0
github.com/go-git/go-git/v5 v5.12.0
github.com/google/go-containerregistry v0.20.2
github.com/google/go-github/v59 v59.0.0
Expand Down Expand Up @@ -90,7 +90,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/x/ansi v0.2.3 // indirect
github.com/charmbracelet/x/ansi v0.4.0 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,12 @@ 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/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY=
github.com/charmbracelet/bubbletea v1.1.1/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY=
github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
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/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/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=
Expand Down Expand Up @@ -492,8 +492,8 @@ github.com/evanphx/json-patch/v5 v5.5.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2Vvl
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down
2 changes: 1 addition & 1 deletion internal/exec/vendor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ExecuteVendorPullCommand(cmd *cobra.Command, args []string) error {
// system dir, home dir, current dir, ENV vars, command-line arguments
cliConfig, err := cfg.InitCliConfig(info, processStacks)
if err != nil {
return err
return fmt.Errorf("failed to initialize CLI config: %w", err)
}

dryRun, err := flags.GetBool("dry-run")
Expand Down
2 changes: 1 addition & 1 deletion website/docs/integrations/atlantis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ on:
branches: [ main ]

env:
ATMOS_VERSION: 1.93.0
ATMOS_VERSION: 1.97.0
ATMOS_CLI_CONFIG_PATH: ./

jobs:
Expand Down
Loading