Skip to content

Commit

Permalink
master > master: docker-state -> in/out instead of 1/0
Browse files Browse the repository at this point in the history
  • Loading branch information
RLogik committed Jul 26, 2021
1 parent 0575727 commit ae6c84d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/.lib.docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -409,25 +409,25 @@ function docker_remove_all_images() {
}

##############################################################################
# AUXILIARY METHODS: DEPTH, WHALES STATE
# AUXILIARY METHODS: DOCKER/WHALES STATE
##############################################################################

function get_docker_depth() {
local depth=0;
[[ -f "$WHALES_FILE_DOCKER_DEPTH" ]] && depth="$( head -n 1 "$WHALES_FILE_DOCKER_DEPTH" )";
! ( echo "$depth" | grep -Eq "^(0|[1-9][0-9]*|-[1-9][0-9]*)$" ) && depth=0;
echo $depth;
function get_docker_state() {
local state="out";
[[ -f "$WHALES_FILE_DOCKER_STATE" ]] && state="$( head -n 1 "$WHALES_FILE_DOCKER_STATE" )";
! ( echo "$state" | grep -Eq "^(in|out)$" ) && state="out";
echo $state;
}

function is_docker() {
local depth=$( get_docker_depth );
[ $depth -gt 0 ] && return 0 || return 1;
local state=$( get_docker_state );
[[ "$state" == "in" ]] && return 0 || return 1;
}

function get_whales_state() {
local state=0;
[[ -f "$WHALES_FILE_WHALES_STATE" ]] && state="$( head -n 1 "$WHALES_FILE_WHALES_STATE" )";
! ( echo "$state" | grep -Eq "^(on|off)$" ) && state=off;
! ( echo "$state" | grep -Eq "^(on|off)$" ) && state="off";
echo $state;
}

Expand Down
2 changes: 1 addition & 1 deletion src/.lib.globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ env_from ".whales.env" import WHALES_PROJECT_NAME;
export WHALES_LABEL_PREFIX="org.whales.";
export WHALES_LABEL_PREFIX_REGEX="^org\.whales\.";
export WHALES_DOCKER_COMPOSE_YML=".whales.docker-compose.yml";
export WHALES_FILE_DOCKER_DEPTH="$WHALES_SETUP_PATH/DOCKER_DEPTH";
export WHALES_FILE_WHALES_STATE="$WHALES_SETUP_PATH/WHALES_STATE";
export WHALES_FILE_DOCKER_STATE="$WHALES_SETUP_PATH/DOCKER_STATE";
export WHALES_TEMPCONTAINER_SCHEME_PREFIX="temp_${WHALES_PROJECT_NAME}";
export WHALES_DOCKER_TAG_EXPLORE="explore";
export WHALES_DOCKER_SERVICE=""; # NOTE: This get changed dynamically.
Expand Down

0 comments on commit ae6c84d

Please sign in to comment.