Skip to content
Closed
Show file tree
Hide file tree
Changes from 102 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
61a9e5c
init cli config
samtholiya Mar 28, 2025
23c36bd
update config
samtholiya Mar 31, 2025
a16144e
update commands
samtholiya Mar 31, 2025
8c9c6cd
Merge branch 'main' of https://github.com/cloudposse/atmos into featu…
samtholiya Mar 31, 2025
dd06513
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 31, 2025
f0e04ab
merge fix
samtholiya Apr 1, 2025
6bce126
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 1, 2025
1be1214
fix add config function
samtholiya Apr 1, 2025
3266760
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 1, 2025
0e5a1ed
fix add config function
samtholiya Apr 1, 2025
95a14e8
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 1, 2025
247ab4c
fix golang lint
samtholiya Apr 1, 2025
4a64fb7
fix golang lint
samtholiya Apr 1, 2025
92b4c4e
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 1, 2025
532d882
fix tests
samtholiya Apr 3, 2025
d362421
checking the cause of test failures
samtholiya Apr 4, 2025
98d875b
checking the test case failure reason
samtholiya Apr 4, 2025
f9672e7
is chDir not working
samtholiya Apr 4, 2025
603db4b
fix test cases
samtholiya Apr 5, 2025
28d7a12
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 5, 2025
41e07ed
fix terraform tests
samtholiya Apr 5, 2025
2c37b5a
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 5, 2025
c19e3e2
fixed loglevel test case
samtholiya Apr 5, 2025
f26abea
checking wd to adjust wd
samtholiya Apr 5, 2025
aabcb31
logging
samtholiya Apr 5, 2025
8d28e71
fixed snapshots
samtholiya Apr 5, 2025
e485267
revert unwanted change
samtholiya Apr 5, 2025
4790fc4
try to fix vendored tests
samtholiya Apr 5, 2025
2b22001
fixed config test case
samtholiya Apr 6, 2025
94338c4
Merge branch 'main' of https://github.com/cloudposse/atmos into featu…
samtholiya Apr 6, 2025
3b6b276
fixed lint
samtholiya Apr 6, 2025
1720916
config tests fixed
samtholiya Apr 7, 2025
f5fcf04
fix terraform test
samtholiya Apr 7, 2025
8c6f57a
fix vendor test
samtholiya Apr 7, 2025
8d4ee36
fixed config test
samtholiya Apr 7, 2025
9e87f02
utils test deteled
samtholiya Apr 7, 2025
998d2db
fix hooks test case
samtholiya Apr 8, 2025
0ae2b98
add comment
samtholiya Apr 9, 2025
10de0bb
Merge branch 'main' of https://github.com/cloudposse/atmos into featu…
samtholiya Apr 10, 2025
60ada38
fix config parameter
samtholiya Apr 11, 2025
c4ff883
TestLoadConfigFromCLIArgs
samtholiya Apr 11, 2025
880097b
added debug log
samtholiya Apr 11, 2025
caa98bc
causing panic
samtholiya Apr 12, 2025
e937ef0
workflow cmd
samtholiya Apr 12, 2025
4e6cc3a
fix lint
samtholiya Apr 12, 2025
eed0033
added test case for more coverage
samtholiya Apr 12, 2025
4b3003e
remove unwanted functions
samtholiya Apr 12, 2025
ffef6da
utils test added
samtholiya Apr 12, 2025
a3bb42d
add test for coverage
samtholiya Apr 12, 2025
ef74d7e
add test case for env atmos config path
samtholiya Apr 13, 2025
ce1b618
fix ci lint
samtholiya Apr 13, 2025
f5cfdce
add more coverage
samtholiya Apr 13, 2025
40893ed
Update pkg/config/config_new.go
samtholiya Apr 13, 2025
6e69afc
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 13, 2025
90bf00a
fix config order
samtholiya Apr 14, 2025
222938e
added more test for utils
samtholiya Apr 14, 2025
ea56d99
fixed test case
samtholiya Apr 15, 2025
1cd1944
fix workflow tests
samtholiya Apr 15, 2025
efd0251
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 16, 2025
546657f
fix test cases
samtholiya Apr 16, 2025
c6ff798
add tests for more coverage
samtholiya Apr 18, 2025
57aa2ad
Update codecov.yml
samtholiya Apr 18, 2025
cf673ff
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 20, 2025
18f6bb0
Update pkg/config/config_new.go
samtholiya Apr 20, 2025
e3cfcae
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 20, 2025
615b1bf
Update pkg/config/config_new.go
samtholiya Apr 20, 2025
cb3eeba
Update tests/vendor_test.go
samtholiya Apr 20, 2025
0f5aa5c
Update tests/vendor_test.go
samtholiya Apr 20, 2025
301dd2e
updated help
samtholiya Apr 20, 2025
892bf0d
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 20, 2025
d47f671
updated tests
samtholiya Apr 20, 2025
f674c2a
add more test coverage
samtholiya Apr 21, 2025
e06feef
Update codecov.yml
samtholiya Apr 21, 2025
0158861
fix type
samtholiya Apr 21, 2025
ea53afd
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 21, 2025
3d8ee7e
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 21, 2025
ec240e8
coderabbit fix
samtholiya Apr 21, 2025
214d129
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 21, 2025
4d8be22
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 21, 2025
3187e52
testing this change
samtholiya Apr 21, 2025
f5af7b4
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 21, 2025
ed90f38
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 22, 2025
11355fd
added new tests
samtholiya Apr 23, 2025
e6dc438
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 23, 2025
f8adc7a
Merge branch 'main' of https://github.com/cloudposse/atmos into featu…
samtholiya Apr 24, 2025
f881626
fix tests
samtholiya Apr 24, 2025
59c524a
config test updated
samtholiya Apr 24, 2025
8a45ef8
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 25, 2025
676846f
fix test cases
samtholiya Apr 25, 2025
3b11603
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya Apr 25, 2025
cf2b060
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya Apr 27, 2025
6d52725
checking if tests pass
samtholiya Apr 27, 2025
cd53d79
fix test cases
samtholiya Apr 28, 2025
b4ade4b
fix tests
samtholiya Apr 28, 2025
9aeb539
fixed test case
samtholiya Apr 28, 2025
8c35bad
fix test case
samtholiya Apr 28, 2025
759c5fa
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya May 1, 2025
2069f55
fix test
samtholiya May 1, 2025
c20ec81
Merge branch 'feature/dev-3093-create-a-cli-command-core-library' of …
samtholiya May 1, 2025
4403fbf
update the tests
samtholiya May 1, 2025
cc26e45
added coverage
samtholiya May 1, 2025
fa08e0b
fix lint
samtholiya May 1, 2025
c52ce45
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
Benbentwo May 7, 2025
bff518b
Merge remote-tracking branch 'origin/main' into feature/dev-3093-crea…
Benbentwo May 7, 2025
c6570d8
cleanup from merge
Benbentwo May 7, 2025
037fb3e
Merge branch 'refs/heads/main' into feature/dev-3093-create-a-cli-com…
Benbentwo May 7, 2025
4d828ea
Merge branch 'main' into feature/dev-3093-create-a-cli-command-core-l…
samtholiya May 9, 2025
97d456d
test fix
samtholiya May 10, 2025
8ac1d29
fix test cases
samtholiya May 11, 2025
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ testacc: get

