Skip to content

Commit 2d694f0

Browse files
committed
refactor(task): replace suspend/unsuspend-job with run-job and switch to kubectl-ctx
1 parent 496e11a commit 2d694f0

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

task

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ help() {
5555
rows+=("list||List Helm deployments.")
5656
rows+=("get-pods||List all pods.")
5757
rows+=("login-oc||Refresh the auth token for OpenShift.")
58-
rows+=("suspend-job|[name]|Suspend a job to stop it.")
59-
rows+=("unsuspend-job|[name]|Unsuspend a job to run it.")
58+
rows+=("run-job|[name]|Make a copy and unsuspends the job.")
6059
# Helm
6160
rows+=("add-repos||Add the required Helm repos.")
6261
rows+=("template-manifest|[chart][values]|Template all charts with Helm.")
@@ -111,8 +110,8 @@ keepass_entry=$(echo "env/${PWD##*/}" | tr '[:upper:]' '[:lower:]')
111110
if kubectl &> /dev/null; then
112111
current_context=$(kubectl config current-context 2> /dev/null) || current_context=""
113112
fi
114-
if kubens &> /dev/null; then
115-
namespace=$(kubens -c)
113+
if kubectl-ctx &> /dev/null; then
114+
namespace=$(kubectl-ctx -c)
116115
fi
117116
get-context-alias() {
118117
local alias="$(basename "$(readlink "$HOME/.kube/config" 2>/dev/null)" 2>/dev/null | cut -d '.' -f 2)"
@@ -476,7 +475,7 @@ switch-context() {
476475
chmod 0644 "$target"
477476

478477
echo 'Select namespace'
479-
kubens
478+
kubectl-ctx
480479
}
481480

482481
show-context() {
@@ -603,20 +602,13 @@ uninstall-release() {
603602
helm uninstall "$release_name"
604603
}
605604

606-
unsuspend-job() {
605+
run-job() {
607606
if test -z "$1"; then echo '\$1 is empty.'; exit 1; fi
608607
local job_name="$1"
609608

610-
echo "Running job: $job_name"
611-
kubectl patch job/$job_name --type=strategic --patch '{"spec":{"suspend":false}}'
612-
}
613-
614-
suspend-job() {
615-
if test -z "$1"; then echo '\$1 is empty.'; exit 1; fi
616-
local job_name="$1"
617-
618-
echo "Running job: $job_name"
619-
kubectl patch job/$job_name --type=strategic --patch '{"spec":{"suspend":true}}'
609+
echo "Run job: $job_name"
610+
kubectl create job --from=job/${job_name} ${job_name}-run
611+
kubectl patch job/${job_name}-run --type=strategic --patch '{"spec":{"suspend":false}}'
620612
}
621613

622614
# kubectl Commands

0 commit comments

Comments
 (0)