Documentation
¶
Overview ¶
Package config is a generated GoMock package.
Index ¶
- Constants
- Variables
- func AtmosConfigAbsolutePaths(atmosConfig *schema.AtmosConfiguration) error
- func EarlyConfigAndStacksInfoFromArgs(args []string) schema.ConfigAndStacksInfo
- func EnsureAdaptersInitialized()
- func FindAllStackConfigsInPaths(atmosConfig *schema.AtmosConfiguration, includeStackPaths []string, ...) ([]string, []string, error)
- func FindAllStackConfigsInPathsForStack(atmosConfig schema.AtmosConfiguration, stack string, ...) ([]string, []string, bool, error)
- func GetActiveProfiles(atmosConfig *schema.AtmosConfiguration) []string
- func GetCacheFilePath() (string, error)
- func GetContextFromVars(vars map[string]any) schema.Context
- func GetContextPrefix(stack string, context schema.Context, stackNamePattern string, ...) (string, error)
- func GetStackNameFromContextAndStackNamePattern(namespace string, tenant string, environment string, stage string, ...) (string, error)
- func HasExplicitProfile() bool
- func InferValueType(dotPath string) (string, bool)
- func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error)
- func LoadConfig(configAndStacksInfo *schema.ConfigAndStacksInfo) (schema.AtmosConfiguration, error)
- func LoadStackAuthDefaults(atmosConfig *schema.AtmosConfiguration) (map[string]bool, error)
- func LoadedConfigFiles() []string
- func MergeStackAuthDefaults(authConfig *schema.AuthConfig, stackDefaults map[string]bool)
- func NormalizeIdentityValue(value string) string
- func ParseProfilesFromEnvString(envValue string) []string
- func ParseProfilesFromOsArgs(args []string) []string
- func ProfileDefinesAuthConfig(atmosConfig *schema.AtmosConfiguration, profileName string) (bool, error)
- func ProfileDefinesIdentity(atmosConfig *schema.AtmosConfiguration, profileName, identityName string) (bool, error)
- func ProfilesWithAuthConfig(atmosConfig *schema.AtmosConfiguration) ([]string, error)
- func ProfilesWithIdentity(atmosConfig *schema.AtmosConfiguration, identityName string) ([]string, error)
- func RegisterImportAdapter(adapter ImportAdapter)
- func ReplaceContextTokens(context schema.Context, pattern string) string
- func ResetImportAdapterRegistry()
- func ResolveEditableConfigFile(atmosConfig *schema.AtmosConfiguration, override string) (string, error)
- func SaveCache(cfg CacheConfig) error
- func SearchAtmosConfig(path string) ([]string, error)
- func SearchConfigFile(configPath string, atmosConfig schema.AtmosConfiguration) (string, error)
- func SetBuiltinAdaptersInitializer(f func())
- func SetDefaultAdapter(adapter ImportAdapter)
- func ShouldCheckForUpdates(lastChecked int64, frequency string) bool
- func UpdateCache(update func(*CacheConfig)) error
- type CacheConfig
- type ConfigSelection
- type DefaultLoader
- type ImportAdapter
- type ImportAdapterRegistry
- type Loader
- type MockLoader
- type MockLoaderMockRecorder
- type ProfileLocation
- type ResolvedPaths
Constants ¶
const ( AtmosCommand = "atmos" CliConfigFileName = "atmos" DotCliConfigFileName = ".atmos" // AtmosEnvVarNamespace is the canonical Viper environment-variable // namespace for Atmos. This is the value passed to viper.SetEnvPrefix and // is the single source of truth for "what counts as an Atmos environment // variable" anywhere in the codebase. // // Use AtmosEnvVarPrefix when you need the namespace as an env-var key // prefix (i.e., the namespace followed by an underscore). AtmosEnvVarNamespace = "ATMOS" // AtmosEnvVarPrefix is the prefix used to identify Atmos-controlled // environment variables (ATMOS_PROFILE, ATMOS_CLI_CONFIG_PATH, // ATMOS_BASE_PATH, etc.). Always equal to AtmosEnvVarNamespace + "_" // — see TestAtmosEnvVarPrefixMatchesNamespace for the build-time // invariant. AtmosEnvVarPrefix = AtmosEnvVarNamespace + "_" SystemDirConfigFilePath = "/usr/local/etc/atmos" WindowsAppDataEnvVar = "LOCALAPPDATA" // Config file names for local configuration detection. AtmosConfigFileName = "atmos.yaml" DotAtmosConfigFileName = ".atmos.yaml" // Config directory names for local configuration detection. AtmosConfigDirName = ".atmos" AtmosDefaultImportsDirName = "atmos.d" DotAtmosDefaultImportsDirName = ".atmos.d" // GlobalOptionsFlag is a custom flag to specify helmfile `GLOBAL OPTIONS` // https://github.com/roboll/helmfile#cli-reference GlobalOptionsFlag = "--global-options" TerraformCommandFlag = "--terraform-command" TerraformDirFlag = "--terraform-dir" HelmfileCommandFlag = "--helmfile-command" HelmfileDirFlag = "--helmfile-dir" PackerCommandFlag = "--packer-command" PackerDirFlag = "--packer-dir" AnsibleCommandFlag = "--ansible-command" AnsibleDirFlag = "--ansible-dir" CliConfigDirFlag = "--config-dir" StackDirFlag = "--stacks-dir" BasePathFlag = "--base-path" VendorBasePathFlag = "--vendor-base-path" WorkflowDirFlag = "--workflows-dir" KubeConfigConfigFlag = "--kubeconfig-path" JsonSchemaDirFlag = "--schemas-jsonschema-dir" OpaDirFlag = "--schemas-opa-dir" CueDirFlag = "--schemas-cue-dir" AtmosManifestJsonSchemaFlag = "--schemas-atmos-manifest" DeployRunInitFlag = "--deploy-run-init" AutoGenerateBackendFileFlag = "--auto-generate-backend-file" AppendUserAgentFlag = "--append-user-agent" InitRunReconfigure = "--init-run-reconfigure" InitPassVars = "--init-pass-vars" PlanSkipPlanfile = "--skip-planfile" FromPlanFlag = "--from-plan" PlanFileFlag = "--planfile" DryRunFlag = "--dry-run" SkipInitFlag = "--skip-init" RedirectStdErrFlag = "--redirect-stderr" HelpFlag1 = "-h" HelpFlag2 = "--help" TerraformComponentType = "terraform" HelmfileComponentType = "helmfile" PackerComponentType = "packer" AnsibleComponentType = "ansible" ContainerComponentType = "container" EmulatorComponentType = "emulator" KubernetesComponentType = "kubernetes" HelmComponentType = "helm" ComponentVendorConfigFileName = "component.yaml" AtmosVendorConfigFileName = "vendor" ImportSectionName = "import" NameSectionName = "name" OverridesSectionName = "overrides" ProvidersSectionName = "providers" ProviderSectionName = "provider" HooksSectionName = "hooks" SecretsSectionName = "secrets" VarsSectionName = "vars" SettingsSectionName = "settings" VersionSectionName = "version" LocalsSectionName = "locals" EnvSectionName = "env" DependenciesSectionName = "dependencies" BackendSectionName = "backend" BackendTypeSectionName = "backend_type" RemoteStateBackendSectionName = "remote_state_backend" RemoteStateBackendTypeSectionName = "remote_state_backend_type" MetadataSectionName = "metadata" SourceSectionName = "source" ComponentSectionName = "component" ComponentsSectionName = "components" CommandSectionName = "command" TerraformSectionName = "terraform" HelmfileSectionName = "helmfile" PackerSectionName = "packer" PackerTemplateSectionName = "template" AnsibleSectionName = "ansible" KubernetesSectionName = "kubernetes" HelmSectionName = "helm" AnsiblePlaybookSectionName = "playbook" ContainerSectionName = "container" EmulatorSectionName = "emulator" AnsibleInventorySectionName = "inventory" WorkspaceSectionName = "workspace" AuthSectionName = "auth" RequiredVersionSectionName = "required_version" RequiredProvidersSectionName = "required_providers" GenerateSectionName = "generate" ProvisionSectionName = "provision" PathsSectionName = "paths" ManifestsSectionName = "manifests" RenderSectionName = "render" ValuesSectionName = "values" ValuesFilesSectionName = "values_files" PluginsSectionName = "plugins" ChartSectionName = "chart" RepositoriesSectionName = "repositories" InheritanceSectionName = "inheritance" IntegrationsSectionName = "integrations" GithubSectionName = "github" ProcessEnvSectionName = "process_env" CliArgsSectionName = "cli_args" RetrySectionName = "retry" TerraformCliVarsSectionName = "tf_cli_vars" TerraformCliArgsEnvSectionName = "env_tf_cli_args" TerraformCliVarsEnvSectionName = "env_tf_cli_vars" TestSectionName = "test" ComponentTypeSectionName = "component_type" OutputsSectionName = "outputs" StaticSectionName = "static" BackendTypeLocal = "local" BackendTypeS3 = "s3" BackendTypeAzurerm = "azurerm" BackendTypeGCS = "gcs" BackendTypeCloud = "cloud" ComponentPathSectionName = "component_path" InheritsSectionName = "inherits" AbstractSectionName = "abstract" LogsLevelFlag = "--logs-level" LogsFileFlag = "--logs-file" QueryFlag = "--query" AffectedFlag = "--affected" AllFlag = "--all" ProcessTemplatesFlag = "--process-templates" ProcessFunctionsFlag = "--process-functions" SkipFlag = "--skip" SettingsListMergeStrategyFlag = "--settings-list-merge-strategy" // Atmos Pro. AtmosProBaseUrlEnvVarName = "ATMOS_PRO_BASE_URL" AtmosProEndpointEnvVarName = "ATMOS_PRO_ENDPOINT" AtmosProTokenEnvVarName = "ATMOS_PRO_TOKEN" AtmosProWorkspaceIDEnvVarName = "ATMOS_PRO_WORKSPACE_ID" AtmosProRunIDEnvVarName = "ATMOS_PRO_RUN_ID" AtmosProDefaultBaseUrl = "https://atmos-pro.com" AtmosProDefaultEndpoint = "api/v1" UploadStatusFlag = "upload-status" TerraformDefaultWorkspace = "default" ComponentStr = "component" StackStr = "stack" // Auth flags. IdentityFlagName = "identity" // Flag name without prefix. IdentityFlag = "--identity" IdentityFlagShortName = "i" IdentityFlagShort = "-i" IdentityFlagSelectValue = "__SELECT__" // Special value when --identity is used without argument. IdentityFlagDisabledValue = "__DISABLED__" // Special value when --identity=false (skip authentication). // Cast recording flag. CastFlagName = "cast" CastFlag = "--cast" CastFlagAutoValue = "__AUTO__" CastEnvVarName = "ATMOS_CAST" // EKS/Helmfile flags. ClusterNameFlagName = "cluster-name" // Flag name without prefix. ClusterNameFlag = "--cluster-name" // Performance profiling flags. ProfilerEnabledFlag = "--profiler-enabled" ProfilerHostFlag = "--profiler-host" ProfilerPortFlag = "--profiler-port" ProfilerFileFlag = "--profiler-file" ProfilerTypeFlag = "--profiler-type" HeatmapFlag = "--heatmap" HeatmapModeFlag = "--heatmap-mode" // AtmosProfileFlag is the CLI flag for specifying Atmos profiles. AtmosProfileFlag = "--profile" // SliceSeparator is the separator used for splitting comma-separated strings into slices. SliceSeparator = "," )
const ( LOCAL importTypes = 0 REMOTE importTypes = 1 ADAPTER importTypes = 2 )
const (
// AtmosCliConfigPathEnvVar is the environment variable name for CLI config path.
AtmosCliConfigPathEnvVar = "ATMOS_CLI_CONFIG_PATH"
)
const (
// CacheDirPermissions is the default permission for cache directory (read/write/execute for owner, read/execute for group and others).
CacheDirPermissions = 0o755
)
const (
// MaximumImportLvL defines the maximum import level allowed.
MaximumImportLvL = 10
)
Variables ¶
var ErrExecuteYamlFunctions = errors.New("failed to execute yaml function")
var ErrNoEditableConfig = errors.New("could not locate an editable atmos.yaml; pass --config to target a specific file")
ErrNoEditableConfig is returned when an editable atmos.yaml file cannot be located.
var (
ErrResolvedConfigFileNotFound = errors.New("resolved config file not found")
)
var (
NotFound = errors.New("\n'atmos.yaml' CLI config was not found in any of the searched paths: system dir, home dir, current dir, ENV vars." +
"\nYou can download a sample config and adapt it to your requirements from " +
"https://raw.githubusercontent.com/cloudposse/atmos/main/examples/quick-start-advanced/atmos.yaml")
)
Functions ¶
func AtmosConfigAbsolutePaths ¶ added in v1.193.0
func AtmosConfigAbsolutePaths(atmosConfig *schema.AtmosConfiguration) error
func EarlyConfigAndStacksInfoFromArgs ¶ added in v1.223.0
func EarlyConfigAndStacksInfoFromArgs(args []string) schema.ConfigAndStacksInfo
EarlyConfigAndStacksInfoFromArgs builds the initial config-selection values before Cobra and Viper have parsed global flags. It is used by cmd/root.go before the first InitCliConfig call so custom commands and aliases are loaded from the selected config location.
func EnsureAdaptersInitialized ¶ added in v1.204.0
func EnsureAdaptersInitialized()
EnsureAdaptersInitialized ensures all built-in adapters are registered. This is called automatically by FindImportAdapter.
func FindAllStackConfigsInPaths ¶ added in v1.4.13
func FindAllStackConfigsInPaths( atmosConfig *schema.AtmosConfiguration, includeStackPaths []string, excludeStackPaths []string, ) ([]string, []string, error)
FindAllStackConfigsInPaths finds all stack manifests in the paths specified by globs.
func FindAllStackConfigsInPathsForStack ¶ added in v1.4.13
func FindAllStackConfigsInPathsForStack( atmosConfig schema.AtmosConfiguration, stack string, includeStackPaths []string, excludeStackPaths []string, ) ([]string, []string, bool, error)
FindAllStackConfigsInPathsForStack finds all stack manifests in the paths specified by globs for the provided stack.
func GetActiveProfiles ¶ added in v1.218.0
func GetActiveProfiles(atmosConfig *schema.AtmosConfiguration) []string
GetActiveProfiles returns the profiles currently active for this command invocation, using the same resolution order as LoadConfig:
- --profile flag (explicit).
- ATMOS_PROFILE environment variable (explicit).
- profiles.default from atmos.yaml (implicit).
Returns nil when no profile is active.
func GetCacheFilePath ¶ added in v1.127.0
GetCacheFilePath returns the filesystem path to the Atmos cache file. It respects ATMOS_XDG_CACHE_HOME and XDG_CACHE_HOME environment variables for cache directory location. Returns an error if xdg.GetXDGCacheDir fails or if the cache directory cannot be created.
func GetContextFromVars ¶ added in v1.3.5
GetContextFromVars creates a context object from the provided variables.
func GetContextPrefix ¶ added in v1.3.5
func GetContextPrefix(stack string, context schema.Context, stackNamePattern string, stackFile string) (string, error)
GetContextPrefix calculates context prefix from the context.
func GetStackNameFromContextAndStackNamePattern ¶ added in v1.4.9
func GetStackNameFromContextAndStackNamePattern( namespace string, tenant string, environment string, stage string, stackNamePattern string, ) (string, error)
GetStackNameFromContextAndStackNamePattern calculates stack name from the provided context using the provided stack name pattern.
func HasExplicitProfile ¶ added in v1.216.0
func HasExplicitProfile() bool
HasExplicitProfile reports whether the user explicitly selected a profile via the `--profile` flag or the `ATMOS_PROFILE` environment variable.
An implicit default from `profiles.default` is NOT considered explicit — this distinction gates the interactive identity fallback (see PRD: interactive-profile-suggestion). We never override an explicit user choice, but we do prompt when the only reason a profile loaded was the implicit default.
func InferValueType ¶ added in v1.223.0
InferValueType walks a dot-notation path (e.g. "mcp.enabled") against schema.AtmosConfiguration's struct tags to determine the atmosyaml.TypeXXX `atmos config set` should use, so a user setting a known bool/int/float field doesn't need to pass --type explicitly.
Returns ("", false) when the path can't be resolved against the schema -- e.g. a free-form section like vars, a typo, or a path containing an array index ("foo[0].bar", not yet supported). Callers should fall back to their own default (atmosyaml.TypeString) in that case, not treat it as an error: atmos.yaml routinely holds content the static schema doesn't model.
func InitCliConfig ¶ added in v1.10.0
func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error)
InitCliConfig finds and merges CLI configurations in the following order: system dir, home dir, current dir, ENV vars, command-line arguments https://dev.to/techschoolguru/load-config-from-file-environment-variables-in-golang-with-viper-2j2d https://medium.com/@bnprashanth256/reading-configuration-files-and-environment-variables-in-go-golang-c2607f912b63
NOTE: Global flags (like --profile) must be synced to Viper before calling this function. This is done by syncGlobalFlagsToViper() in cmd/root.go PersistentPreRun.
TODO: Change configAndStacksInfo to pointer. Temporarily suppressing gocritic warnings; refactoring InitCliConfig would require extensive changes.
func LoadConfig ¶ added in v1.167.0
func LoadConfig(configAndStacksInfo *schema.ConfigAndStacksInfo) (schema.AtmosConfiguration, error)
LoadConfig loads the Atmos configuration from multiple sources in order of precedence: * Embedded atmos.yaml (`atmos/pkg/config/atmos.yaml`) * System dir (`/usr/local/etc/atmos` on Linux, `%LOCALAPPDATA%/atmos` on Windows). * Home directory (~/.atmos). * Current working directory. * ENV vars. * Command-line arguments.
NOTE: Global flags (like --profile) must be synced to Viper before calling this function. This is done by syncGlobalFlagsToViper() in cmd/root.go PersistentPreRun.
func LoadStackAuthDefaults ¶ added in v1.201.0
func LoadStackAuthDefaults(atmosConfig *schema.AtmosConfiguration) (map[string]bool, error)
LoadStackAuthDefaults loads stack configuration files for auth identity defaults. This is a lightweight load that doesn't process templates or YAML functions. It returns a map of identity names to their default status found in stack configs.
The loader looks for:
auth:
identities:
<identity-name>:
default: true
This function is used to resolve stack-level default identities before full stack processing, solving the chicken-and-egg problem where we need to know the default identity to authenticate, but stack configs are only loaded after authentication is configured.
When multiple stack files define DIFFERENT default identities, it means each stack has its own default that only applies when that stack is targeted. Since this function runs before stack resolution (we don't know the target stack yet), conflicting defaults are discarded to avoid false "multiple default identities" errors. The per-stack default will be resolved after full stack processing. See https://github.com/cloudposse/atmos/issues/2072.
func LoadedConfigFiles ¶ added in v1.223.0
func LoadedConfigFiles() []string
LoadedConfigFiles returns the physical config files merged during the most recent LoadConfig call. Embedded defaults and runtime/env overrides are not included.
func MergeStackAuthDefaults ¶ added in v1.201.0
func MergeStackAuthDefaults(authConfig *schema.AuthConfig, stackDefaults map[string]bool)
MergeStackAuthDefaults merges stack-level auth defaults into the auth config. Stack defaults have HIGHER priority than atmos.yaml defaults (following Atmos inheritance model). This means stack config can override the default identity set in atmos.yaml.
func NormalizeIdentityValue ¶ added in v1.204.0
NormalizeIdentityValue converts boolean false representations to the disabled sentinel value. Recognizes: false, False, FALSE, 0, no, No, NO, off, Off, OFF. All other values are returned unchanged.
This function is used to normalize identity values from: - CLI flags (--identity=false) - Environment variables (ATMOS_IDENTITY=false) - Configuration files
When a false value is detected, it returns IdentityFlagDisabledValue ("__DISABLED__") which signals to the authentication system to skip authentication entirely.
func ParseProfilesFromEnvString ¶ added in v1.223.0
ParseProfilesFromEnvString parses comma-separated profiles from an environment variable value. Trims whitespace and filters empty entries.
func ParseProfilesFromOsArgs ¶ added in v1.223.0
ParseProfilesFromOsArgs parses --profile flags from os.Args using pflag. This is used both as a fallback for commands with DisableFlagParsing=true (terraform, helmfile, packer) and for early profile extraction before Cobra parses flags (same pattern as --chdir). Uses pflag's StringSlice parser to handle all syntax variations correctly.
func ProfileDefinesAuthConfig ¶ added in v1.216.0
func ProfileDefinesAuthConfig(atmosConfig *schema.AtmosConfiguration, profileName string) (bool, error)
ProfileDefinesAuthConfig reports whether the named profile defines any auth configuration — either a non-empty auth.identities map or a non-empty auth.providers map. Used by the identity-agnostic fallback in auth commands (login, exec, shell, env, console, whoami) when the base atmos.yaml has no usable auth config at all.
Uses a scoped Viper instance — does NOT mutate global config.
func ProfileDefinesIdentity ¶ added in v1.216.0
func ProfileDefinesIdentity(atmosConfig *schema.AtmosConfiguration, profileName, identityName string) (bool, error)
ProfileDefinesIdentity reports whether the named profile defines the given identity in its auth.identities section. Match is case-insensitive.
Uses a scoped Viper instance — does NOT mutate global config. Returns false + nil when the profile exists but does not define the identity. Returns false + error when the profile cannot be located or loaded.
func ProfilesWithAuthConfig ¶ added in v1.216.0
func ProfilesWithAuthConfig(atmosConfig *schema.AtmosConfiguration) ([]string, error)
ProfilesWithAuthConfig returns the names of all profiles that define any auth configuration (identities or providers). The returned list is sorted alphabetically for deterministic output.
Errors loading individual profiles are logged at debug level and that profile is skipped — a single broken profile should not hide the others.
func ProfilesWithIdentity ¶ added in v1.216.0
func ProfilesWithIdentity(atmosConfig *schema.AtmosConfiguration, identityName string) ([]string, error)
ProfilesWithIdentity returns the names of all profiles that define the given identity in their auth.identities section. The returned list is sorted alphabetically for deterministic output. Uses case-insensitive matching.
Errors loading individual profiles are logged at debug level and that profile is skipped — a single broken profile should not hide the others.
func RegisterImportAdapter ¶ added in v1.204.0
func RegisterImportAdapter(adapter ImportAdapter)
RegisterImportAdapter adds an import adapter to the registry. Adapters are matched in registration order, so register more specific schemes before less specific ones.
Call this from init() functions to self-register adapters.
func ReplaceContextTokens ¶ added in v1.3.5
ReplaceContextTokens replaces context tokens in the provided pattern and returns a string with all the tokens replaced.
func ResetImportAdapterRegistry ¶ added in v1.204.0
func ResetImportAdapterRegistry()
ResetImportAdapterRegistry clears all registered adapters. This is intended for testing only.
func ResolveEditableConfigFile ¶ added in v1.223.0
func ResolveEditableConfigFile(atmosConfig *schema.AtmosConfiguration, override string) (string, error)
ResolveEditableConfigFile returns the path to the atmos.yaml file that config edits should target. Because atmos.yaml can be merged from several locations, edits operate on a single concrete file chosen by this precedence:
- an explicit override (the --config flag or ATMOS_CLI_CONFIG_PATH);
- atmos.yaml / .atmos.yaml in the current working directory;
- atmos.yaml / .atmos.yaml at the git repository root.
It returns ErrNoEditableConfig if none of these exist, so callers can prompt the user to create one or pass --config explicitly.
func SaveCache ¶ added in v1.127.0
func SaveCache(cfg CacheConfig) error
SaveCache writes the provided cache configuration to the cache file atomically. The function acquires an exclusive lock to prevent concurrent writes and ensures data consistency across multiple processes.
Parameters:
- cfg: The CacheConfig to save to disk.
Returns an error if the cache file cannot be created or written. Callers can check for specific failure types using errors.Is() with the following sentinel errors:
- ErrCacheMarshal: Failed to marshal cache content to YAML
- ErrCacheWrite: Failed to write the cache file
func SearchAtmosConfig ¶ added in v1.167.0
SearchAtmosConfig searches for a config file in path. The path is directory, file or a pattern.
func SearchConfigFile ¶ added in v1.117.0
func SearchConfigFile(configPath string, atmosConfig schema.AtmosConfiguration) (string, error)
func SetBuiltinAdaptersInitializer ¶ added in v1.204.0
func SetBuiltinAdaptersInitializer(f func())
SetBuiltinAdaptersInitializer sets the function used to initialize built-in adapters. This should be called from the adapters package's init() function.
func SetDefaultAdapter ¶ added in v1.204.0
func SetDefaultAdapter(adapter ImportAdapter)
SetDefaultAdapter sets the fallback adapter for paths without recognized schemes. This is typically the LocalAdapter for filesystem paths.
func ShouldCheckForUpdates ¶ added in v1.127.0
ShouldCheckForUpdates determines whether an update check is due based on the configured frequency and the time of the last check.
func UpdateCache ¶ added in v1.192.0
func UpdateCache(update func(*CacheConfig)) error
UpdateCache atomically updates the cache file by acquiring a lock, loading the current configuration, applying the update function, and saving the result. This prevents race conditions when multiple processes try to update different fields simultaneously.
Parameters:
- update: A function that modifies the provided CacheConfig in place.
Returns an error if the cache file cannot be accessed, read, or written. Callers can check for specific failure types using errors.Is() with the following sentinel errors:
- ErrCacheRead: Failed to read the cache file
- ErrCacheUnmarshal: Failed to unmarshal cache content
- ErrCacheWrite: Failed to write the cache file
- ErrCacheMarshal: Failed to marshal cache content
Types ¶
type CacheConfig ¶ added in v1.127.0
type CacheConfig struct {
LastChecked int64 `mapstructure:"last_checked" yaml:"last_checked"`
InstallationId string `mapstructure:"installation_id" yaml:"installation_id"`
TelemetryDisclosureShown bool `mapstructure:"telemetry_disclosure_shown" yaml:"telemetry_disclosure_shown"`
BrowserSessionWarningShown bool `mapstructure:"browser_session_warning_shown" yaml:"browser_session_warning_shown"`
}
CacheConfig holds persistent application state for version checks, telemetry preferences, and session-level warnings.
func LoadCache ¶ added in v1.127.0
func LoadCache() (CacheConfig, error)
LoadCache loads the cache configuration from the cache file. Uses platform-specific file locking to prevent concurrent read/write issues.
type ConfigSelection ¶ added in v1.223.0
ConfigSelection holds the config-selection flags parsed early from os.Args before Cobra is initialized (same pattern as profile early-parsing).
func ConfigSelectionFromEnv ¶ added in v1.223.0
func ConfigSelectionFromEnv() ConfigSelection
ConfigSelectionFromEnv reads config-selection values from environment variables as fallbacks when not provided via CLI flags.
func ParseConfigSelectionFromOsArgs ¶ added in v1.223.0
func ParseConfigSelectionFromOsArgs(args []string) ConfigSelection
ParseConfigSelectionFromOsArgs parses --base-path, --config, and --config-path flags from os.Args using pflag. This is used for early extraction before Cobra parses flags, so that InitCliConfig receives the correct config location.
type DefaultLoader ¶ added in v1.195.0
type DefaultLoader struct{}
DefaultLoader implements Loader using real config operations.
func (*DefaultLoader) InitCliConfig ¶ added in v1.195.0
func (d *DefaultLoader) InitCliConfig(configAndStacksInfo *schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error)
InitCliConfig initializes the CLI configuration.
type ImportAdapter ¶ added in v1.204.0
type ImportAdapter interface {
// Schemes returns the URL schemes/prefixes this adapter handles.
// Examples: []string{"http://", "https://", "git::", "github.com/"}
//
// Return nil or empty slice for the default adapter (LocalAdapter),
// which handles paths without recognized schemes.
Schemes() []string
// Resolve processes an import path and returns resolved file paths.
//
// Parameters:
// - ctx: Context for cancellation and deadlines
// - importPath: The full import path (e.g., "git::https://github.com/org/repo//path")
// - basePath: The base path for resolving relative references
// - tempDir: Temporary directory for downloaded/generated files
// - currentDepth: Current recursion depth for nested imports
// - maxDepth: Maximum allowed recursion depth
// - atmosConfig: The Atmos configuration being assembled, so adapters can honor
// auth settings (e.g., GitHub token injection and the Atmos Pro credential
// broker) when fetching remote imports. May be nil.
//
// Returns:
// - []ResolvedPaths: List of resolved file paths to merge
// - error: Any error encountered during resolution
//
// Adapters are responsible for handling nested imports by calling
// processImports() recursively when the resolved config contains
// further import statements.
Resolve(
ctx context.Context,
importPath string,
basePath string,
tempDir string,
currentDepth int,
maxDepth int,
atmosConfig *schema.AtmosConfiguration,
) ([]ResolvedPaths, error)
}
ImportAdapter handles import resolution for specific URL schemes. All import handling goes through the adapter registry - there are no special cases.
Built-in adapters:
- GoGetterAdapter: http://, https://, git::, s3::, oci://, github.com/, etc.
- LocalAdapter: Local filesystem paths (default fallback)
- MockAdapter: mock:// scheme for testing
Future adapters:
- TerragruntAdapter: terragrunt:// for HCL→YAML transformation
func FindImportAdapter ¶ added in v1.204.0
func FindImportAdapter(importPath string) ImportAdapter
FindImportAdapter returns the appropriate adapter for the given import path. It checks registered adapters' schemes in order and returns the first match. If no adapter matches, returns the default adapter (LocalAdapter).
This function always returns an adapter - never nil.
func GetDefaultAdapter ¶ added in v1.204.0
func GetDefaultAdapter() ImportAdapter
GetDefaultAdapter returns the current default adapter. This is intended for testing and debugging.
func GetRegisteredAdapters ¶ added in v1.204.0
func GetRegisteredAdapters() []ImportAdapter
GetRegisteredAdapters returns a copy of all registered adapters. This is intended for testing and debugging.
type ImportAdapterRegistry ¶ added in v1.204.0
type ImportAdapterRegistry struct {
// contains filtered or unexported fields
}
ImportAdapterRegistry manages import adapter registration and lookup. Thread-safe for concurrent access.
type Loader ¶ added in v1.195.0
type Loader interface {
// InitCliConfig initializes the CLI configuration.
InitCliConfig(configAndStacksInfo *schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error)
}
Loader defines operations for loading Atmos configuration. This interface allows mocking of config loading in tests.
type MockLoader ¶ added in v1.195.0
type MockLoader struct {
// contains filtered or unexported fields
}
MockLoader is a mock of Loader interface.
func NewMockLoader ¶ added in v1.195.0
func NewMockLoader(ctrl *gomock.Controller) *MockLoader
NewMockLoader creates a new mock instance.
func (*MockLoader) EXPECT ¶ added in v1.195.0
func (m *MockLoader) EXPECT() *MockLoaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLoader) InitCliConfig ¶ added in v1.195.0
func (m *MockLoader) InitCliConfig(configAndStacksInfo *schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error)
InitCliConfig mocks base method.
type MockLoaderMockRecorder ¶ added in v1.195.0
type MockLoaderMockRecorder struct {
// contains filtered or unexported fields
}
MockLoaderMockRecorder is the mock recorder for MockLoader.
func (*MockLoaderMockRecorder) InitCliConfig ¶ added in v1.195.0
func (mr *MockLoaderMockRecorder) InitCliConfig(configAndStacksInfo, processStacks any) *gomock.Call
InitCliConfig indicates an expected call of InitCliConfig.
type ProfileLocation ¶ added in v1.199.0
type ProfileLocation struct {
Path string // Absolute path to profile directory.
Type string // "configurable", "project-hidden", "xdg", "project".
Precedence int // Lower number = higher precedence.
}
ProfileLocation represents a location where profiles can be stored.
type ResolvedPaths ¶ added in v1.167.0
type ResolvedPaths struct {
FilePath string // Absolute path to the resolved file.
ImportPaths string // Original import path from atmos config.
ImportType importTypes // Type of import (LOCAL, REMOTE, or ADAPTER).
}
ResolvedPaths represents a resolved import path with its file location and type.
func ProcessImportsFromAdapter ¶ added in v1.204.0
func ProcessImportsFromAdapter(atmosConfig *schema.AtmosConfiguration, basePath string, importPaths []string, tempDir string, currentDepth, maxDepth int) ([]ResolvedPaths, error)
ProcessImportsFromAdapter is the public entry point for adapters to process nested imports. Adapters should call this when they discover nested import statements in resolved configs. The atmosConfig parameter is threaded through so nested remote imports honor auth settings (GitHub token injection and the Atmos Pro credential broker); it may be nil.
Source Files
¶
- auth_realm.go
- cache.go
- config.go
- config_edit.go
- const.go
- default.go
- git_root.go
- identity.go
- import_adapter.go
- import_adapter_registry.go
- imports.go
- interface.go
- load.go
- load_config_args.go
- mock_interface.go
- process_yaml.go
- process_yaml_append.go
- process_yaml_git.go
- profiles.go
- schema_type.go
- stack_auth_loader.go
- utils.go
- xdg_test_helper.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adapters contains import adapter implementations for the config package.
|
Package adapters contains import adapter implementations for the config package. |
|
Package casemap provides utilities for preserving original case of YAML map keys.
|
Package casemap provides utilities for preserving original case of YAML map keys. |