testacc-cover: get
@echo "Running tests with coverage"
go test $(TEST) -v $(TESTARGS) -timeout 20m -coverprofile=coverage.out.tmp
go test $(TEST) -v -coverpkg=./... $(TESTARGS) -timeout 20m -coverprofile=coverage.out.tmp
cat coverage.out.tmp | grep -v "mock_" > coverage.out

# Run acceptance tests with coverage report
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func checkAtmosConfig(opts ...AtmosValidateOption) {
atmosConfigExists, err := u.IsDirectory(atmosConfig.StacksBaseAbsolutePath)
if !atmosConfigExists || err != nil {
printMessageForMissingAtmosConfig(atmosConfig)
os.Exit(1)
u.OsExit(1)
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions cmd/helmfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/config"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/spf13/cobra"
)
Expand All @@ -20,10 +21,41 @@ func init() {
// https://github.com/spf13/cobra/issues/739
helmfileCmd.DisableFlagParsing = true
helmfileCmd.PersistentFlags().Bool("", false, doubleDashHint)
config.DefaultConfigHandler.AddConfig(helmfileCmd, &config.ConfigOptions{
FlagName: "helmfile-command",
EnvVar: "ATMOS_COMPONENTS_HELMFILE_COMMAND",
Description: "Specifies the executable to be called by `atmos` when running Helmfile commands.",
Key: "components.helmfile.command",
DefaultValue: "helmfile",
})
config.DefaultConfigHandler.AddConfig(helmfileCmd, &config.ConfigOptions{
FlagName: "helmfile-dir",
EnvVar: "ATMOS_COMPONENTS_HELMFILE_BASE_PATH",
Description: "Specifies the directory where Helmfile commands are executed. (Deprecated: use `--helmfile-base-path` instead)",
Key: "components.helmfile.base_path",
DefaultValue: "",
})
config.DefaultConfigHandler.AddConfig(helmfileCmd, &config.ConfigOptions{
FlagName: "helmfile-base-path",
EnvVar: "ATMOS_COMPONENTS_HELMFILE_BASE_PATH",
Description: "Specifies the directory where Helmfile commands are executed.",
Key: "components.helmfile.base_path",
DefaultValue: "",
})

AddStackCompletion(helmfileCmd)
helmfileCommandConfig()
RootCmd.AddCommand(helmfileCmd)
}

func helmfileCommandConfig() {
config.DefaultConfigHandler.SetDefault("components.helmfile.use_eks", true)
config.DefaultConfigHandler.BindEnv("components.helmfile.use_eks", "ATMOS_COMPONENTS_HELMFILE_USE_EKS")
config.DefaultConfigHandler.BindEnv("components.helmfile.kubeconfig_path", "ATMOS_COMPONENTS_HELMFILE_KUBECONFIG_PATH")
config.DefaultConfigHandler.BindEnv("components.helmfile.helm_aws_profile_pattern", "ATMOS_COMPONENTS_HELMFILE_HELM_AWS_PROFILE_PATTERN")
config.DefaultConfigHandler.BindEnv("components.helmfile.cluster_name_pattern", "ATMOS_COMPONENTS_HELMFILE_CLUSTER_NAME_PATTERN")
}

func helmfileRun(cmd *cobra.Command, commandName string, args []string) {
handleHelpRequest(cmd, args)
diffArgs := []string{commandName}
Expand Down
61 changes: 56 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/internal/tui/templates"
tuiUtils "github.com/cloudposse/atmos/internal/tui/utils"
"github.com/cloudposse/atmos/pkg/config"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/logger"
"github.com/cloudposse/atmos/pkg/schema"
Expand Down Expand Up @@ -189,11 +190,61 @@ func init() {
RootCmd.PersistentFlags().String("redirect-stderr", "", "File descriptor to redirect `stderr` to. "+
"Errors can be redirected to any file or any standard file descriptor (including `/dev/null`)")

RootCmd.PersistentFlags().String("logs-level", "Info", "Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level is set to Off, Atmos will not log any messages")
RootCmd.PersistentFlags().String("logs-file", "/dev/stderr", "The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including '/dev/stdout', '/dev/stderr' and '/dev/null'")
RootCmd.PersistentFlags().String("base-path", "", "Base path for Atmos project")
RootCmd.PersistentFlags().StringSlice("config", []string{}, "Paths to configuration files (comma-separated or repeated flag)")
RootCmd.PersistentFlags().StringSlice("config-path", []string{}, "Paths to configuration directories (comma-separated or repeated flag)")
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "logs-level",
EnvVar: "ATMOS_LOGS_LEVEL",
Description: "Logs level. Supported log levels are Trace, Debug, Info, Warning, Off. If the log level is set to Off, Atmos will not log any messages",
Key: "logs.level",
DefaultValue: "Info",
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "logs-file",
EnvVar: "ATMOS_LOGS_FILE",
DefaultValue: "/dev/stderr",
Description: "The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including `/dev/stdout`, `/dev/stderr` and `/dev/null`",
Key: "logs.file",
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "base-path",
EnvVar: "ATMOS_BASE_PATH",
Key: "base_path",
Description: "Base path for components, stacks and workflows configurations.",
DefaultValue: "",
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "stacks-dir",
EnvVar: "ATMOS_STACKS_BASE_PATH",
Key: "stacks.base_path",
Description: "Base path for stacks configurations. (Deprecated: use `--stacks-base-path` instead)",
DefaultValue: "",
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "stacks-base-path",
EnvVar: "ATMOS_STACKS_BASE_PATH",
Key: "stacks.base_path",
Description: "Base path for stacks configurations.",
DefaultValue: "",
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "settings-list-merge-strategy",
EnvVar: "ATMOS_SETTINGS_LIST_MERGE_STRATEGY",
Key: "settings.list_merge_strategy",
Description: "Specifies the merge strategy for lists in settings files. Supported values are `append`, `merge` and `replace`.",
DefaultValue: "replace",
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "config",
Key: "config",
Description: "Paths to configuration files (comma-separated or repeated flag)",
DefaultValue: []string{},
})
config.DefaultConfigHandler.AddConfig(RootCmd, &cfg.ConfigOptions{
FlagName: "config-path",
Key: "config_path",
Description: "Paths to configuration directories (comma-separated or repeated flag)",
DefaultValue: []string{},
})

// Set custom usage template
err := templates.SetCustomUsageFunc(RootCmd)
if err != nil {
Expand Down
92 changes: 92 additions & 0 deletions cmd/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/config"
cfg "github.com/cloudposse/atmos/pkg/config"
terrerrors "github.com/cloudposse/atmos/pkg/errors"
h "github.com/cloudposse/atmos/pkg/hooks"
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/cloudposse/atmos/pkg/version"
)

// terraformCmd represents the base command for all terraform sub-commands
Expand All @@ -27,11 +29,101 @@ func init() {
// https://github.com/spf13/cobra/issues/739
terraformCmd.DisableFlagParsing = true
terraformCmd.PersistentFlags().Bool("", false, doubleDashHint)
addTerraformCommandConfig()
AddStackCompletion(terraformCmd)
attachTerraformCommands(terraformCmd)
RootCmd.AddCommand(terraformCmd)
}

func addTerraformCommandConfig() {
addTerraformCommandSettings()
addTerraformInitSettings()
addTerraformExecutionSettings()
}

func addTerraformCommandSettings() {
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
FlagName: "terraform-command",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_COMMAND",
Description: "Specifies the executable to be called by `atmos` when running Terraform commands.",
Key: "components.terraform.command",
DefaultValue: "terraform",
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
FlagName: "terraform-dir",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_BASE_PATH",
Description: "Specifies the directory where Terraform commands are executed. (Deprecated: use `--terraform-base-path` instead)",
Key: "components.terraform.base_path",
DefaultValue: "",
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
FlagName: "terraform-base-path",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_BASE_PATH",
Description: "Specifies the directory where Terraform commands are executed.",
Key: "components.terraform.base_path",
DefaultValue: "",
})
config.DefaultConfigHandler.BindEnv("components.terraform.apply_auto_approve", "ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE")
}

