# # Copyright 2015 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Avoid sourcing bashrc.google more than once for a session as some of # the commands below are not reentrant. #if [[ -n "${GOOGLE_BASHRC_SOURCED}" ]]; then # return #fi GOOGLE_BASHRC_SOURCED=1 START_TIME=$(date +%s%3N) for FILE in /google/devshell/bashrc.google.d/*; do if [ $FILE == "/google/devshell/bashrc.google.d/nvm" ]; then # Don't source that file, instead send true. true elif [ -f "$FILE" ]; then source "$FILE" fi done # Assigns a unique per current session configuration location for Cloud SDK # tools to isolate independent Developer Shell session from each other. export CLOUDSDK_CONFIG=$(mktemp -d) # Makes Cloud SDK use Python3 if the environment variable is set to true. export CLOUDSDK_PYTHON=python3 # This dir is deleted on devshell session exit by a script installed in # /google/devshell/bash_exit.google.d/rm_temp_cloudsdk_config.sh export __TMP_CLOUDSDK_CONFIG=$CLOUDSDK_CONFIG # Returns a gcloud property by section and name. # Could parse it from "gcloud config list" output, but invoking gcloud on # each prompt is impractically slow currently. Use custom Python for now. get_gcloud_config_property () { # CD to the root directory so we don't pick up unexpected python modules. CUR_DIR=`pwd` cd / SECTION=\'$1\' PROPERTY=\'$2\' ACTIVE_CONFIG=`cat $CLOUDSDK_CONFIG/active_config` python2 <