atmos.stack
The atmos.stack function runs atmos stack through the current Atmos executable. Use it to read and edit
component values in stack manifests with dot-notation paths, format manifests, and validate stacks from automation.
Usage
atmos.stack(
*positionals,
flags = {},
args = [],
working_directory = ...,
env = ...,
output = "stream",
check = True,
)
Get operations default to JSON and captured output. Read result.data for the typed
value or result.stdout for raw JSON. Use flags = {"format": "raw"} for unquoted
text and output = "stream" to display output live. Other operations retain
streaming output. See query defaults.
Subcommands
Pass the subcommand and any positional arguments as strings before the keyword arguments. The call
atmos.stack("get", "vars.location", flags = {"stack": "dev", "component": "station"}) runs
atmos stack get vars.location --stack=dev --component=station.
| Subcommand | Purpose |
|---|---|
get | Read a component-relative value from a stack. |
set | Set a component-relative value in the manifest that defines it. |
delete | Delete a component-relative value from the manifest that defines it. Also available as del and unset. |
format | Format the manifest files that define a stack component. Also available as fmt. |
validate | Validate stack manifest configurations. |
schema | Print the atmos-manifest JSON Schema. |
config | Read, edit, and list component config in stack manifests, with its own get, set, delete, format, and list subcommands. |
See the atmos stack command reference for the complete list of subcommands and flags.
Arguments
*positionals(Optional) Strings placed on the command line right after
stack, in order: the subcommand and its positional arguments, such as a dot-notation path and, forset, the new value. Every value must be a string, so pass"3"rather than3as a value.flags(Optional) A dictionary of command-line options; see flag translation. A bare key such as
"stack"becomes--stack, and registered shorthands such as"s"and"c"resolve to--stackand--component. Common keys for this command are"stack","component","file", and, forset,"type".args- (Optional) A list or tuple of strings appended after the flags.
working_directory,env,output,check(Optional) See
atmos.runfor process options and defaults.
Options other than the positionals are keyword-only.
Returns
A result with data, stdout, stderr, and exit_code. See atmos.run for output and error behavior.
Examples
Read a value from a component
location = atmos.stack("get", "vars.location", flags = {"stack": "dev", "component": "station"}, output = "capture")
print(location.data)
The value is written to stdout. The command reports which manifest the value comes from on stderr.
Change a value in the manifest that defines it
atmos.stack(
"set",
"vars.location",
"Oslo",
flags = {"stack": "dev", "component": "station"},
)
Atmos finds the manifest file that defines the effective value and edits it in place, keeping comments and YAML
functions. Pass flags = {"file": "stacks/deploy/dev.yaml"} to target one file explicitly.
Validate stacks as a gate
result = atmos.stack("validate", output = "capture", check = False)
if result.exit_code != 0:
fail("Stack validation failed:\n" + result.stderr)
ui.success("All stacks validated successfully.")
Compare a value across stacks
def location_of(stack):
out = atmos.stack("get", "vars.location", flags = {"stack": stack, "component": "station"}, output = "capture")
return out.data
for stack in ["dev", "staging", "prod"]:
ui.info(stack + ": " + location_of(stack))
Related
atmos.runruns any Atmos command from an argument list.atmos stackdocuments every subcommand and flag.- Atmos Automation Language and the script step