Skip to content

Commit af123c0

Browse files
ostermanclaudemilldr
authored
Add Atmos auth integration to Geodesic (#979)
Co-authored-by: Claude <[email protected]> Co-authored-by: Dan Miller <[email protected]>
1 parent 9dcc82c commit af123c0

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

rootfs/etc/profile.d/atmos.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
#!/bin/bash
22

3+
# Configure Atmos XDG paths to use container's home directory
4+
# This is required for Atmos auth to work correctly with mounted volumes
5+
export ATMOS_XDG_CONFIG_HOME="${ATMOS_XDG_CONFIG_HOME:-${HOME}/.config}"
6+
export ATMOS_XDG_DATA_HOME="${ATMOS_XDG_DATA_HOME:-${HOME}/.local/share}"
7+
export ATMOS_XDG_CACHE_HOME="${ATMOS_XDG_CACHE_HOME:-${HOME}/.cache}"
8+
9+
# Helper function for Atmos auth integration
10+
# Usage: use-identity [identity-name] [other atmos auth env flags]
11+
# This uses Atmos auth to authenticate and set credentials in the environment
12+
# If called with no arguments, it brings up the identity selector
13+
function use-identity() {
14+
if ! command -v atmos >/dev/null 2>&1; then
15+
echo "Error: atmos command not found. Please install atmos first." >&2
16+
return 1
17+
fi
18+
19+
# Run atmos auth env and evaluate the output to set credentials
20+
local auth_output
21+
if [ $# -eq 0 ]; then
22+
# No arguments: bring up the selector by passing --identity with no value
23+
if ! auth_output=$(atmos auth env --identity 2>&1); then
24+
echo "Error running atmos auth: $auth_output" >&2
25+
return 1
26+
fi
27+
else
28+
# Arguments provided: pass --identity=<value> with the first argument, then any additional flags
29+
if ! auth_output=$(atmos auth env --identity="$1" "${@:2}" 2>&1); then
30+
echo "Error running atmos auth: $auth_output" >&2
31+
return 1
32+
fi
33+
fi
34+
35+
# Evaluate the output to set environment variables
36+
eval "$auth_output"
37+
38+
# If export_current_aws_role function exists (from aws.sh), refresh the AWS role display
39+
if declare -f export_current_aws_role >/dev/null 2>&1; then
40+
export_current_aws_role
41+
fi
42+
}
43+
344
function atmos_configure_base_path() {
445
# Leave $ATMOS_BASE_PATH alone if it is already set
546
if [[ -n $ATMOS_BASE_PATH ]]; then

rootfs/templates/wrapper-body.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ function use() {
531531
fi
532532
done
533533

534+
# Mount Atmos-specific directories for auth support (if they exist)
535+
# These are small directories specific to Atmos auth and won't impact performance
536+
for dir in ".cache/atmos" ".local/share/atmos"; do
537+
if [ -d "${local_home}/${dir}" ] || [ -f "${local_home}/${dir}" ]; then
538+
DOCKER_LAUNCH_ARGS+=(--volume="${local_home}/${dir}:${mount_dir}${local_home}/${dir}")
539+
debug "Mounting '${local_home}/${dir}' into container for Atmos auth"
540+
fi
541+
done
542+
534543
# WORKSPACE_MOUNT is the directory in the container that is to be the mount point for the host filesystem
535544
WORKSPACE_MOUNT="${WORKSPACE_MOUNT:-/workspace}"
536545
# WORKSPACE_HOST_DIR is the directory on the host that is to be the working directory

0 commit comments

Comments
 (0)