-
Notifications
You must be signed in to change notification settings - Fork 0
/
releases.yml
89 lines (83 loc) · 3.15 KB
/
releases.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
version: '3'
tasks:
helmfile:
interactive: true
desc: "Wrapper Task for Helmfile used by other Tasks"
cmds:
- |
set - {{ .CLI_ARGS }}
COMMAND="$1"; shift
SELECTOR=""
if [[ -n "$1" ]] && [[ ! "$1" =~ '=' ]]; then
SELECTOR+="--selector=namespace=$1"; shift
fi
if [[ -n "$1" ]] && [[ ! "$1" =~ '=' ]]; then
SELECTOR+=",name=$1"; shift
fi
if [[ -z "$SELECTOR" ]] && [[ "$#" -gt 0 ]]; then
SELECTOR+="--selector="
fi
IFS="" SELECTOR+=$(echo "$*")
set -e
usage(){
echo "Invalid usage."
echo
echo "Arguments:"
echo "<command> The Helmfile command to use. $([ -z "$COMMAND" ] && echo ❌ Not specified || echo ✅ Current value is $COMMAND)."
echo "<namespace> Must be a valid namespace. $([ -z "$NAMESPACE" ] && echo ❌ Not specified || echo Current value is $NAMESPACE. $([ ! -f "$NAMESPACE_FILE_PATH" ] && echo ❌ Expected file $NAMESPACE_FILE_PATH does not exist || echo Expected file ✅ $NAMESPACE_FILE_PATH exists))."
echo "[release-name] Optionally select a single release"
exit 1
}
DEBUG_LOGS=""
if [ "$LAUNCHPAD_VERBOSE_LOGS" = "true" ]; then
DEBUG_LOGS="--debug"
fi
if [ "$NAMESPACE" = "sealed-secrets" ] && [ "$COMMAND" != "status" ]; then
TEXT="You are about to modify the $NAMESPACE namespace.
Deleting the sealed-secrets controller will render all existing SealedSecrets invalid.
Make sure you have backup copies of all your secrets. Are you sure you want to continue?"
gum confirm --prompt.foreground "#ff0000" "$TEXT"
fi
set -x
if [ "$COMMAND" = "apply" ]; then
echo "\nREMEMBER: To pull the latest charts, be sure to run releases:update-deps before releases:apply\n\n"
helmfile $DEBUG_LOGS --interactive -f "$NAMESPACE_FILE_PATH" --skip-deps $SELECTOR $COMMAND "$@"
else
helmfile $DEBUG_LOGS --interactive -f "$NAMESPACE_FILE_PATH" $SELECTOR $COMMAND "$@"
fi
status:
interactive: true
desc: "View status for release(s). Usage: releases:status"
cmds:
- task: helmfile
vars:
CLI_ARGS: "status {{.CLI_ARGS}}"
apply:
interactive: true
desc: "Apply current helmfile state. Usage: releases:apply"
cmds:
- task: helmfile
vars:
CLI_ARGS: "apply {{.CLI_ARGS}}"
destroy:
interactive: true
desc: "Destroy release(s) for a cluster namespace. Usage: releases:destroy -- <namespace> [release-name]"
cmds:
- task: helmfile
vars:
CLI_ARGS: "destroy {{.CLI_ARGS}}"
list:
interactive: true
desc: "List release(s) present in the helmfile. Usage: releases:list"
cmds:
- task: helmfile
vars:
CLI_ARGS: "list {{.CLI_ARGS}}"
update-deps:
interactive: true
desc: "Clear cache and update all repo and chart dependencies. Usage: releases:update-deps"
cmds:
- helmfile cache cleanup
- task: helmfile
vars:
CLI_ARGS: "deps {{.CLI_ARGS}}"