devzone 7.5.4 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Service hooks of the workstation for services.sh (#538): secrets created
3
- # apart (postgres-admin, mysql-admin, mirrored and never printed), Helm
4
- # parameters of the mysql chart (existing volume claim), and the
5
- # devzone workspace services enable|disable switch when Argo CD holds the
6
- # charts. Sourced by manage/scripts/workspace/argocd-services.sh. bash 3.2 (macOS).
7
-
8
- # Namespace of the service: labelled, isolated like the other devzone-*
9
- # (services.sh: services_namespace_prepare)
10
-
11
- # Superuser secret postgres-admin, created apart: an existing secret is kept
12
- # and mirrored; otherwise a password generated on the workstation. Mirror
13
- # workspace/.postgres/admin-password (600) and .password; never printed
14
- services_secret_postgres() {
15
- local dir="$PWD/workspace/.postgres" file password
16
- file="$dir/admin-password"
17
- mkdir -p "$dir"
18
- chmod 700 "$dir"
19
- password="$(ak -n "$POSTGRES_NS" get secret postgres-admin \
20
- -o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
21
- if [ -n "$password" ]; then
22
- (umask 077 && printf '%s' "$password" >"$file")
23
- else
24
- if [ ! -s "$file" ]; then
25
- (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$file")
26
- fi
27
- ak -n "$POSTGRES_NS" create secret generic postgres-admin --from-file=password="$file" >/dev/null
28
- fi
29
- chmod 600 "$file"
30
- argocd_passwords_refresh
31
- }
32
-
33
- # Superuser secret mysql-admin, created apart, the same way; the mirror
34
- # workspace/.mysql/admin-password feeds the mysql entry of .password
35
- services_secret_mysql() {
36
- local dir="$PWD/workspace/.mysql" file password
37
- file="$dir/admin-password"
38
- mkdir -p "$dir"
39
- chmod 700 "$dir"
40
- password="$(ak -n "$MYSQL_NS" get secret mysql-admin \
41
- -o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
42
- if [ -n "$password" ]; then
43
- (umask 077 && printf '%s' "$password" >"$file")
44
- else
45
- if [ ! -s "$file" ]; then
46
- (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$file")
47
- fi
48
- ak -n "$MYSQL_NS" create secret generic mysql-admin --from-file=password="$file" >/dev/null
49
- fi
50
- chmod 600 "$file"
51
- argocd_passwords_refresh
52
- }
53
-
54
- # Values of the MySQL chart: image, port, memory and size (catalogue defaults),
55
- # and the claim to mount chosen among the existing volumes (one PVC *-mysql-0:
56
- # its prefix; none: the chart default donnees; several: refused)
57
- services_chart_mysql() {
58
- local liste claim=""
59
- liste="$(ak -n "$MYSQL_NS" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null | grep -E '\-mysql-0$' || true)"
60
- if [ -n "$liste" ]; then
61
- if [ "$(printf '%s\n' "$liste" | grep -c .)" -gt 1 ]; then
62
- echo "✖ several MySQL volumes in $MYSQL_NS: devzone mysql volume <name> picks the mounted one" >&2
63
- return 2
64
- fi
65
- claim=" claim=${liste%-mysql-0}"
66
- fi
67
- printf 'image=mysql:8.4 port=3306 memory=1Gi size=5Gi%s' "$claim"
68
- }
69
-
70
- # devzone workspace services enable|disable postgres|mysql when Argo CD holds
71
- # the charts: the [services] section written, then reconciled (services.sh).
72
- # disable keeps the namespace, the volumes and the data; --yes is the explicit
73
- # data removal (namespace deleted; the mirror workspace/.mysql stays, like
74
- # supprimer-donnees of the module, the one of .postgres goes)
75
- services_argocd_toggle() {
76
- local svc="$1" action="$2" yes
77
- shift 2
78
- case "$action" in
79
- enable)
80
- if [ "$#" -ne 0 ]; then
81
- echo "✖ $svc through Argo CD takes no option (got: $*)" >&2
82
- return 1
83
- fi
84
- # Before [services] is written: a refused chart leaves the state unchanged
85
- chart_require "$svc" || return $?
86
- echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
87
- services_note "$svc" on
88
- services_reconcile || return $?
89
- echo "✔ Application devzone-$svc declared ([services] $svc = on in $ARGOCD_CONF); status: devzone workspace argocd status; local access: devzone workspace ports"
90
- ;;
91
- disable)
92
- yes="$(yes_flag "services disable $svc [--yes]" "$@")" || return 1
93
- services_note "$svc" off
94
- services_reconcile || return $?
95
- if [ "$yes" = 1 ]; then
96
- ak delete namespace "devzone-$svc" --wait=true --ignore-not-found >/dev/null
97
- case "$svc" in
98
- postgres) rm -rf "$PWD/workspace/.$svc" ;;
99
- esac
100
- argocd_passwords_refresh
101
- echo "✔ $svc removed: Application, namespace devzone-$svc and data ([services] $svc = off)"
102
- else
103
- echo "✔ $svc stopped: Application removed, the namespace devzone-$svc, the volumes and the data stay (devzone workspace services disable $svc --yes to remove the data)"
104
- fi
105
- ;;
106
- esac
107
- }
108
-
109
- # Toggles postgres on/off as an Argo CD Application (charts/devzone-postgres).
110
- # Calls services_argocd_toggle to write the [services] section and reconcile.
111
- postgres_argocd() { services_argocd_toggle postgres "$@"; }
112
-
@@ -1,182 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Deployments held by Argo CD in the Kubernetes workspace (#516), sourced by
3
- # manage/workspace.sh after argocd-workspace.sh: the workspace itself, the
4
- # services of the [services] section (services.sh), the argocd services
5
- # switch and devzone workspace argocd.
6
- # workspace_deploy <repository> <tag> <with-image> start: Application, else helm direct
7
- # workspace_undeploy stop: Application, else helm uninstall
8
- # argocd_toggle enable|disable devzone workspace services … argocd
9
- # services_secret_postgres postgres secret created apart
10
- # postgres_argocd enable|disable [--yes] postgres: [services] written, then reconciled
11
- # argocd_cmd status | init | apply | app add|list|remove devzone workspace argocd …
12
- # Secrets stay out of Git: created here, only referenced by the charts.
13
- # bash 3.2 (macOS).
14
-
15
- WORKSPACE_APP="devzone-workspace"
16
- # shellcheck disable=SC2034 # read by argocd-services-svc.sh
17
- POSTGRES_NS="devzone-postgres"
18
- # shellcheck disable=SC2034 # read by argocd-services-svc.sh
19
- MYSQL_NS="devzone-mysql"
20
- # Services held by Argo CD ([services] of .argocd.conf, services.sh); gitlab
21
- # joins in its step (#538)
22
- # shellcheck disable=SC2034 # read by services.sh
23
- SERVICES_LIST="postgres mysql"
24
-
25
- # The only option of a removal: --yes; prints 1 or 0
26
- yes_flag() {
27
- local usage="$1" arg found=0
28
- shift
29
- for arg in "$@"; do
30
- case "$arg" in
31
- --yes) found=1 ;;
32
- *) echo "✖ unknown option: $arg (devzone workspace $usage)" >&2; return 1 ;;
33
- esac
34
- done
35
- echo "$found"
36
- }
37
-
38
- # shellcheck disable=SC2034 # read by apps.sh
39
- APPS_CMD="devzone workspace argocd app"
40
- # shellcheck disable=SC2034 # read by apps.sh
41
- APPS_GENERATOR="$RACINE/.devcontainer/argocd/application.sh"
42
- # shellcheck disable=SC2034 # read by gitops.sh
43
- GITOPS_CMD="devzone workspace argocd init"
44
- # .argocd.conf of the devzone folder of the workstation (conf.sh)
45
- # shellcheck disable=SC2034 # read by conf.sh and apps.sh
46
- ARGOCD_CONF_DIR="$PWD"
47
- # shellcheck disable=SC2034
48
- ARGOCD_CONF="$PWD/.argocd.conf"
49
- # shellcheck source=../../../.devcontainer/argocd/conf.sh
50
- # shellcheck disable=SC1091
51
- . "$RACINE/.devcontainer/argocd/conf.sh"
52
- # shellcheck source=../../../.devcontainer/argocd/gitops.sh
53
- # shellcheck disable=SC1091
54
- . "$RACINE/.devcontainer/argocd/gitops.sh"
55
- # shellcheck source=../../../.devcontainer/argocd/apps.sh
56
- # shellcheck disable=SC1091
57
- . "$RACINE/.devcontainer/argocd/apps.sh"
58
- # shellcheck source=../../../.devcontainer/argocd/services.sh
59
- # shellcheck disable=SC1091
60
- . "$RACINE/.devcontainer/argocd/services.sh"
61
- argocd_kubectl() { ak "$@"; }
62
-
63
- # workspace start and argocd apply: the declarations of .argocd.conf held
64
- argocd_reconcile() {
65
- argocd_installed || return 0
66
- gitops_init || return 1
67
- gitops_root || return 1
68
- apps_reconcile
69
- if argocd_holds_charts; then
70
- services_reconcile
71
- fi
72
- }
73
-
74
- # Root token of the devzone GitLab for app add: the file of the workstation,
75
- # else the one of the pod (the module was installed there, #528); never printed
76
- apps_gitlab_token() {
77
- if [ -s "$PWD/workspace/.gitlab/root-token" ]; then
78
- cat "$PWD/workspace/.gitlab/root-token"
79
- else
80
- ak -n "$NAMESPACE" exec "$POD" -c workspace -- cat "$DOSSIER_PROJETS/workspace/.gitlab/root-token" 2>/dev/null || true
81
- fi
82
- }
83
-
84
- # Argo CD holds the devzone charts only with a Git revision (release tag or
85
- # DEVZONE_ARGOCD_REVISION): a development clone stays on helm direct
86
- argocd_holds_charts() {
87
- argocd_active && [ -n "$(argocd_revision)" ]
88
- }
89
-
90
- argocd_clone_notice() {
91
- if argocd_active && [ -z "$(argocd_revision)" ]; then
92
- echo "ℹ development clone (version 0.0.0): helm direct; DEVZONE_ARGOCD_REVISION=<branch> to go through Argo CD"
93
- fi
94
- }
95
-
96
- # Release secrets of a release deployed with helm before: deleted, so that
97
- # Argo CD adopts the live resources without any helm uninstall (no downtime)
98
- helm_release_forget() {
99
- ak -n "$2" delete secret -l "owner=helm,name=$1" --ignore-not-found >/dev/null 2>&1 || true
100
- }
101
-
102
- workspace_deploy() {
103
- local repository="$1" tag="$2" with_image="$3" params
104
- if ! argocd_holds_charts; then
105
- argocd_clone_notice
106
- workspace_helm_deploy "$repository" "$tag" "$with_image"
107
- return
108
- fi
109
- params="image.tag=$tag"
110
- [ -z "$with_image" ] || params="$params image.repository=$repository"
111
- [ "$tag" != latest ] || params="$params image.pullPolicy=Always"
112
- # egress proxy settings of .devzone.modules (#633): replayed at each start and update
113
- params="$params $("${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace egress params)"
114
- chart_require workspace || return $?
115
- # GitOps repository created or designated first, with its root Application
116
- gitops_init || return 1
117
- gitops_root || return 1
118
- echo "▶ Application $WORKSPACE_APP (Argo CD, charts/devzone-workspace at $(argocd_revision))…"
119
- helm_release_forget devzone-workspace devzone-workspace
120
- # shellcheck disable=SC2086
121
- argocd_apply_application "$WORKSPACE_APP" workspace devzone-workspace \
122
- "$DEVZONE_REPO_URL" "$(argocd_revision)" charts/devzone-workspace $params
123
- }
124
-
125
- workspace_undeploy() {
126
- if argocd_installed && argocd_application_exists "$WORKSPACE_APP"; then
127
- echo "▶ Application $WORKSPACE_APP deleted (Argo CD removes the pod, the volumes stay)…"
128
- argocd_delete_application "$WORKSPACE_APP"
129
- else
130
- # shellcheck disable=SC2046
131
- helm $(helm_flag) uninstall devzone-workspace --namespace devzone-workspace
132
- fi
133
- }
134
-
135
- # devzone workspace services enable|disable argocd: the workstation installs
136
- # or removes it itself; the state line follows what succeeded
137
- argocd_toggle() {
138
- local action="$1"
139
- shift
140
- if [ "$#" -ne 0 ]; then
141
- echo "✖ services $action argocd takes no option (got: $*)" >&2
142
- return 1
143
- fi
144
- case "$action" in
145
- enable) argocd_install && state_note argocd on && gitops_init && gitops_root ;;
146
- disable) argocd_uninstall && state_note argocd off ;;
147
- esac
148
- }
149
-
150
- # Service hooks (secrets, mysql chart parameters, services switch)
151
- # shellcheck source=argocd-services-svc.sh
152
- # shellcheck disable=SC1091
153
- . "$(dirname "${BASH_SOURCE[0]}")/argocd-services-svc.sh"
154
-
155
- # devzone workspace argocd status | app …
156
- argocd_cmd() {
157
- case "${1:-status}" in
158
- status) argocd_status ;;
159
- init)
160
- gitops_init "${@:2}" || return $?
161
- if argocd_installed; then gitops_root; fi
162
- ;;
163
- apply)
164
- if ! argocd_installed; then
165
- echo "✖ Argo CD not installed: devzone workspace services enable argocd" >&2
166
- return 1
167
- fi
168
- argocd_reconcile
169
- ;;
170
- app)
171
- if ! argocd_installed; then
172
- echo "✖ Argo CD not installed: devzone workspace services enable argocd" >&2
173
- return 1
174
- fi
175
- argocd_app "${@:2}"
176
- ;;
177
- *)
178
- echo "✖ devzone workspace argocd status | init [--repo <url>|--none] | apply | app add <repo url> [path] [--name N] [--revision R] | app list | app remove <N>" >&2
179
- return 1
180
- ;;
181
- esac
182
- }
@@ -1,227 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Argo CD of the Kubernetes workspace, driven from the workstation (#516).
3
- # Sourced by manage/workspace.sh (kubectl_flag, helm_flag, RACINE: the
4
- # package; $PWD: the devzone folder of the workstation, its .devzone.modules,
5
- # workspace/.argocd and .password).
6
- # argocd_wanted 0 unless .devzone.modules says argocd=off (on by default)
7
- # argocd_installed namespace devzone-argocd present
8
- # argocd_active wanted and installed: Applications instead of helm direct
9
- # argocd_ensure installs it when wanted and missing (workspace start)
10
- # argocd_install | argocd_uninstall | argocd_status
11
- # argocd_revision Git revision of the devzone charts; empty on a dev clone
12
- # argocd_apply_application / argocd_delete_application
13
- # Why: the pod has no administrator access (#430); the workstation has helm
14
- # and kubectl. The admin password goes to workspace/.argocd/admin.env and
15
- # .password of the workstation, never on screen. bash 3.2 (macOS).
16
-
17
- ARGOCD_NS="devzone-argocd"
18
- ARGOCD_CHART_VERSION="${ARGOCD_VERSION:-10.14.0}"
19
- ARGOCD_LOCAL_PORT="${ARGOCD_PORT:-8443}"
20
- ARGOCD_WAIT="${ARGOCD_ATTENTE:-600}"
21
- ARGOCD_MIN_MEMORY_KI=1048576
22
- DEVZONE_REPO_URL="${DEVZONE_REPO_URL:-https://github.com/SimBienvenueHoulBoumi/devzone.git}"
23
-
24
- # Wrapper chart installed by the workstation and by the container (#538)
25
- argocd_chart() { printf '%s/charts/devzone-argocd' "$RACINE"; }
26
- argocd_generator() { printf '%s/.devcontainer/argocd/application.sh' "$RACINE"; }
27
- argocd_secrets_dir() { printf '%s/workspace/.argocd' "$PWD"; }
28
-
29
- # kubectl of the workstation, context devzone when it exists
30
- ak() {
31
- # shellcheck disable=SC2046
32
- kubectl $(kubectl_flag) "$@"
33
- }
34
-
35
- # Last value of a key of .devzone.modules of the workstation (empty if none)
36
- state_read() {
37
- grep "^$1=" .devzone.modules 2>/dev/null | tail -1 | cut -d= -f2- || true
38
- }
39
-
40
- # key=value written in .devzone.modules of the workstation, other lines kept
41
- state_note() {
42
- local f=".devzone.modules" tmp
43
- tmp="$f.tmp.$$"
44
- {
45
- if [ -f "$f" ]; then grep -v "^$1=" "$f" || true; fi
46
- echo "$1=$2"
47
- } >"$tmp" && mv "$tmp" "$f"
48
- }
49
-
50
- argocd_wanted() { [ "$(state_read argocd)" != off ]; }
51
-
52
- argocd_installed() { ak get namespace "$ARGOCD_NS" >/dev/null 2>&1; }
53
-
54
- argocd_active() { argocd_wanted && argocd_installed; }
55
-
56
- # Git revision of the devzone charts: DEVZONE_ARGOCD_REVISION, else the tag of
57
- # the package version; empty on a development clone (0.0.0: the local chart
58
- # is not in Git)
59
- argocd_revision() {
60
- local version
61
- if [ -n "${DEVZONE_ARGOCD_REVISION:-}" ]; then
62
- printf '%s' "$DEVZONE_ARGOCD_REVISION"
63
- return 0
64
- fi
65
- version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$RACINE/package.json" | head -1)"
66
- case "$version" in
67
- '' | 0.0.0) ;;
68
- *) printf 'v%s' "$version" ;;
69
- esac
70
- }
71
-
72
- # Kubernetes memory quantity in Ki (Ki, Mi, Gi, Ti, K, M, G, bytes)
73
- argocd_quantity_ki() {
74
- local q="${1:-}" n
75
- case "$q" in
76
- *Ki) n="${q%Ki}"; echo $((n)) ;;
77
- *Mi) n="${q%Mi}"; echo $((n * 1024)) ;;
78
- *Gi) n="${q%Gi}"; echo $((n * 1024 * 1024)) ;;
79
- *Ti) n="${q%Ti}"; echo $((n * 1024 * 1024 * 1024)) ;;
80
- *K | *k) n="${q%[Kk]}"; echo $((n * 1000 / 1024)) ;;
81
- *M) n="${q%M}"; echo $((n * 1000 * 1000 / 1024)) ;;
82
- *G) n="${q%G}"; echo $((n * 1000 * 1000 * 1000 / 1024)) ;;
83
- *)
84
- case "$q" in
85
- '' | *[!0-9]*) echo 0 ;;
86
- *) echo $((q / 1024)) ;;
87
- esac
88
- ;;
89
- esac
90
- }
91
-
92
- # Refuses under 1 Gi of allocatable memory in the cluster (sum of the nodes)
93
- argocd_memory_ok() {
94
- local lines value total=0
95
- lines="$(ak get nodes -o jsonpath='{range .items[*]}{.status.allocatable.memory}{"\n"}{end}' 2>/dev/null)" || lines=""
96
- if [ -z "$lines" ]; then
97
- echo "✖ argocd: cluster unreachable or nodes unreadable (kubectl config get-contexts)" >&2
98
- return 2
99
- fi
100
- while IFS= read -r value; do
101
- [ -n "$value" ] || continue
102
- total=$((total + $(argocd_quantity_ki "$value")))
103
- done <<<"$lines"
104
- if [ "$total" -lt "$ARGOCD_MIN_MEMORY_KI" ]; then
105
- echo "✖ argocd: at least 1 Gi of allocatable memory is needed in the cluster (available: $((total / 1024)) Mi); enlarge the cluster (Docker Desktop → Settings → Resources), then: devzone workspace services enable argocd" >&2
106
- return 2
107
- fi
108
- }
109
-
110
- # Initial admin password, read with kubectl (go-template base64decode: no
111
- # base64 of the workstation involved), written in workspace/.argocd/admin.env
112
- # (600) and in .password; never printed
113
- argocd_save_admin_password() {
114
- local dir password
115
- dir="$(argocd_secrets_dir)"
116
- password="$(ak -n "$ARGOCD_NS" get secret argocd-initial-admin-secret \
117
- -o go-template='{{.data.password | base64decode}}' 2>/dev/null)" || password=""
118
- if [ -z "$password" ]; then
119
- echo "⚠ argocd: admin password unreadable (secret argocd-initial-admin-secret); .password not updated" >&2
120
- return 0
121
- fi
122
- mkdir -p "$dir"
123
- chmod 700 "$dir"
124
- (
125
- umask 077
126
- printf 'ARGOCD_URL=https://localhost:%s\nARGOCD_USER=admin\nARGOCD_PASSWORD=%s\n' "$ARGOCD_LOCAL_PORT" "$password" >"$dir/admin.env"
127
- )
128
- chmod 600 "$dir/admin.env"
129
- argocd_passwords_refresh
130
- }
131
-
132
- # .password of the workstation regenerated from workspace/.*/ (password.sh of the package)
133
- argocd_passwords_refresh() {
134
- DEVZONE_ROOT="$PWD" devzone passwords regenerate 2>/dev/null ||
135
- echo "⚠ .password not updated (devzone passwords regenerate)" >&2
136
- }
137
-
138
- # Installs Argo CD (pinned chart and values), idempotent (upgrade --install)
139
- argocd_install() {
140
- chart_require argocd || return 2
141
- argocd_memory_ok || return 2
142
- echo "▶ Argo CD $ARGOCD_CHART_VERSION in $ARGOCD_NS (helm, up to ${ARGOCD_WAIT}s)…"
143
- ak create namespace "$ARGOCD_NS" --dry-run=client -o yaml | ak apply -f - >/dev/null
144
- ak label namespace "$ARGOCD_NS" app.kubernetes.io/managed-by=devzone --overwrite >/dev/null
145
- # Wrapper chart: the dependency argo-cd (pinned in Chart.yaml) is built
146
- # first, then installed from the local chart (#538)
147
- helm dependency build "$(argocd_chart)" >/dev/null
148
- # shellcheck disable=SC2046
149
- helm $(helm_flag) upgrade --install argocd "$(argocd_chart)" \
150
- --namespace "$ARGOCD_NS" \
151
- --timeout "${ARGOCD_WAIT}s" --wait || return 1
152
- argocd_save_admin_password
153
- echo "✔ Argo CD ready: https://localhost:$ARGOCD_LOCAL_PORT once devzone workspace ports runs; user admin, password in .password"
154
- }
155
-
156
- # Installs it when wanted and missing (workspace start); a refusal (memory)
157
- # is told and the start goes on with helm direct. A cluster that does not
158
- # answer is not "helm direct": the start has already stopped on it (#565)
159
- argocd_ensure() {
160
- argocd_wanted || return 0
161
- argocd_installed && return 0
162
- if ! "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" kube-ready >/dev/null; then
163
- echo "⚠ Argo CD not checked: the cluster does not answer (devzone workspace services enable argocd once it does)" >&2
164
- return 0
165
- fi
166
- argocd_install || echo "⚠ Argo CD not installed: the workspace is deployed with helm directly (devzone workspace services enable argocd to retry)" >&2
167
- return 0
168
- }
169
-
170
- # Applications removed without cascade (finalizer dropped first: the services
171
- # stay, under helm direct; the GitOps repository keeps its files), then helm
172
- # uninstall and the namespace
173
- argocd_uninstall() {
174
- local app
175
- if argocd_installed; then
176
- echo "▶ Argo CD removal: Applications released (their resources stay), release and namespace deleted…"
177
- while IFS= read -r app; do
178
- [ -n "$app" ] || continue
179
- gitops_direct_delete_application "${app#*/}" keep
180
- done <<<"$(ak -n "$ARGOCD_NS" get applications.argoproj.io -o name 2>/dev/null || true)"
181
- # shellcheck disable=SC2046
182
- helm $(helm_flag) uninstall argocd --namespace "$ARGOCD_NS" >/dev/null 2>&1 || true
183
- ak delete namespace "$ARGOCD_NS" --wait=true --ignore-not-found >/dev/null
184
- fi
185
- rm -rf "$(argocd_secrets_dir)"
186
- argocd_passwords_refresh
187
- echo "✔ Argo CD removed; the services stay, under helm direct"
188
- }
189
-
190
- # Applies the Application <name> of <kind> to <namespace> from <repo> at
191
- # <revision>, <path>; the other arguments are Helm parameters key=value.
192
- # In the GitOps repository when one is designated (gitops.sh), else directly
193
- argocd_apply_application() {
194
- gitops_apply_application "$@"
195
- }
196
-
197
- # Deletes an Application (and its file of the GitOps repository); keep:
198
- # finalizer dropped first, its resources stay
199
- argocd_delete_application() {
200
- gitops_delete_application "$@"
201
- }
202
-
203
- argocd_application_exists() {
204
- ak -n "$ARGOCD_NS" get application.argoproj.io "$1" >/dev/null 2>&1
205
- }
206
-
207
- # Installed or not, then the Applications with their sync and health status
208
- argocd_status() {
209
- if ! argocd_installed; then
210
- echo "○ argocd not installed: devzone workspace services enable argocd"
211
- return 0
212
- fi
213
- if argocd_wanted; then
214
- echo "✔ argocd installed: https://localhost:$ARGOCD_LOCAL_PORT (devzone workspace ports), user admin, password in .password"
215
- else
216
- echo "⚠ argocd installed but argocd=off in .devzone.modules: devzone workspace services enable argocd, or disable to remove it"
217
- fi
218
- if gitops_enabled; then
219
- echo " GitOps repository: $(gitops_repo) (apps/, root Application $GITOPS_ROOT_APP)"
220
- else
221
- echo " no GitOps repository: Applications applied directly (devzone workspace argocd init)"
222
- fi
223
- ak -n "$ARGOCD_NS" get applications.argoproj.io \
224
- -o custom-columns='APPLICATION:.metadata.name,KIND:.metadata.labels.devzone\.io/kind,SYNC:.status.sync.status,HEALTH:.status.health.status,REVISION:.spec.source.targetRevision' \
225
- 2>/dev/null | sed 's/^/ /'
226
- return 0
227
- }