You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📝 Add docstrings to general-improvements-and-typo-fixes
Docstrings generation was requested by @RoseSecurity.
* #980 (comment)
The following files were modified:
* `rootfs/etc/profile.d/aws.sh`
* `rootfs/etc/profile.d/fzf.sh`
* `rootfs/etc/profile.d/prompt.sh`
* `rootfs/templates/wrapper-body.sh`
# _aws_config_home locates or creates the AWS configuration directory, exports GEODESIC_AWS_HOME (and may set AWS_CONFIG_FILE), ensures the directory and config file exist with secure permissions, and returns 1 on failure to create a usable directory.
#If no command is given, a subshell is started with the role.
84
+
#aws_sdk_assume_role sets ASSUME_ROLE and AWS_PROFILE to the specified role (or an interactively chosen role if none specified) and either launches a login subshell that preserves shell history or executes a given command with that profile, then restores the previous ASSUME_ROLE.
84
85
functionaws_sdk_assume_role() {
85
86
local role=$1
86
87
shift
@@ -108,7 +109,12 @@ function aws_sdk_assume_role() {
108
109
}
109
110
110
111
# Asks AWS what the currently active identity is and
111
-
# sets environment variables accordingly
112
+
# export_current_aws_role sets ASSUME_ROLE to reflect the currently active AWS identity.
113
+
# It inspects the current STS caller identity and the active profile (AWS_PROFILE or AWS_VAULT),
114
+
# attempts to map the active ARN to a more descriptive profile name by consulting the AWS config
115
+
# and credentials files (handling normal IAM roles and Identity Center/SSO roles), warns and
116
+
# exports a redacted marker when the environment profile disagrees with the active identity,
117
+
# and unsets ASSUME_ROLE and returns when no identity can be determined.
112
118
functionexport_current_aws_role() {
113
119
local role_name role_names
114
120
# Could be a primary or assumed role. If we have assumed a role, cut off the session name.
@@ -251,7 +257,9 @@ function export_current_aws_role() {
251
257
252
258
# Keep track of AWS credentials and updates to AWS role environment variables.
253
259
# When changes are noticed, update prompt with current role.
254
-
unset GEODESIC_AWS_ROLE_CACHE # clear out value inherited from supershell
260
+
unset GEODESIC_AWS_ROLE_CACHE # refresh_current_aws_role_if_needed checks whether the active AWS role context has changed and updates cached state if necessary.
261
+
#
262
+
# It computes a fingerprint from the exported AWS_PROFILE, the modification time of the shared credentials file, and AWS_ACCESS_KEY_ID; if the fingerprint differs from GEODESIC_AWS_ROLE_CACHE it calls export_current_aws_role and updates GEODESIC_AWS_ROLE_CACHE with the new fingerprint.
255
263
functionrefresh_current_aws_role_if_needed() {
256
264
local is_exported="^declare -[^ x]*x[^ x]* "
257
265
local aws_profile=$(declare -p AWS_PROFILE 2>/dev/null)
@@ -268,4 +276,4 @@ function refresh_current_aws_role_if_needed() {
268
276
# so only use refresh_current_aws_role_if_needed if they are disabled or overridden
269
277
if [[ ($AWS_OKTA_ENABLED!= "true"&&${AWS_VAULT_ENABLED:-false}!= "true") ||-n$AWS_PROFILE ]];then
# A lot of terminals (including Apple's) do not support 24-bit color and the mapping from 24-bit to 8-bit is horrible.
12
12
# So most of the color schemes are limited to the 256 ANSI colors that nearly every terminal supports.
13
-
# Color schemes that only render properly with 24_bit color support are suffixed with _24
13
+
# _set_fzf_default_opts builds and exports FZF_DEFAULT_OPTS based on the given color scheme.
14
+
# The first argument selects the color scheme (e.g., solar_24, solarized_dark, solarized_light, mild, dark, light, 16, bw); when omitted or unrecognized, a mild/default palette is used.
# geodesic_prompt Constructs and installs the interactive shell prompt (PS1) using configured style, role, secrets, Terraform and Kubernetes state, and optional banner.
67
+
#
68
+
# geodesic_prompt selects glyphs and marks based on PROMPT_STYLE (plain, unicode, fancy, or default), computes a level indicator from SHLVL, and sets status/role indicators based on ASSUME_ROLE.
69
+
# It detects active secret environment variables listed in PROMPT_SECRET_ENVS and appends an indicator if any are set, integrates Terraform prompt lines when GEODESIC_TF_PROMPT_ACTIVE is enabled, and adapts the kube prompt prefix for KUBE_PS1.
70
+
# The final PS1 includes an optional BANNER line (with namespace when configured) followed by the directory/host/role segment and prompt glyphs; when no BANNER is defined, PS1 contains only the Terraform and directory segments.
66
71
functiongeodesic_prompt() {
67
72
68
73
case$PROMPT_STYLEin
@@ -211,4 +216,4 @@ function geodesic_prompt_style() {
#Call this function to wait for the container to exit, after all other shells have exited.
290
+
#wait_for_container_exit waits for the Docker container to exit after other shells have terminated, triggers appropriate exit hooks, and prints guidance or forces termination if the container remains running.
289
291
functionwait_for_container_exit() {
290
292
local i n shells
291
293
n=15
@@ -320,6 +322,7 @@ function wait_for_container_exit() {
320
322
fi
321
323
}
322
324
325
+
# run_exit_hooks coordinates shutdown after the terminal detaches: it waits for other interactive shells (if any), reports status to the user, and invokes container- and shell-exit hooks while waiting for the container to terminate.
323
326
functionrun_exit_hooks() {
324
327
# This runs as soon as the terminal is detached. It may take moments for the shell to actually exit.
325
328
# It can then take at least a second for the init process to quit.
@@ -653,6 +656,7 @@ function use() {
653
656
true
654
657
}
655
658
659
+
# _polite_stop sends SIGTERM to the Docker container matching NAME, waits up to 8 seconds for it to exit, and re-sends SIGTERM (exiting with code 138) if the container does not stop.
656
660
_polite_stop() {
657
661
name="$1"
658
662
[ -n"$name" ] ||return 1
@@ -676,6 +680,7 @@ _polite_stop() {
676
680
return 138
677
681
}
678
682
683
+
# stop stops a running geodesic container: if a container name is provided as the first target it requests a graceful shutdown of that container; otherwise it finds containers matching DOCKER_NAME and stops the single match, reports none found, or returns an error when multiple matches exist.
0 commit comments