Skip to content

Commit

Permalink
feat: support CLOUDSDK_CONFIG env var (#54)
Browse files Browse the repository at this point in the history
Co-authored-by: James Hegedus <jthegedus@hey.com>
  • Loading branch information
gullitmiranda and jthegedus authored Jun 30, 2022
1 parent 6b34d04 commit e1896e1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ cloud-firestore-emulator

This file must be named `.default-cloud-sdk-components` and be at one of the following locations:

- `$CLOUDSDK_CONFIG/.default-cloud-sdk-components`: next to gcloud auth configurations
- `$HOME/.config/gcloud/.default-cloud-sdk-components`: next to gcloud auth configurations
- `$(dirname ASDF_CONFIG_FILE)/.default-cloud-sdk-components`: relative to `.asdfrc` if configured
- `$HOME/.default-cloud-sdk-components`: Home dir

> NOTE: by default `CLOUDSDK_CONFIG=$HOME/.config/gcloud`
Below is the list of available components (as of version `342.0.0`):

```
Expand Down
4 changes: 3 additions & 1 deletion bin/post-install
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source "${plugin_dir}/lib/utils.bash"

function default_cloud_sdk_components_config_path() {
local default_components_filename=".default-cloud-sdk-components"
local default_config_dir="$HOME/.config/gcloud"
local default_config_dir="$(default_cloud_sdk_config)"

local asdf_config_path="${ASDF_CONFIG_FILE:-"$HOME/.asdfrc"}"
local asdf_config_dir
Expand All @@ -31,6 +31,8 @@ function install_default_cloud_sdk_components() {
local gcloud="${ASDF_INSTALL_PATH}/bin/gcloud"
declare -a component_list=()

log_info "ℹ️ Check by Default SDK Components at ${default_cloud_sdk_components}"

if [ ! -f "$default_cloud_sdk_components" ]; then
return
fi
Expand Down
2 changes: 1 addition & 1 deletion bin/pre-plugin-remove
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ source "${plugin_dir}/lib/utils.bash"

# Google Cloud SDK uninstall instructions - https://cloud.google.com/sdk/docs/uninstall-cloud-sdk

log_info "ℹ️ Your gcloud project configuration(s) persist in you gcloud configuration directory. Usually ${HOME}/.config/gcloud"
log_info "ℹ️ Your gcloud project configuration(s) persist in you gcloud configuration directory at \"$(default_cloud_sdk_config)\""
2 changes: 1 addition & 1 deletion bin/uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ source "${plugin_dir}/lib/utils.bash"

# Google Cloud SDK uninstall instructions - https://cloud.google.com/sdk/docs/uninstall-cloud-sdk

log_info "ℹ️ Your gcloud project configuration(s) persist in you gcloud configuration directory. Usually ${HOME}/.config/gcloud"
log_info "ℹ️ Your gcloud project configuration(s) persist in you gcloud configuration directory at \"$(default_cloud_sdk_config)\""

rm -rf "${ASDF_INSTALL_PATH}"
4 changes: 4 additions & 0 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function log_warning() {
}
# END Logging

function default_cloud_sdk_config() {
printf "%s\\n" "${CLOUDSDK_CONFIG:-"$HOME/.config/gcloud"}"
}

function check_dependencies() {
local dependencies_file="${1}"
local failure_type="${2}" # should be "warning" or "failure"
Expand Down

0 comments on commit e1896e1

Please sign in to comment.