func addTerraformInitSettings() {
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.init_run_config",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE",
FlagName: "init-run-reconfigure",
Description: "Run `terraform init` with reconfigure before running `terraform apply`",
DefaultValue: false,
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.auto_generate_backend_file",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE",
FlagName: "auto-generate-backend-file",
Description: "Automatically generate a backend file for Terraform commands",
DefaultValue: false,
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.init.pass_vars",
FlagName: "init-pass-vars",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_INIT_PASS_VARS",
Description: "Pass the generated varfile to `terraform init` using the `--var-file` flag. [OpenTofu supports passing a varfile to `init`](https://opentofu.org/docs/cli/commands/init/#general-options) to dynamically configure backends",
DefaultValue: false,
})
}

func addTerraformExecutionSettings() {
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.append_user_agent",
FlagName: "append-user-agent",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_APPEND_USER_AGENT",
DefaultValue: fmt.Sprintf("Atmos/%s (Cloud Posse; +https://atmos.tools)", version.Version),
Description: fmt.Sprintf("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)`. This flag works with almost all commands.", version.Version),
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.skip_init",
FlagName: "skip-init",
Description: "Skip running `terraform init` before executing terraform commands",
DefaultValue: false,
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.process_templates",
FlagName: "process-templates",
Description: "Enable/disable Go template processing in Atmos stack manifests when executing terraform commands",
DefaultValue: true,
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.process_functions",
FlagName: "process-functions",
Description: "Enable/disable YAML functions processing in Atmos stack manifests when executing terraform commands",
DefaultValue: true,
})
config.DefaultConfigHandler.AddConfig(terraformCmd, &cfg.ConfigOptions{
Key: "components.terraform.skip",
FlagName: "skip",
Description: "Skip executing specific YAML functions in the Atmos stack manifests when executing terraform commands",
DefaultValue: []string{},
})
}

