config

package
v1.172.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

README

Import Config

flowchart TD
    A["Load Configuration File"] --> B{"Import Section Exists?"}
    
    B -- Yes --> C["Process Imports in Order"]
    C --> D{"Import Type?"}
    D --> E["Remote URL"]
    D --> F["Specific Path"]
    D --> G["Wildcard Globs"]
    
    E --> H["Fetch Config from Remote URL"]
    F --> I["Read Config from Filesystem"]
    G --> I["Read Config from Filesystem"]
    
    H --> J["Call Load Configuration File (Recursively)"]
    I --> J["Call Load Configuration File (Recursively)"]
    
    J --> L["Deep Merge with Current Config in Memory"]
    L --> K{"More Imports to Process?"}
    K -- Yes --> C
    K -- No --> M["Configuration Processing Complete"]
    
    %% Loopback for recursion
    J -.-> A

    %% Styling for clarity
    style A fill:#A8DADC,stroke:#1D3557,stroke-width:2px,color:#000000
    style B fill:#F4A261,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style C fill:#457B9D,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style D fill:#A8DADC,stroke:#1D3557,stroke-width:2px,color:#000000
    style E fill:#E63946,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style F fill:#E63946,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style G fill:#E63946,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style H fill:#A8DADC,stroke:#1D3557,stroke-width:2px,color:#000000
    style I fill:#A8DADC,stroke:#1D3557,stroke-width:2px,color:#000000
    style J fill:#F4A261,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style L fill:#457B9D,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style K fill:#F4A261,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    style M fill:#1D3557,stroke:#1D3557,stroke-width:2px,color:#FFFFFF
    
    classDef recursion stroke-dasharray: 5 5;

Documentation

Index

Constants

View Source
const (
	CliConfigFileName    = "atmos"
	DotCliConfigFileName = ".atmos"

	SystemDirConfigFilePath = "/usr/local/etc/atmos"
	WindowsAppDataEnvVar    = "LOCALAPPDATA"

	// 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"
	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"

	FromPlanFlag       = "--from-plan"
	PlanFileFlag       = "--planfile"
	DryRunFlag         = "--dry-run"
	SkipInitFlag       = "--skip-init"
	RedirectStdErrFlag = "--redirect-stderr"

	HelpFlag1 = "-h"
	HelpFlag2 = "--help"

	TerraformComponentType = "terraform"
	HelmfileComponentType  = "helmfile"

	ComponentVendorConfigFileName = "component.yaml"
	AtmosVendorConfigFileName     = "vendor"

	ImportSectionName                 = "import"
	OverridesSectionName              = "overrides"
	ProvidersSectionName              = "providers"
	HooksSectionName                  = "hooks"
	VarsSectionName                   = "vars"
	SettingsSectionName               = "settings"
	EnvSectionName                    = "env"
	BackendSectionName                = "backend"
	BackendTypeSectionName            = "backend_type"
	RemoteStateBackendSectionName     = "remote_state_backend"
	RemoteStateBackendTypeSectionName = "remote_state_backend_type"
	MetadataSectionName               = "metadata"
	ComponentSectionName              = "component"
	ComponentsSectionName             = "components"
	CommandSectionName                = "command"
	TerraformSectionName              = "terraform"
	HelmfileSectionName               = "helmfile"
	WorkspaceSectionName              = "workspace"
	InheritanceSectionName            = "inheritance"
	IntegrationsSectionName           = "integrations"
	GithubSectionName                 = "github"
	TerraformCliVarsSectionName       = "tf_cli_vars"
	CliArgsSectionName                = "cli_args"

	LogsLevelFlag = "--logs-level"
	LogsFileFlag  = "--logs-file"

	QueryFlag = "--query"

	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"
	AtmosProDefaultBaseUrl     = "https://app.cloudposse.com"
	AtmosProDefaultEndpoint    = "api"

	// Atmos YAML functions
	AtmosYamlFuncExec            = "!exec"
	AtmosYamlFuncTemplate        = "!template"
	AtmosYamlFuncTerraformOutput = "!terraform.output"
	AtmosYamlFuncEnv             = "!env"

	TerraformDefaultWorkspace = "default"
)
View Source
const (
	LOCAL  importTypes = 0
	REMOTE importTypes = 1
)
View Source
const MaximumImportLvL = 10

Variables

View Source
var (
	ErrBasePath           = errors.New("base path required to process imports")
	ErrTempDir            = errors.New("temporary directory required to process imports")
	ErrResolveLocal       = errors.New("failed to resolve local import path")
	ErrSourceDestination  = errors.New("source and destination cannot be nil")
	ErrImportPathRequired = errors.New("import path required to process imports")
	ErrNOFileMatchPattern = errors.New("no files matching patterns found")
	ErrMaxImportDepth     = errors.New("maximum import depth reached")
)
View Source
var (
	ErrExpectedDirOrPattern        = errors.New("--config-path expected directory found file")
	ErrFileNotFound                = errors.New("file not found")
	ErrExpectedFile                = errors.New("--config expected file found directory")
	ErrAtmosArgConfigNotFound      = errors.New("atmos configuration not found")
	ErrAtmosFilesDIrConfigNotFound = errors.New("`atmos.yaml` or `.atmos.yaml` configuration  file not found on directory")
)
View Source
var ErrAtmosDIrConfigNotFound = errors.New("atmos config directory not found")
View Source
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 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 GetCacheFilePath added in v1.127.0

func GetCacheFilePath() (string, error)

func GetContextFromVars added in v1.3.5

func GetContextFromVars(vars map[string]any) schema.Context

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 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

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)

* 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.

func ReplaceContextTokens added in v1.3.5

func ReplaceContextTokens(context schema.Context, pattern string) string

ReplaceContextTokens replaces context tokens in the provided pattern and returns a string with all the tokens replaced

func SaveCache added in v1.127.0

func SaveCache(cfg CacheConfig) error

func SaveCache2 added in v1.127.0

func SaveCache2(cfg CacheConfig) error

func SearchAtmosConfig added in v1.167.0

func SearchAtmosConfig(path string) ([]string, error)

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 ShouldCheckForUpdates added in v1.127.0

func ShouldCheckForUpdates(lastChecked int64, frequency string) bool

Types

type CacheConfig added in v1.127.0

type CacheConfig struct {
	LastChecked int64 `mapstructure:"last_checked"`
}

func LoadCache added in v1.127.0

func LoadCache() (CacheConfig, error)

type ResolvedPaths added in v1.167.0

type ResolvedPaths struct {
	// contains filtered or unexported fields
}

import Resolved Paths.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL