mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
feat(scw): export other SCW_* vars based on the selected profile
This commit makes the `ssp` command also export the following variables: - SCW_DEFAULT_ORGANIZATION_ID - SCW_DEFAULT_PROJECT_ID - SCW_DEFAULT_REGION - SCW_DEFAULT_ZONE - SCW_API_URL - SCW_ACCESS_KEY (only exported if SCW_EXPORT_TOKENS set to "true") - SCW_SECRET_KEY (only exported if SCW_EXPORT_TOKENS set to "true")
This commit is contained in:
parent
974a12e83a
commit
62bc41d615
1 changed files with 35 additions and 2 deletions
|
@ -10,7 +10,14 @@ function sgp() {
|
|||
# SCW profile selection
|
||||
function ssp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset SCW_PROFILE
|
||||
unset SCW_PROFILE \
|
||||
SCW_DEFAULT_ORGANIZATION_ID \
|
||||
SCW_DEFAULT_PROJECT_ID \
|
||||
SCW_DEFAULT_REGION \
|
||||
SCW_DEFAULT_ZONE \
|
||||
SCW_API_URL \
|
||||
SCW_ACCESS_KEY \
|
||||
SCW_SECRET_KEY
|
||||
echo SCW profile cleared.
|
||||
return
|
||||
fi
|
||||
|
@ -23,7 +30,33 @@ function ssp() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
export SCW_PROFILE=$1
|
||||
export SCW_PROFILE="$1"
|
||||
unset SCW_DEFAULT_ORGANIZATION_ID \
|
||||
SCW_DEFAULT_PROJECT_ID \
|
||||
SCW_DEFAULT_REGION \
|
||||
SCW_DEFAULT_ZONE \
|
||||
SCW_API_URL \
|
||||
SCW_ACCESS_KEY \
|
||||
SCW_SECRET_KEY
|
||||
|
||||
function scw_export() {
|
||||
local -r scw_var="$1"
|
||||
local -r scw_key="$2"
|
||||
|
||||
local -r scw_val="$(scw config get $scw_key)"
|
||||
if [[ -n "$scw_val" ]] && [[ "$scw_val" != "-" ]]; then
|
||||
eval "export ${scw_var}=$scw_val"
|
||||
fi
|
||||
}
|
||||
scw_export "SCW_DEFAULT_ORGANIZATION_ID" "default-organization-id"
|
||||
scw_export "SCW_DEFAULT_PROJECT_ID" "default-project-id"
|
||||
scw_export "SCW_DEFAULT_REGION" "default-region"
|
||||
scw_export "SCW_DEFAULT_ZONE" "default-zone"
|
||||
scw_export "SCW_API_URL" "api-url"
|
||||
if [[ "$SCW_EXPORT_TOKENS" = "true" ]]; then
|
||||
scw_export "SCW_ACCESS_KEY" "access-key"
|
||||
scw_export "SCW_SECRET_KEY" "secret-key"
|
||||
fi
|
||||
}
|
||||
|
||||
function scw_profiles() {
|
||||
|
|
Loading…
Reference in a new issue