Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/github-test-workflow.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: "shellcheck main"
run: ./prj/run-shellcheck.sh
- name: "shellcheck standalones"
run: shellcheck --exclude "SC2181,SC2155,SC2119,SC2031" activate && shellcheck --exclude "SC2181,SC2155,SC2119,SC2031" deactivate
run: shellcheck --exclude "SC2181,SC2155,SC2119,SC2031,SC2317" activate && shellcheck --exclude "SC2181,SC2155,SC2119,SC2031,SC2317" deactivate
tests:
strategy:
matrix:
Expand Down
Empty file modified .github/workflows/multi-arch.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified Dockerfile.GitHub
100644 → 100755
Empty file.
Empty file modified Dockerfile.OCP
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified activate-auto
100644 → 100755
Empty file.
254 changes: 29 additions & 225 deletions bin/ent
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#H::
#H:: Built-in Scripts:

# The directory from which ent was called
# shellcheck disable=SC2034
ENT_ORIGIN_WORKDIR="$PWD"
ENT_CALLER_DIR="$PWD"
ENT_CALLER_PATH="$PATH"

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN() {
upgrade_project_file "$C_ENT_PRJ_FILE" "$C_ENT_OLD_PRJ_FILE"
Expand All @@ -27,8 +27,12 @@ RUN() {
while true; do
cmd="$1"
export ENTANDO_CLI_COMMAND="$1"
cmd=$(_resolve_alias "$cmd")

shift

[ "$ENTANDO_ENT_TRACE" == "true" ] && set -x

case "$cmd" in
"version") #H: shows the version of the current ent
which_ent version
Expand Down Expand Up @@ -61,6 +65,9 @@ RUN() {
# shellcheck disable=SC1090
source "$ENTANDO_ENT_HOME/bin/mod/ent-profile" "$@"
;;
"sub-profile"|"SP"|"subpro") #H: helps creating and managing sub-profiles
_shortcut_subpro "$@"
;;
"attach-vm") #H: [vm-name] -- attach ent to a ent-managed VM
managed-vm-attach "$@"
;;
Expand Down Expand Up @@ -126,18 +133,21 @@ RUN() {
"jhipster"|"bundler"|"bundle")
_ent node-cmd-wrapper "$cmd" "ENT wrapper for the node command \"$cmd\"" "$@"
;;
"pkg") #H: helps dealing with the ent bin tools
_ent.pkg "$@"
;;
"crane"|"docker"|"jq"|"k9s")
_ent.pkg run "$cmd" "$@"
;;
"use") #H: shortcut to "ent pro use"
_ent pro use "$@"
;;
"shell") #H: runs a shell that inherits the ent environment
run-sun-shell "$@"
;;
"load-module")
ent-load-extension-module "$@"
;;
"trace")
ent-trace "$@"
;;
"")
# shellcheck disable=SC1091
_source_ent help
Expand All @@ -146,31 +156,15 @@ RUN() {
cmplt
;;
*)
[ "$cmd" = "k" ] && cmd="kubectl"

local FOUND=false RV=0

local mod_script="${ENTANDO_ENT_HOME}/bin/mod/ent-${cmd}"

if [ -f "$mod_script" ]; then
FOUND=true
# shellcheck disable=SC1090
source "$mod_script" "$@"
RV="$?"
_execute_script "$cmd" "$@"
RV="$?"
if [ "$RV" = "33" ]; then
_log_e "Unrecognized ent module or command \"$cmd\""
elif [ "$RV" = "34" ]; then
_log_e "Unrecognized ent command \"$1\" for module \"$cmd\""
else
local ext_mod_script="$ENTANDO_ENT_EXTENSIONS_MODULES_PATH/ent-${cmd}"
if _ent.extension-module.is-present "$cmd"; then
FOUND=true
_ent.extension-module.execute "${cmd}" "$@"
fi
return "${RV:-1}"
fi

! $FOUND && {
_log_e "Unrecognized ent command \"$cmd\""
return 33
}

