Documentation
¶
Index ¶
- Constants
- Variables
- func AddIdentityCompletion(cmd *cobra.Command)
- func AddStackCompletion(cmd *cobra.Command)
- func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration)
- func Cleanup()
- func ComponentsArgCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func Contains(slice []string, target string) bool
- func Execute() error
- func ExecuteListInstancesCmd(cmd *cobra.Command, args []string) error
- type AtmosValidateOption
- type ExampleContent
- type MetadataParams
- type ProcessingOptions
- type SettingsParams
- type ValidateConfig
Constants ¶
const (
ErrFmtWrapErr = "%w: %v" // Format for wrapping errors.
)
Error format strings.
const (
IdentityFlagName = "identity"
)
Variables ¶
var ( ErrInvalidOutputType = fmt.Errorf("invalid output type specified. Valid values are 'list', 'map', and 'all'") ErrInvalidFormat = fmt.Errorf("invalid format specified. Valid values are 'yaml' and 'json'") )
var ( ErrGettingCommonFlags = pkgerrors.New("error getting common flags") ErrGettingAbstractFlag = pkgerrors.New("error getting abstract flag") ErrGettingVarsFlag = pkgerrors.New("error getting vars flag") ErrInitializingCLIConfig = pkgerrors.New("error initializing CLI config") ErrDescribingStacks = pkgerrors.New("error describing stacks") ErrComponentNameRequired = pkgerrors.New("component name is required") ErrInvalidArguments = pkgerrors.New("invalid arguments: the command requires one argument 'component'") )
var RootCmd = &cobra.Command{ Use: "atmos", Short: "Universal Tool for DevOps and Cloud Automation", Long: `Atmos is a universal tool for DevOps and cloud automation used for provisioning, managing and orchestrating workflows across various toolchains`, FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, PersistentPreRun: func(cmd *cobra.Command, args []string) { isHelpCommand := cmd.Name() == "help" helpFlag := cmd.Flags().Changed("help") isHelpRequested := isHelpCommand || helpFlag if isHelpRequested { cmd.SilenceUsage = false cmd.SilenceErrors = false } else { cmd.SilenceUsage = true cmd.SilenceErrors = true } if err := processChdirFlag(cmd); err != nil { errUtils.CheckErrorPrintAndExit(err, "", "") } configAndStacksInfo := schema.ConfigAndStacksInfo{} if bp, _ := cmd.Flags().GetString("base-path"); bp != "" { configAndStacksInfo.AtmosBasePath = bp } if cfgFiles, _ := cmd.Flags().GetStringSlice("config"); len(cfgFiles) > 0 { configAndStacksInfo.AtmosConfigFilesFromArg = cfgFiles } if cfgDirs, _ := cmd.Flags().GetStringSlice("config-path"); len(cfgDirs) > 0 { configAndStacksInfo.AtmosConfigDirsFromArg = cfgDirs } tmpConfig, err := cfg.InitCliConfig(configAndStacksInfo, false) if err != nil { if errors.Is(err, cfg.NotFound) { if !isHelpRequested { log.Warn(err.Error()) } } else { errUtils.CheckErrorPrintAndExit(err, "", "") } } if !isHelpRequested { if setupErr := setupProfiler(cmd, &tmpConfig); setupErr != nil { errUtils.CheckErrorPrintAndExit(setupErr, "Failed to setup profiler", "") } } if cmd.Flags().Changed("version") { if versionFlag, err := cmd.Flags().GetBool("version"); err == nil && versionFlag { versionErr := e.NewVersionExec(&tmpConfig).Execute(false, "") if versionErr != nil { errUtils.CheckErrorPrintAndExit(versionErr, "", "") } errUtils.OsExit(0) return } } if showHeatmap, _ := cmd.Flags().GetBool("heatmap"); showHeatmap { perf.EnableTracking(true) } if !isCompletionCommand(cmd) && err == nil { telemetry.PrintTelemetryDisclosure() } }, PersistentPostRun: func(cmd *cobra.Command, args []string) { if profilerServer != nil { if stopErr := profilerServer.Stop(); stopErr != nil { log.Error("Failed to stop profiler", "error", stopErr) } } if perf.IsTrackingEnabled() { heatmapMode, _ := cmd.Flags().GetString("heatmap-mode") if heatmapMode == "" { heatmapMode = "bar" } if err := displayPerformanceHeatmap(cmd, heatmapMode); err != nil { log.Error("Failed to display performance heatmap", "error", err) } } }, RunE: func(cmd *cobra.Command, args []string) error { checkAtmosConfig() fmt.Println() err := tuiUtils.PrintStyledText("ATMOS") if err != nil { return err } err = e.ExecuteAtmosCmd() return err }, }
RootCmd represents the base command when called without any subcommands.
var SupportedFormats = []string{"json", "bash", "dotenv"}
var ValidateSchemaCmd = &cobra.Command{ Use: "schema", Short: "Validate YAML files against JSON schemas defined in atmos.yaml", Long: `The validate schema command reads the ` + "`" + `schemas` + "`" + ` section of the atmos.yaml file and validates matching YAML files against their corresponding JSON schemas. Each entry under ` + "`" + `schemas` + "`" + ` should define: - ` + "`" + `schema` + "`" + `: The path to the JSON schema file. - ` + "`" + `matches` + "`" + `: A glob pattern that specifies which YAML files to validate. For every schema entry: - The JSON schema is loaded from the specified path. - All files matching the glob pattern are collected. - Each matching YAML file is parsed and converted to JSON. - The converted YAML is validated against the schema. This command helps ensure that configuration files follow a defined structure and are compliant with expected formats, reducing configuration drift and runtime errors. `, FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { checkAtmosConfig() schema := "" key := "" if len(args) > 0 { key = args[0] } if cmd.Flags().Changed("schemas-atmos-manifest") { schema, _ = cmd.Flags().GetString("schemas-atmos-manifest") } if key == "" && schema != "" { log.Error("key not provided for the schema to be used") errUtils.OsExit(1) } if err := exec.NewAtmosValidatorExecutor(&atmosConfig).ExecuteAtmosValidateSchemaCmd(key, schema); err != nil { if errors.Is(err, exec.ErrInvalidYAML) { errUtils.OsExit(1) } return err } return nil }, }
ValidateSchemaCmd represents the 'atmos validate schema' command.
This command reads the 'schemas' section from the atmos.yaml configuration file, where each schema entry specifies a JSON schema path and a glob pattern for matching YAML files.
For each entry:
- The JSON schema is loaded.
- All YAML files matching the glob pattern are discovered.
- Each YAML file is converted to JSON and validated against the schema.
This command ensures that configuration files conform to expected structures and helps catch errors early in the development or deployment process.
var ValidateStacksCmd = &cobra.Command{ Use: "stacks", Short: "Validate stack manifest configurations", Long: "This command validates the configuration of stack manifests in Atmos to ensure proper setup and compliance.", Example: "validate stacks", FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { checkAtmosConfig() err := exec.ExecuteValidateStacksCmd(cmd, args) if err != nil { return err } log.Info("All stacks validated successfully") return nil }, }
ValidateStacksCmd validates stacks
Functions ¶
func AddIdentityCompletion ¶ added in v1.195.0
AddIdentityCompletion registers shell completion for the identity flag if present on the command.
func AddStackCompletion ¶ added in v1.161.0
func CheckForAtmosUpdateAndPrintMessage ¶ added in v1.127.0
func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration)
CheckForAtmosUpdateAndPrintMessage checks if a version update is needed and prints a message if a newer version is found. It loads the cache, decides if it's time to check for updates, compares the current version to the latest available release, and if newer, prints the update message. It also updates the cache's timestamp after printing.
func Cleanup ¶ added in v1.192.0
func Cleanup()
Cleanup performs cleanup operations before the program exits. This should be called by main when the program is terminating.
func ComponentsArgCompletion ¶ added in v1.161.0
func Contains ¶ added in v1.137.0
Contains checks if a slice of strings contains an exact match for the target string.
Types ¶
type AtmosValidateOption ¶ added in v1.97.0
type AtmosValidateOption func(*ValidateConfig)
func WithStackValidation ¶ added in v1.97.0
func WithStackValidation(check bool) AtmosValidateOption
type ExampleContent ¶ added in v1.162.0
type MetadataParams ¶ added in v1.170.0
type MetadataParams struct {
CommonFlags *fl.CommonFlags
ProcessingFlags *fl.ProcessingFlags
ComponentFilter string
}
MetadataParams contains the parameters needed for listing metadata.
type ProcessingOptions ¶ added in v1.170.0
ProcessingOptions holds flags for processing templates and YAML functions.
type SettingsParams ¶ added in v1.170.0
type SettingsParams struct {
CommonFlags *fl.CommonFlags
ProcessingFlags *fl.ProcessingFlags
ComponentFilter string
}
SettingsParams contains all parameters needed for the list settings command.
type ValidateConfig ¶ added in v1.97.0
type ValidateConfig struct {
CheckStack bool
}
ValidateConfig holds configuration options for Atmos validation. CheckStack determines whether stack configuration validation should be performed.
Source Files
¶
- atlantis.go
- atlantis_generate.go
- atlantis_generate_repo_config.go
- auth.go
- auth_console.go
- auth_env.go
- auth_exec.go
- auth_list.go
- auth_login.go
- auth_logout.go
- auth_shell.go
- auth_user.go
- auth_validate.go
- auth_whoami.go
- aws.go
- aws_eks.go
- aws_eks_update_kubeconfig.go
- cmd_flag_utils.go
- cmd_utils.go
- completion.go
- describe.go
- describe_affected.go
- describe_component.go
- describe_config.go
- describe_dependents.go
- describe_stacks.go
- describe_workflows.go
- docs.go
- docs_generate.go
- helmfile.go
- helmfile_apply.go
- helmfile_destroy.go
- helmfile_diff.go
- helmfile_generate.go
- helmfile_generate_varfile.go
- helmfile_sync.go
- helmfile_version.go
- list.go
- list_components.go
- list_instances.go
- list_metadata.go
- list_settings.go
- list_stacks.go
- list_values.go
- list_vendor.go
- list_workflows.go
- markdown_help.go
- packer.go
- packer_build.go
- packer_init.go
- packer_inspect.go
- packer_output.go
- packer_validate.go
- packer_version.go
- pro.go
- pro_lock.go
- pro_unlock.go
- root.go
- support.go
- terraform.go
- terraform_commands.go
- terraform_generate.go
- terraform_generate_backend.go
- terraform_generate_backends.go
- terraform_generate_planfile.go
- terraform_generate_varfile.go
- terraform_generate_varfiles.go
- terraform_utils.go
- validate.go
- validate_component.go
- validate_editorconfig.go
- validate_schema.go
- validate_stacks.go
- vendor.go
- vendor_diff.go
- vendor_pull.go
- workflow.go