Skip to content

Commit 9f1ac74

Browse files
committed
awsecure-cli code for zsh
1 parent beec984 commit 9f1ac74

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

bin/zsh/aws

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env zsh
2+
3+
set -eo pipefail
4+
5+
. ~/.awsecure-cli
6+
7+
if [[ $(type awsecure_cli_log_info 2> /dev/null) == "" || -z "${AWSECURE_CLI_SRC_DIRECTORY// /}" ]]; then
8+
[[ -L ${0} ]] && declare -gr AWSECURE_CLI_SRC_DIRECTORY="$(realpath $(readlink ${0}) | xargs dirname)/../../src" || declare -gr AWSECURE_CLI_SRC_DIRECTORY="$(realpath ${0} | xargs dirname)/../../src"
9+
. ${AWSECURE_CLI_SRC_DIRECTORY}/common/logging.shinc
10+
fi
11+
12+
awsecure_cli_log_info "Using the AWSecure CLI wrapper"
13+
. ${AWSECURE_CLI_SRC_DIRECTORY}/common/wrapper.sh

src/zsh/validate-prereqs.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env zsh
2+
3+
set -eo pipefail
4+
5+
function awsecure_cli_validate_commands() {
6+
local -rl AWSECURE_CLI_VALIDATE_COMMANDS=(jq ${AWSECURE_CLI_AWS_BIN_FILEPATH} ${AWSECURE_CLI_SH_INTERPRETER})
7+
for cmd in ${AWSECURE_CLI_VALIDATE_COMMANDS}; do
8+
awsecure_cli_log_info "Testing if ${cmd} is installed"
9+
${cmd} --version &> /dev/null || awsecure_cli_log_error "The ${cmd} is not installed or not in the PATH environment variable"
10+
done
11+
}
12+
13+
case "${AWSECURE_CLI_OS_NAME// /}" in
14+
darwin)
15+
true
16+
;;
17+
linux)
18+
true
19+
;;
20+
*)
21+
awsecure_cli_log_error "OS not supported"
22+
;;
23+
esac
24+
25+
awsecure_cli_validate_commands
26+
27+
set +eo pipefail
28+
${AWSECURE_CLI_AWS_BIN_FILEPATH} configure get aws_access_key_id > /dev/null 2>&1
29+
[[ $? -ne 0 ]] && { awsecure_cli_log_info "The profile ${AWS_PROFILE} is not using an AWS access key, skipping AWS access key rotation" ; SKIP_AWSECURE_CLI_AUTOROTATE_AWS_ACCESS_KEYS=true ; }
30+
set -eo pipefail

0 commit comments

Comments
 (0)