(exit "$RV")
;;
esac
_SOE
Expand All @@ -180,172 +174,13 @@ RUN() {
done
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ent-load-extension-module() {
(
local REPO NAME BRANCH
args_or_ask -h "$HH" -a -n -- REPO '1/git_repo//%sp repository of the module' "$@"
args_or_ask -h "$HH" -n -- NAME '--name/strict_file_name//%sp name of the module' "$@"
args_or_ask -h "$HH" -n -- BRANCH '--branch/dn//%sp branch to use instead of the default one' "$@"
end_help_parsing

DIRNAME="$(basename "$REPO")"
[ -z "$NAME" ] && NAME="$DIRNAME"

local EXT_DIR="${ENTANDO_ENT_HOME}/bin/mod/ext"
mkdir -p "$EXT_DIR"
__cd "$EXT_DIR"
if [[ "$PWD" = *".entando"* ]]; then
[ -d "$DIRNAME" ] && rm -rf "$DIRNAME"
git clone --depth=1 ${BRANCH:+-b "$BRANCH"} --single-branch "$REPO"
cp -p -- "$PWD/$DIRNAME/mod/"* .
else
_FATAL "Extension module cleanup: Refusing to delete a non entando-cli dir"
fi
)
}

which_ent() {
_resolve_alias() {
case "$1" in
version) echo "${ENTANDO_CLI_VERSION}"; return;;
which) echo "${ENTANDO_CLI_VERSION}";;
home) echo "$ENTANDO_ENT_HOME"; return;;
k) echo "kubectl";;
*) echo "$1";;
esac

(
echo ""
echo "---"
echo ""

# CLI INFO
echo "## CLI:"
echo ""
cd "$ENTANDO_ENT_HOME"
echo "- DIR: $ENTANDO_ENT_HOME"
IFS='|' read -r sha time < <(git log --pretty=format:'%H|%ci' -1)
echo "- SHA: $sha"
echo "- UPD: $time"
echo ""

# RELEASE INFO
__cd "$(_dist_directory)"
echo "## RELEASE:"
echo ""
echo "- DIR: $PWD"
IFS='|' read -r sha time < <(git log --pretty=format:'%H|%ci' -1)
echo "- SHA: $sha"
echo "- UPD: $time"
echo ""

) 1>&2
}

handle_config_command() {
bgn_help_parsing "${BASH_SOURCE[0]}" "$@"

args_or_ask -h "$HH" -f -- '--default///selects the default ent configuration' "$@" && {
# shellcheck disable=SC2034
CFG_FILE="$ENT_DEFAULT_CFG_FILE"
ENT_WORK_DIR="${ENTANDO_ENT_HOME}/w"
THIS_PROFILE=""
}
args_or_ask -h "$HH" -f -- '--global///selects the global ent configuration' "$@" && {
# shellcheck disable=SC2034
_pp ENTANDO_GLOBAL_CFG
CFG_FILE="$ENTANDO_GLOBAL_CFG"
ENT_WORK_DIR="${ENTANDO_ENT_HOME}/w"
THIS_PROFILE=""
}

args_or_ask -h "$HH" -F ENTANDO_NO_OBFUSCATION '--no-obfuscation///disables the obfuscation in the effective configuration' "$@"
args_or_ask -h "$HH" -f -- '--effective///prints the effective configuration' "$@" && {
print-effective-config
return 0
}

args_or_ask -h "$HH" -f -- '--edit///edits the configuration' "$@" && {
_edit "$CFG_FILE"
return 0
}

args_or_ask -h "$HH" -f -- '--set///sets a specific configuration parameter' "$@" && {
args_or_ask -a -h "$HH" "CFG_KEY" "1///%sp the config key" "$@"
args_or_ask -a -n -h "$HH" "CFG_VALUE" "2///%sp the value to set" "$@"
save_cfg_value "$CFG_KEY" "$CFG_VALUE" "$CFG_FILE"
return 0
}

args_or_ask -h "$HH" -f -- '--del///deletes a specific configuration parameter' "$@" && {
args_or_ask -a -h "$HH" "CFG_KEY" "1///%sp the config key" "$@"
save_cfg_value "$CFG_KEY" "" "$CFG_FILE"
return 0
}

args_or_ask -h "$HH" -f -- '--get///gets a specific configuration parameter' "$@" && {
args_or_ask -a -h "$HH" "CFG_KEY" "1///%sp the config key" "$@"
(
reload_cfg "$CFG_FILE"
echo "${!CFG_KEY}"
)
return 0
}
end_help_parsing

if [ -n "$THIS_PROFILE" ]; then
_log_i "Configuration of the profile \"$THIS_PROFILE\" ($CFG_FILE):" 1>&2
else
_log_i "Default configuration of the current entando distribution ($CFG_FILE):" 1>&2
fi
[ -f "$CFG_FILE" ] || _FATAL -s "Configuration file \"$CFG_FILE\" not found"
cat "$CFG_FILE"
print-secrets-leak-warning
}