func runHooks(event h.HookEvent, cmd *cobra.Command, args []string) error {
info := getConfigAndStacksInfo("terraform", cmd, append([]string{cmd.Name()}, args...))

Expand Down
18 changes: 9 additions & 9 deletions cmd/terraform_commands.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cmd

import (
"fmt"
"log"
"os"

"github.com/cloudposse/atmos/pkg/config"
cfg "github.com/cloudposse/atmos/pkg/config"
h "github.com/cloudposse/atmos/pkg/hooks"
"github.com/cloudposse/atmos/pkg/version"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -268,12 +268,6 @@ Arguments:

// attachTerraformCommands attaches static Terraform commands to a provided parent command
func attachTerraformCommands(parentCmd *cobra.Command) {
parentCmd.PersistentFlags().String("append-user-agent", "", fmt.Sprintf("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)`. This flag works with almost all commands.", version.Version))
parentCmd.PersistentFlags().Bool("skip-init", false, "Skip running `terraform init` before executing terraform commands")
parentCmd.PersistentFlags().Bool("process-templates", true, "Enable/disable Go template processing in Atmos stack manifests when executing terraform commands")
parentCmd.PersistentFlags().Bool("process-functions", true, "Enable/disable YAML functions processing in Atmos stack manifests when executing terraform commands")
parentCmd.PersistentFlags().StringSlice("skip", nil, "Skip executing specific YAML functions in the Atmos stack manifests when executing terraform commands")

commands := getTerraformCommands()

for _, cmd := range commands {
Expand Down Expand Up @@ -303,7 +297,13 @@ func attachTerraformCommands(parentCmd *cobra.Command) {

var commandMaps = map[string]func(cmd *cobra.Command){
"deploy": func(cmd *cobra.Command) {
cmd.PersistentFlags().Bool("deploy-run-init", false, "If set atmos will run `terraform init` before executing the command")
config.DefaultConfigHandler.AddConfig(cmd, &cfg.ConfigOptions{
Key: "components.terraform.deploy_run_init",
EnvVar: "ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT",
FlagName: "deploy-run-init",
Description: "Run `terraform init` before running `terraform apply`",
DefaultValue: false,
})
cmd.PersistentFlags().Bool("from-plan", false, "If set atmos will use the previously generated plan file")
cmd.PersistentFlags().String("planfile", "", "Set the plan file to use")
},
Expand Down
20 changes: 19 additions & 1 deletion cmd/validate_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/ui/theme"
u "github.com/cloudposse/atmos/pkg/utils"
)
Expand Down Expand Up @@ -45,6 +46,23 @@ func init() {
if err != nil {
u.LogErrorAndExit(err)
}

validateComponentCommandConfig()
validateCmd.AddCommand(validateComponentCmd)
}

func validateComponentCommandConfig() {
config.DefaultConfigHandler.AddConfig(validateComponentCmd, &config.ConfigOptions{
FlagName: "schemas-jsonschema-dir",
EnvVar: "ATMOS_SCHEMAS_JSONSCHEMA_BASE_PATH",
Description: "Base path for JSON Schema files.",
Key: "schemas.jsonschema.base_path",
DefaultValue: "",
})
config.DefaultConfigHandler.AddConfig(validateComponentCmd, &config.ConfigOptions{
FlagName: "schemas-opa-dir",
EnvVar: "ATMOS_SCHEMAS_OPA_BASE_PATH",
Description: "Base path for OPA policy files.",
Key: "schemas.opa.base_path",
DefaultValue: "",
})
}
2 changes: 2 additions & 0 deletions cmd/validate_editorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
u "github.com/cloudposse/atmos/pkg/utils"
"github.com/cloudposse/atmos/pkg/version"

cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/editorconfig-checker/editorconfig-checker/v3/pkg/config"
er "github.com/editorconfig-checker/editorconfig-checker/v3/pkg/error"
"github.com/editorconfig-checker/editorconfig-checker/v3/pkg/files"
Expand Down Expand Up @@ -206,4 +207,5 @@ func init() {
addPersistentFlags(editorConfigCmd)
// Add command
validateCmd.AddCommand(editorConfigCmd)
cfg.DefaultConfigHandler.SetDefault("validate.editorconfig.color", true)
}
10 changes: 8 additions & 2 deletions cmd/validate_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/spf13/cobra"

e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/ui/theme"
u "github.com/cloudposse/atmos/pkg/utils"
)
Expand Down Expand Up @@ -32,7 +33,12 @@ var ValidateStacksCmd = &cobra.Command{
func init() {
ValidateStacksCmd.DisableFlagParsing = false

ValidateStacksCmd.PersistentFlags().String("schemas-atmos-manifest", "", "Specifies the path to a JSON schema file used to validate the structure and content of the Atmos manifest file")

config.DefaultConfigHandler.AddConfig(ValidateStacksCmd, &config.ConfigOptions{
FlagName: "schemas-atmos-manifest",
EnvVar: "ATMOS_SCHEMAS_ATMOS_MANIFEST",
Description: "Specifies the path to a JSON schema file used to validate the structure and content of the Atmos manifest file",
Key: "schemas.atmos.manifest",
DefaultValue: "",
})
validateCmd.AddCommand(ValidateStacksCmd)
}
8 changes: 8 additions & 0 deletions cmd/vendor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"github.com/cloudposse/atmos/pkg/config"
"github.com/spf13/cobra"
)

Expand All @@ -14,5 +15,12 @@ var vendorCmd = &cobra.Command{
}

func init() {
config.DefaultConfigHandler.AddConfig(vendorCmd, &config.ConfigOptions{
FlagName: "vendor-base-path",
EnvVar: "ATMOS_VENDOR_BASE_PATH",
Description: "Base path for vendored dependencies.",
Key: "vendor.base_path",
DefaultValue: "",
})
RootCmd.AddCommand(vendorCmd)
}
Loading