Skip to content

Commit bede0ef

Browse files
committed
refactor(task): simplify context and namespace detection with helper functions and remove unused kubectl check
1 parent cf8af33 commit bede0ef

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

task

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,19 @@ CONTAINER_CONFIG="$HOME/.docker/$CONTAINER_REGISTRY"
107107

108108
pass_entry=$(echo "env/${PWD##*/}" | tr '[:upper:]' '[:lower:]')
109109
keepass_entry=$(echo "env/${PWD##*/}" | tr '[:upper:]' '[:lower:]')
110-
if kubectl &> /dev/null; then
111-
current_context=$(kubectl config current-context 2> /dev/null) || current_context=""
112-
fi
113-
if kubectl-ctx &> /dev/null; then
114-
namespace=$(kubectl-ctx -c)
115-
fi
110+
111+
get-namespace() {
112+
if kubectl-ctx &> /dev/null; then
113+
echo $(kubectl-ctx -c 2> /dev/null)
114+
fi
115+
}
116+
namespace="$(get-namespace)"
117+
116118
get-context-alias() {
117119
local alias="$(basename "$(readlink "$HOME/.kube/config" 2>/dev/null)" 2>/dev/null | cut -d '.' -f 2)"
118120
echo "${alias:-loc}"
119121
}
120-
context_alias=$(get-context-alias)
122+
context_alias="$(get-context-alias)"
121123

122124
# Import commands
123125

@@ -148,8 +150,7 @@ version() {
148150

149151
info() {
150152
echo "OpenShift-Project: $OC_PROJECT"
151-
echo "Current-Context: $current_context"
152-
echo "Context-Alias: $context_alias"
153+
echo "Context-Alias: $(get-context-alias)"
153154
echo "Namespace: $namespace"
154155
}
155156

@@ -295,9 +296,9 @@ start-and-prepare() {
295296
install-chart k8up
296297

297298
#FIXME: This does not work in GitHub runner env.
298-
# echo "Load Odoo image."
299-
# docker pull mintsystem/odoo:18.0.20260209
300-
# load-image mintsystem/odoo:18.0.20260209
299+
echo "Load Odoo image."
300+
docker pull mintsystem/odoo:18.0.20260209
301+
load-image mintsystem/odoo:18.0.20260209
301302
}
302303

303304
load-image() {

0 commit comments

Comments
 (0)