cmplt() {
cd "$ENTANDO_ENT_HOME/bin/mod" || {
echo "Unable to enter directory $PWD/bin"
exit 99
}
for file in ent-*; do
mod="${file//ent-/}"
echo "$mod"
done

[ -z "$ENTANDO_ENT_EXTENSIONS_MODULES_PATH" ] && ENTANDO_ENT_EXTENSIONS_MODULES_PATH="$ENTANDO_ENT_HOME/bin/mod/ext"
if [ -d "$ENTANDO_ENT_EXTENSIONS_MODULES_PATH" ]; then
(
cd "$ENTANDO_ENT_EXTENSIONS_MODULES_PATH" || exit 0
for file in ent-*; do
[ -f "$file" ] && {
mod="${file//ent-/}"
echo "$mod"
}
done
)
fi

local topcmd+=(
"attach-vm" "detach-vm" "fix-vm-ddns" "completion" "config" "which" "version" "home" "import" "activate"
"kubectl-cmd" "reset-kubectl-mode" "status"
"attach-kubeconfig" "detach-kubeconfig" "namespace" "appname" "pkg"
"attach-kubectx" "detach-kubectx" "list-kubectx"
"bundle" "bundler" "jhipster"
)

for tc in "${topcmd[@]}"; do
echo "$tc"
done
}

_ent() {
# shellcheck disable=SC1090
"$ENTANDO_ENT_HOME/bin/ent" "$@"
}

_source_ent() {
# shellcheck disable=SC1090
source "$ENTANDO_ENT_HOME/bin/ent" "$@"
}

# ######################################################################################################################
# ######################################################################################################################
Expand Down Expand Up @@ -403,43 +238,10 @@ if (
return "$ENTANDO_ENT_TMPVAR_0002bb75"
else
# shellcheck disable=SC2034

ENTANDO_CALLER_PWD="$PWD"
fi

upgrade_project_file() {
local N=$1
local O=$2
if [ -f "$O" ]; then
mkdir -p "$C_ENT_PRJ_ENT_DIR"
if [ -f "$N" ]; then
mv "$O" "$C_ENT_PRJ_ENT_DIR/$O.backup"
else
mv "$O" "$N"
fi
fi
}

handle_status_config() {
if [ "$V" = "--del" ]; then
ent config --set ""
else
V="$2"
[ "$V" == "--" ] && V="$3"
if [ "$V" = "" ]; then
ent config --get "$1"
else
ent config --set "$1" "$V"
fi
fi
}

handle_kubectl_cmd() {
if [ "$1" = "" ]; then
ent config --get "ENT_KUBECTL_CMD"
else
ent kubectl ent-set-cmd "$@"
fi
}

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
cd "$DIR/.." || {
Expand All @@ -459,6 +261,8 @@ fi
}

. s/_base.sh
. s/_root-helper.sh
cd - > /dev/null || _FATAL "internal error"

RUN "$@"

Loading