devzone 7.1.0 → 7.2.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.
Files changed (76) hide show
  1. package/.devcontainer/Dockerfile +15 -22
  2. package/.devcontainer/ai/host-check.message +12 -12
  3. package/.devcontainer/ai/host-check.sh +1 -1
  4. package/.devcontainer/catalog/app.sh +5 -12
  5. package/.devcontainer/catalog/catalog-watcher.sh +7 -7
  6. package/.devcontainer/catalog.sh +1 -1
  7. package/.devcontainer/cluster.sh +1 -11
  8. package/.devcontainer/devcontainer.json +1 -11
  9. package/.devcontainer/devzone +19 -23
  10. package/.devcontainer/devzone-ai.sh +1 -1
  11. package/.devcontainer/devzone-cluster.sh +2 -3
  12. package/.devcontainer/devzone-modules.sh +7 -2
  13. package/.devcontainer/devzone-repair.sh +11 -21
  14. package/.devcontainer/devzone-services.sh +21 -20
  15. package/.devcontainer/devzone-status.sh +4 -12
  16. package/.devcontainer/gitlab/demo/.gitlab-ci.yml +1 -1
  17. package/.devcontainer/help.sh +3 -5
  18. package/.devcontainer/isolation.sh +1 -1
  19. package/.devcontainer/kube-account.sh +12 -173
  20. package/.devcontainer/metrics-server.sh +1 -1
  21. package/.devcontainer/packages.sh +3 -3
  22. package/.devcontainer/password.sh +5 -6
  23. package/.devcontainer/ports-json.sh +0 -4
  24. package/.devcontainer/ports.sh +7 -103
  25. package/.devcontainer/services-admin.sh +2 -2
  26. package/.devcontainer/state-json.sh +4 -14
  27. package/.devcontainer/versions.env +2 -2
  28. package/.devcontainer/workspace-init.sh +1 -9
  29. package/Makefile +6 -6
  30. package/README.md +14 -33
  31. package/bin/SHA256SUMS +6 -6
  32. package/bin/devzone-darwin-amd64 +0 -0
  33. package/bin/devzone-darwin-arm64 +0 -0
  34. package/bin/devzone-linux-amd64 +0 -0
  35. package/bin/devzone-linux-arm64 +0 -0
  36. package/bin/devzone-windows-amd64.exe +0 -0
  37. package/bin/devzone-windows-arm64.exe +0 -0
  38. package/manage/devzone +7 -20
  39. package/manage/scripts/ci/check-names.sh +5 -6
  40. package/manage/scripts/ci/ticket-protocol.txt +7 -0
  41. package/manage/scripts/ci/versions-tools-plan.sh +1 -1
  42. package/manage/scripts/devzone-create.sh +4 -4
  43. package/manage/scripts/devzone-update.sh +18 -22
  44. package/manage/scripts/workspace/argocd-services.sh +1 -1
  45. package/manage/scripts/workspace/argocd-workspace.sh +2 -2
  46. package/manage/scripts/workspace/ports-workspace.sh +5 -5
  47. package/manage/scripts/workspace/services-workspace.sh +3 -3
  48. package/manage/scripts/workspace/workspace-update.sh +0 -3
  49. package/manage/workspace.sh +0 -14
  50. package/package.json +1 -1
  51. package/.devcontainer/argocd/argocd.sh +0 -222
  52. package/.devcontainer/argocd/catalog-argocd.sh +0 -119
  53. package/.devcontainer/argocd/services-hook.sh +0 -181
  54. package/.devcontainer/catalog/mysql/install.sh +0 -87
  55. package/.devcontainer/catalog/mysql/mysql.sh +0 -262
  56. package/.devcontainer/catalog/mysql/volume.sh +0 -71
  57. package/.devcontainer/command-aliases.sh +0 -234
  58. package/.devcontainer/git-identity.sh +0 -28
  59. package/.devcontainer/gitlab/argocd.sh +0 -54
  60. package/.devcontainer/gitlab/chart.sh +0 -39
  61. package/.devcontainer/gitlab/gitlab.sh +0 -168
  62. package/.devcontainer/gitlab/installation.sh +0 -193
  63. package/.devcontainer/gitlab/secrets.sh +0 -95
  64. package/.devcontainer/gitlab/seed.sh +0 -204
  65. package/.devcontainer/gitlab/test-gitlab-restes.sh +0 -16
  66. package/.devcontainer/gitlab/test-gitlab.sh +0 -489
  67. package/.devcontainer/kind-wrapper.sh +0 -45
  68. package/.devcontainer/kube-config.sh +0 -78
  69. package/.devcontainer/kube-reachable.sh +0 -64
  70. package/.devcontainer/ports-auto.sh +0 -247
  71. package/.devcontainer/post-create.sh +0 -91
  72. package/.devcontainer/postgres/postgres.sh +0 -309
  73. package/.devcontainer/rename-legacy-files.sh +0 -172
  74. package/.devcontainer/rename-legacy-ports.sh +0 -119
  75. package/.devcontainer/startup.sh +0 -65
  76. package/manage/scripts/ci/check-english.sh +0 -57
@@ -1,262 +0,0 @@
1
- #!/usr/bin/env bash
2
- # MySQL of the catalog (#414): create, list, delete, status, relay-start, relay-stop, install, delete-data.
3
- set -euo pipefail
4
- ICI="$(cd "$(dirname "$0")" && pwd)"
5
- RACINE="${DEVZONE_ROOT:-$(dirname "$(dirname "$(dirname "$ICI")")")}"
6
- ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
7
- # shellcheck source=SCRIPTDIR/../../cluster.sh
8
- # shellcheck disable=SC1091
9
- . "$ICI/../../cluster.sh"
10
- # shellcheck source=SCRIPTDIR/../../password.sh
11
- # shellcheck disable=SC1091
12
- . "$ICI/../../password.sh"
13
- # shellcheck source=SCRIPTDIR/../../isolation.sh
14
- # shellcheck disable=SC1091
15
- . "$ICI/../../isolation.sh"
16
- # shellcheck source=SCRIPTDIR/volume.sh
17
- # shellcheck disable=SC1091
18
- . "$ICI/volume.sh"
19
- # shellcheck source=SCRIPTDIR/install.sh
20
- # shellcheck disable=SC1091
21
- . "$ICI/install.sh"
22
- # The argocd module on: MySQL installed by an Application (#538)
23
- # shellcheck source=SCRIPTDIR/../../argocd/catalog-argocd.sh
24
- # shellcheck disable=SC1091
25
- . "$ICI/../../argocd/catalog-argocd.sh"
26
- NS=devzone-mysql
27
- SECRETS="$RACINE/workspace/.mysql"
28
- MYSQL_PORT="${MYSQL_PORT:-3306}"
29
- MYSQL_IMAGE="${MYSQL_IMAGE:-mysql:8.4}"
30
- MYSQL_MEMOIRE="${MYSQL_MEMOIRE:-1Gi}"
31
- MYSQL_TAILLE="${MYSQL_TAILLE:-5Gi}"
32
- MYSQL_ATTENTE="${MYSQL_ATTENTE:-300}"
33
- # Standard refusal with a message and code 2
34
- refuse() { echo "devzone : catalog mysql : $*" >&2; exit 2; }
35
- # Secret mysql-admin of the services.sh hook: the same as the direct installation
36
- services_secret_mysql() { mysql_secret; }
37
- # Regenerates the .password view (non-blocking failure)
38
- regenerer_identifiants() {
39
- password_regenerate ||
40
- echo "devzone : catalog mysql : grouped credentials not updated (devzone passwords)" >&2
41
- }
42
- # Shortcut for kubectl in the devzone-mysql namespace
43
- k() { kubectl --context devzone -n "$NS" "$@"; }
44
- # Does the devzone-mysql namespace exist? Administrator only (#430)
45
- installed() { account_admin "$(account_context)" get namespace "$NS" >/dev/null 2>&1; }
46
- # Context of the module: the one of the devzone cluster
47
- module_context() {
48
- local c
49
- c="$(cluster_saved)"
50
- [ -n "$c" ] || refuse "no cluster chosen: devzone enable mysql"
51
- echo "$c"
52
- }
53
- # Failure marker of the module (same scheme as devzone's failure_file)
54
- failure_file() { echo "$ETAT-failed-mysql"; }
55
- # Project name: a simple SQL identifier, never escaped, not a reserved name
56
- check_project_name() {
57
- local p="${1:-}"
58
- [ -n "$p" ] || refuse "missing project name"
59
- [[ "$p" =~ ^[a-z][a-z0-9_]{0,62}$ ]] || refuse "invalid project name: $p (lowercase, digits, _; starts with a letter)"
60
- case "$p" in
61
- mysql | information_schema | performance_schema | sys) refuse "reserved name: $p" ;;
62
- esac
63
- }
64
- # Random password for a new project
65
- new_password() { openssl rand -hex 24; }
66
- # Root password: from root.env of an existing installation, else admin-password
67
- root_password() {
68
- local password
69
- password="$(sed -n 's/^MYSQL_PASSWORD=//p' "$SECRETS/root.env" 2>/dev/null | tail -1 || true)"
70
- [ -z "$password" ] && [ -f "$SECRETS/admin-password" ] && password="$(cat "$SECRETS/admin-password" 2>/dev/null || true)"
71
- [ -n "$password" ] || refuse "MySQL root password not found (workspace/.mysql/root.env)"
72
- echo "$password"
73
- }
74
- # mysql as superuser in the pod; the password is never shown
75
- mysql_admin() { k exec -i mysql-0 -c mysql -- mysql -uroot -p"$(root_password)" "$@"; }
76
- # Number of databases, system databases excluded
77
- database_count() {
78
- local n
79
- n="$(mysql_admin -N -B -e "SHOW DATABASES" 2>/dev/null | grep -vE '^(information_schema|mysql|performance_schema|sys)$' | grep -c . || true)"
80
- echo "${n:-0}"
81
- }
82
- # Installs the module (the Argo CD path when the argocd module is on)
83
- install_module() {
84
- local CTX claim
85
- CTX="$(module_context)"
86
- if ! devzone_context_set "$CTX"; then
87
- echo "devzone : catalog mysql : cannot set the devzone context on $CTX" >&2
88
- return 1
89
- fi
90
- echo "▶ MySQL on cluster $CTX (namespace $NS)…"
91
- if catalogue_argocd_active mysql; then
92
- mysql_install_argocd "$CTX"
93
- return
94
- fi
95
- account_namespace "$CTX" "$NS"
96
- namespace_isolate "$NS" >/dev/null
97
- if k get statefulset mysql >/dev/null 2>&1; then
98
- echo "devzone : catalog mysql : existing installation in $NS, adopted (volume and root.env kept)"
99
- else
100
- mysql_secret
101
- claim="$(mysql_claim_choose "$NS")" || return 2
102
- mysql_apply_chart "$NS" "$claim" || return 1
103
- if ! k rollout status statefulset/mysql --timeout="${MYSQL_ATTENTE}s" >/dev/null; then
104
- echo "devzone : catalog mysql : not ready after ${MYSQL_ATTENTE}s: kubectl --context $CTX -n $NS describe pod mysql-0" >&2
105
- return 1
106
- fi
107
- fi
108
- mysql_secret
109
- relay_start mysql "$CTX" "$NS" svc/mysql 3306:3306
110
- echo "✔ MySQL ready: 127.0.0.1:$MYSQL_PORT in the container"
111
- regenerer_identifiants
112
- }
113
- # Deletes the namespace (so the PVCs), keeps workspace/.mysql (#441):
114
- # terminal confirmation [y/N], --yes required otherwise (refusal, code 2)
115
- delete_data() {
116
- local CTX yes="" arg answer
117
- for arg in "$@"; do
118
- case "$arg" in
119
- --yes) yes=1 ;;
120
- *) refuse "unknown argument: $arg" ;;
121
- esac
122
- done
123
- if [ -z "$yes" ]; then
124
- cluster_interactive || refuse "confirmation needs a terminal: devzone mysql delete-data --yes"
125
- printf 'Delete namespace %s and all its volumes? [y/N] ' "$NS" >&2
126
- read -r answer || answer=""
127
- case "$answer" in
128
- y | Y | yes) ;;
129
- *) echo "Aborted: nothing was deleted."; return 0 ;;
130
- esac
131
- fi
132
- CTX="$(cluster_saved)"
133
- [ -n "$CTX" ] || refuse "no cluster chosen: devzone enable mysql"
134
- installed || refuse "module disabled: devzone enable mysql"
135
- echo "▶ Deleting MySQL and its volumes on ${CTX}…"
136
- # The Application goes first (#538): otherwise Argo CD recreates the namespace
137
- catalogue_argocd_delete mysql >/dev/null 2>&1 || true
138
- # RoleBinding removed, then the namespace deleted by the administrator (#430)
139
- account_remove "$CTX" "$NS" >/dev/null 2>&1 || true
140
- account_admin "$CTX" delete namespace "$NS" --wait=true >/dev/null
141
- relay_stop mysql
142
- rm -f "$(failure_file)"
143
- echo "✔ namespace $NS and volume deleted; workspace/.mysql/root.env kept"
144
- regenerer_identifiants
145
- }
146
- # State (disabled, failed, ready, relay stopped): read by devzone, keep the words
147
- module_status() {
148
- local CTX
149
- CTX="$(cluster_saved)"
150
- if [ -z "$CTX" ] || ! installed; then
151
- echo "disabled"
152
- return 0
153
- fi
154
- if [ "$(k get statefulset mysql -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" != 1 ]; then
155
- echo "failed on $CTX: devzone apply"
156
- return 0
157
- fi
158
- if ! relay_active mysql; then
159
- echo "ready on $CTX, relay stopped: devzone apply"
160
- return 0
161
- fi
162
- echo "ready on $CTX: 127.0.0.1:$MYSQL_PORT, $(database_count) database(s)"
163
- }
164
- # Creates the user and the database of a project; .env in 600, password kept
165
- create_project() {
166
- local project="${1:-}" renew="" file password arg
167
- check_project_name "$project"
168
- for arg in "${@:2}"; do
169
- case "$arg" in
170
- --new-password) renew=1 ;;
171
- *) refuse "unknown argument: $arg" ;;
172
- esac
173
- done
174
- CTX="$(module_context)"
175
- installed || refuse "module disabled: devzone enable mysql"
176
- file="$SECRETS/$project.env"
177
- if [ -z "$renew" ] && [ -s "$file" ]; then
178
- password="$(sed -n 's/^MYSQL_PASSWORD=//p' "$file" 2>/dev/null | tail -1)"
179
- else
180
- password="$(new_password)"
181
- fi
182
- mysql_admin <<SQL
183
- CREATE USER IF NOT EXISTS '$project'@'%' IDENTIFIED BY '$password';
184
- ALTER USER '$project'@'%' IDENTIFIED BY '$password';
185
- CREATE DATABASE IF NOT EXISTS $project;
186
- GRANT ALL ON $project.* TO '$project'@'%';
187
- SQL
188
- mkdir -p "$SECRETS"
189
- chmod 700 "$SECRETS"
190
- (
191
- umask 077
192
- cat >"$file" <<ENV
193
- MYSQL_HOST=127.0.0.1
194
- MYSQL_PORT=$MYSQL_PORT
195
- MYSQL_USER=$project
196
- MYSQL_PASSWORD=$password
197
- MYSQL_URL=jdbc:mysql://127.0.0.1:$MYSQL_PORT/$project
198
- ENV
199
- )
200
- echo "✔ database $project ready; credentials: $file"
201
- regenerer_identifiants
202
- }
203
- # Lists the databases of the server
204
- list_databases() {
205
- local CTX
206
- CTX="$(module_context)"
207
- installed || refuse "module disabled: devzone enable mysql"
208
- # grep -v exits 1 with no user database: under pipefail, the list stays at 0
209
- mysql_admin -N -B -e "SHOW DATABASES" 2>/dev/null |
210
- { grep -vE '^(information_schema|mysql|performance_schema|sys)$' || true; } |
211
- awk 'BEGIN { n = 0 } { printf " %-30s\n", $1; n++ } END { if (n == 0) print " (no database: devzone mysql create <project>)" }'
212
- }
213
- # Deletes the database and the user of a project (confirmation without --yes)
214
- delete_project() {
215
- local project="${1:-}" yes="" arg answer
216
- check_project_name "$project"
217
- for arg in "${@:2}"; do
218
- case "$arg" in
219
- --yes) yes=1 ;;
220
- *) refuse "unknown argument: $arg" ;;
221
- esac
222
- done
223
- CTX="$(module_context)"
224
- installed || refuse "module disabled: devzone enable mysql"
225
- if [ -z "$yes" ]; then
226
- cluster_interactive || refuse "confirmation needs a terminal: devzone mysql delete $project --yes"
227
- printf 'Delete database %s and its user? [y/N] ' "$project" >&2
228
- read -r answer || answer=""
229
- case "$answer" in
230
- y | Y | yes) ;;
231
- *) echo "Aborted: nothing was deleted."; return 0 ;;
232
- esac
233
- fi
234
- mysql_admin <<SQL
235
- DROP DATABASE IF EXISTS $project;
236
- DROP USER IF EXISTS '$project'@'%';
237
- SQL
238
- rm -f "$SECRETS/$project.env"
239
- echo "✔ database $project deleted"
240
- regenerer_identifiants
241
- }
242
- # Restarts the relay 127.0.0.1:3306 if the namespace exists
243
- relay_restart() {
244
- local CTX
245
- CTX="$(cluster_saved)"
246
- [ -n "$CTX" ] && installed && relay_start mysql "$CTX" "$NS" svc/mysql 3306:3306
247
- }
248
- case "${1:-}" in
249
- install) install_module ;;
250
- delete-data) delete_data "${@:2}" ;;
251
- status) module_status ;;
252
- create) create_project "${@:2}" ;;
253
- list) list_databases ;;
254
- delete) delete_project "${@:2}" ;;
255
- volume) mysql_volume "$NS" "${@:2}" ;;
256
- relay-start) relay_restart ;;
257
- relay-stop) relay_stop mysql ;;
258
- *)
259
- echo "devzone : catalog mysql : create <project> [--new-password] | list | delete <project> [--yes] | volume [<name>] [--delete <name>] [--yes] | delete-data [--yes]" >&2
260
- exit 1
261
- ;;
262
- esac
@@ -1,71 +0,0 @@
1
- #!/usr/bin/env bash
2
- # MySQL volumes (#440): choice, listing and deletion of the -mysql-0 PVCs.
3
-
4
- # Lists the PVCs of the namespace whose name ends with -mysql-0
5
- mysql_volumes() {
6
- local ns="$1"
7
- kubectl --context devzone -n "$ns" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null |
8
- grep -E '\-mysql-0$' || true
9
- }
10
-
11
- # Claim prefix: 1 PVC -> its prefix, 0 -> donnees, >1 -> refusal (code 2)
12
- mysql_claim_choose() {
13
- local ns="$1" list count
14
- list="$(mysql_volumes "$ns")"
15
- if [ -z "$list" ]; then echo donnees; return 0; fi
16
- count="$(printf '%s\n' "$list" | grep -c .)"
17
- if [ "$count" -eq 1 ]; then echo "${list%-mysql-0}"; return 0; fi
18
- echo "devzone : catalog mysql : several volumes found:" >&2
19
- printf '%s\n' "$list" | sed 's/^/ /' >&2
20
- echo "devzone : catalog mysql : choose one with devzone mysql volume <name>" >&2
21
- return 2
22
- }
23
-
24
- # Claim carried by the StatefulSet (empty if absent)
25
- mysql_claim_mounted() {
26
- local ns="$1"
27
- kubectl --context devzone -n "$ns" get statefulset mysql \
28
- -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true
29
- }
30
-
31
- # volume subcommand: lists, or selects/deletes a PVC
32
- mysql_volume() {
33
- local ns="$1" name="" yes="" delete="" arg answer pvc mounted claim
34
- shift
35
- for arg in "$@"; do
36
- case "$arg" in
37
- --delete) delete=1 ;;
38
- --yes) yes=1 ;;
39
- *) name="$arg" ;;
40
- esac
41
- done
42
- if [ -n "$delete" ]; then
43
- [ -n "$name" ] || refuse "volume --delete: missing name"
44
- pvc="$name"
45
- [[ "$pvc" == *-mysql-0 ]] || pvc="$pvc-mysql-0"
46
- mounted="$(mysql_claim_mounted "$ns")"
47
- [ "${pvc%-mysql-0}" != "$mounted" ] || refuse "mounted volume, deletion refused: $name"
48
- if [ -z "$yes" ]; then
49
- cluster_interactive || refuse "confirmation needs a terminal: devzone mysql volume --delete $name --yes"
50
- printf 'Delete volume %s? [y/N] ' "$pvc" >&2
51
- read -r answer || answer=""
52
- case "$answer" in
53
- y | Y | yes) ;;
54
- *) echo "Aborted: nothing was deleted."; return 0 ;;
55
- esac
56
- fi
57
- kubectl --context devzone -n "$ns" delete pvc "$pvc" >/dev/null
58
- echo "✔ volume $pvc deleted"
59
- return 0
60
- fi
61
- if [ -z "$name" ]; then
62
- mounted="$(mysql_claim_mounted "$ns")"
63
- mysql_volumes "$ns" | awk -v m="$mounted-mysql-0" 'NF { mark = ($0 == m) ? " (mounted)" : ""; printf " %s%s\n", $0, mark; n++ } END { if (!n) print " (no volume)" }'
64
- return 0
65
- fi
66
- module_context >/dev/null
67
- installed || refuse "module disabled: devzone enable mysql"
68
- claim="$name"
69
- [[ "$claim" == *-mysql-0 ]] && claim="${claim%-mysql-0}"
70
- mysql_install_claim "$ns" "$claim"
71
- }
@@ -1,234 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Renamed names of the devzone CLI (#695): the French names of the commands,
3
- # subcommands and options are no longer accepted, they are refused. Each old
4
- # name prints « ✖ « old » was renamed: devzone new » on stderr, exits with
5
- # code 1 and does nothing (no folder is created: « devzone stop » creates ./stop,
6
- # « devzone mettre-a-jour » must not create ./mettre-a-jour).
7
- #
8
- # renamed_command <name> : English name of a renamed command, or 1
9
- # renamed_subcommand <command> <name> : English name of a renamed subcommand, or 1
10
- # renamed_option <option> : English name of a renamed option, or 1
11
- # renamed_module <name> : new name of a renamed module (argument of
12
- # enable, disable, is-enabled, apply), or 1
13
- # reject_renamed <command> <args...> : refuses the first renamed name of a call
14
- # (command, first word that is not an
15
- # option, then each option); 0 if none
16
- #
17
- # bash 3.2 (macOS): case only, no associative array.
18
-
19
- # English name of a renamed command, or return 1.
20
- renamed_command() {
21
- case "${1:-}" in
22
- actif) echo is-enabled ;;
23
- activer) echo enable ;;
24
- desactiver) echo disable ;;
25
- ia) echo ai ;;
26
- aide) echo help ;;
27
- appliquer) echo apply ;;
28
- catalogue) echo catalog ;;
29
- demarrer) echo start ;;
30
- arreter) echo stop ;;
31
- etat) echo status ;;
32
- mots-de-passe) echo passwords ;;
33
- paquets) echo packages ;;
34
- plateforme) echo platform ;;
35
- reparer) echo repair ;;
36
- utiliser) echo use ;;
37
- mettre-a-jour) echo update ;;
38
- desinstaller) echo uninstall ;;
39
- copier-vers) echo copy-to ;;
40
- copier-depuis) echo copy-from ;;
41
- *) return 1 ;;
42
- esac
43
- }
44
-
45
- # English name of a renamed subcommand of <command> (English name), or return 1.
46
- renamed_subcommand() {
47
- local command="${1:-}" word="${2:-}"
48
- case "$command" in
49
- postgres | mysql)
50
- case "$word" in
51
- creer) echo create ;;
52
- liste) echo list ;;
53
- supprimer) echo delete ;;
54
- supprimer-donnees) echo delete-data ;;
55
- etat) echo status ;;
56
- installer) echo install ;;
57
- desinstaller) echo uninstall ;;
58
- relais-lancer) echo relay-start ;;
59
- relais-arreter) echo relay-stop ;;
60
- autoriser) echo authorize ;;
61
- interdire) echo forbid ;;
62
- *) return 1 ;;
63
- esac
64
- ;;
65
- gitlab)
66
- case "$word" in
67
- migrer) echo migrate ;;
68
- nouveau-mdp) echo new-password ;;
69
- etat) echo status ;;
70
- installer) echo install ;;
71
- desinstaller) echo uninstall ;;
72
- relais-lancer) echo relay-start ;;
73
- relais-arreter) echo relay-stop ;;
74
- relais-etat) echo relay-status ;;
75
- *) return 1 ;;
76
- esac
77
- ;;
78
- argocd)
79
- case "$word" in
80
- etat) echo status ;;
81
- installer) echo install ;;
82
- desinstaller) echo uninstall ;;
83
- relais-lancer) echo relay-start ;;
84
- relais-arreter) echo relay-stop ;;
85
- *) return 1 ;;
86
- esac
87
- ;;
88
- packages)
89
- case "$word" in
90
- ajouter) echo add ;;
91
- retirer) echo remove ;;
92
- appliquer) echo apply ;;
93
- lister) echo list ;;
94
- *) return 1 ;;
95
- esac
96
- ;;
97
- catalog)
98
- case "$word" in
99
- synchroniser) echo sync ;;
100
- appliquer) echo apply ;;
101
- lister) echo list ;;
102
- desinstaller) echo remove ;;
103
- *) return 1 ;;
104
- esac
105
- ;;
106
- port)
107
- case "$word" in
108
- ouvrir) echo open ;;
109
- fermer) echo close ;;
110
- liste) echo list ;;
111
- relancer) echo restart ;;
112
- exclure) echo exclude ;;
113
- inclure) echo include ;;
114
- *) return 1 ;;
115
- esac
116
- ;;
117
- workspace)
118
- case "$word" in
119
- demarrer) echo start ;;
120
- mettre-a-jour) echo update ;;
121
- arreter) echo stop ;;
122
- etat) echo status ;;
123
- copier-vers) echo copy-to ;;
124
- copier-depuis) echo copy-from ;;
125
- aide) echo help ;;
126
- *) return 1 ;;
127
- esac
128
- ;;
129
- "workspace ports")
130
- case "$word" in
131
- demarrer) echo start ;;
132
- arreter) echo stop ;;
133
- etat) echo status ;;
134
- *) return 1 ;;
135
- esac
136
- ;;
137
- agent)
138
- case "$word" in
139
- etat) echo state ;;
140
- liberer) echo release ;;
141
- aide) echo help ;;
142
- *) return 1 ;;
143
- esac
144
- ;;
145
- *) return 1 ;;
146
- esac
147
- }
148
-
149
- # English name of a renamed option, or return 1.
150
- renamed_option() {
151
- case "${1:-}" in
152
- --fermer) echo --close ;;
153
- --supprimer) echo --delete ;;
154
- --nouveau-mdp) echo --new-password ;;
155
- --oui) echo --yes ;;
156
- --confirmer) echo --confirm ;;
157
- --contexte) echo --context ;;
158
- --modele) echo --model ;;
159
- --tous) echo --all ;;
160
- --sans-reconstruire) echo --no-rebuild ;;
161
- *) return 1 ;;
162
- esac
163
- }
164
-
165
- # New name of a renamed module, or return 1. Modules are not commands: the
166
- # message names the module only (« ia » was renamed: ai).
167
- renamed_module() {
168
- case "${1:-}" in
169
- ia) echo ai ;;
170
- *) return 1 ;;
171
- esac
172
- }
173
-
174
- # Names removed in 3.0 (#735): refused with the same exit code, with a notice
175
- # that names no former feature and never creates a folder.
176
- removed_notice() {
177
- echo "✖ this command or option was removed in devzone 3.0 (see manage/docs/migrating-to-3.md)" >&2
178
- return 1
179
- }
180
-
181
- # reject_renamed <command> <args...> : checks the command itself (top level),
182
- # the first word of <args> that is not an option (subcommand), then every
183
- # option. The first renamed name prints its message on stderr and returns 1;
184
- # nothing is run. Returns 0 when no name is renamed.
185
- reject_renamed() {
186
- local command="${1:-}" word new
187
- if [ "$#" -gt 0 ]; then shift; fi
188
- case "$command" in
189
- migrer | revenir | nettoyer-docker) removed_notice; return 1 ;;
190
- esac
191
- if new="$(renamed_command "$command")"; then
192
- # these commands only exist under « devzone workspace »
193
- case "$command" in
194
- copier-vers | copier-depuis) new="workspace $new" ;;
195
- esac
196
- printf '✖ « %s » was renamed: devzone %s\n' "$command" "$new" >&2
197
- return 1
198
- fi
199
- for word in "$@"; do
200
- case "$word" in
201
- -*) continue ;;
202
- esac
203
- if [ "$command" = workspace ]; then
204
- case "$word" in
205
- migrer | revenir | nettoyer-docker) removed_notice; return 1 ;;
206
- esac
207
- fi
208
- case "$command" in
209
- enable | disable | is-enabled | apply)
210
- if new="$(renamed_module "$word")"; then
211
- printf '✖ « %s » was renamed: %s\n' "$word" "$new" >&2
212
- return 1
213
- fi
214
- ;;
215
- esac
216
- if new="$(renamed_subcommand "$command" "$word")"; then
217
- printf '✖ « %s » was renamed: devzone %s %s\n' "$word" "$command" "$new" >&2
218
- return 1
219
- fi
220
- break
221
- done
222
- for word in "$@"; do
223
- case "$word" in
224
- --rapatrier) removed_notice; return 1 ;;
225
- -*)
226
- if new="$(renamed_option "$word")"; then
227
- printf '✖ « %s » was renamed: %s\n' "$word" "$new" >&2
228
- return 1
229
- fi
230
- ;;
231
- esac
232
- done
233
- return 0
234
- }
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Git identity, at each startup as long as it is missing: deduced from the gh
3
- # account (specific to each user, connection kept in their volume) and written
4
- # into ~/.config/git/config (devzone-git volume, survives rebuilds).
5
- # An identity already set (by hand, or copied by VS Code into ~/.gitconfig) is
6
- # never replaced. GitHub noreply email: commits are attached to the account
7
- # without exposing the personal email.
8
- set -euo pipefail
9
-
10
- CONFIG="$HOME/.config/git/config"
11
- name_git="$(git config --get user.name || true)"
12
- email_git="$(git config --get user.email || true)"
13
-
14
- [ -n "$name_git" ] && [ -n "$email_git" ] && exit 0
15
-
16
- # Without gh: nothing to deduce; the devzone summary reports it
17
- gh auth status >/dev/null 2>&1 || exit 0
18
-
19
- id="" login="" name=""
20
- IFS=$'\t' read -r id login name < <(gh api user --jq '[.id, .login, (.name // "")] | @tsv' 2>/dev/null || true)
21
- if [ -z "$id" ] || [ -z "$login" ]; then
22
- echo "git-identity : GitHub account unreadable (network?); run again: bash .devcontainer/git-identity.sh"
23
- exit 0
24
- fi
25
-
26
- [ -n "$name_git" ] || git config --file "$CONFIG" user.name "${name:-$login}"
27
- [ -n "$email_git" ] || git config --file "$CONFIG" user.email "${id}+${login}@users.noreply.github.com"
28
- echo "git-identity : $(git config --get user.name) <$(git config --get user.email)>"
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env bash
2
- # GitLab held by Argo CD (#538): with the module argocd on and installed, the
3
- # installation is the Application devzone-gitlab on the wrapper chart
4
- # charts/devzone-gitlab at the revision, instead of a helm pass (chart.sh).
5
- # The Rails secret is re-applied before it (installation.sh), the seed runs
6
- # once GitLab answers (seed.sh); the runner token goes to the Secret
7
- # gitlab-runner-secret written by the seed, out of Git.
8
- # Sourced by installation.sh (through gitlab.sh). bash 3.2 (macOS).
9
- # gitlab_argocd_active module argocd on, chart present, revision
10
- # gitlab_release_adopter helm release of before Argo CD: its release
11
- # secrets removed, the objects are adopted
12
- # gitlab_application_apply the Application devzone-gitlab
13
- # gitlab_application_retirer the Application removed (namespace kept)
14
-
15
- # The catalogue side of Argo CD (module on, chart, revision, Application)
16
- # shellcheck source=SCRIPTDIR/../argocd/catalog-argocd.sh
17
- # shellcheck disable=SC1091
18
- . "$ICI/../argocd/catalog-argocd.sh"
19
-
20
- # The module argocd is on, the namespace devzone-argocd is installed, the chart
21
- # is in the repository and the revision is known: a development clone (version
22
- # 0.0.0) keeps the helm-direct path, like the catalogue applications
23
- gitlab_argocd_active() {
24
- catalogue_argocd_active gitlab
25
- }
26
-
27
- # Argo CD takes over the objects of a helm release gitlab: the release secrets
28
- # (sh.helm.release.v1.gitlab.*) go, so that helm no longer owns the objects
29
- gitlab_release_adopter() {
30
- kubectl --context devzone -n "$GITLAB_NS" delete secret \
31
- -l owner=helm,name=gitlab --ignore-not-found >/dev/null 2>&1 || true
32
- }
33
-
34
- # The Application on charts/devzone-gitlab at the revision, in the namespace of
35
- # the instance; the internal URL of the webservice follows that namespace
36
- # (chart value not templated, passed as a helm parameter, as in chart.sh)
37
- gitlab_application_apply() {
38
- catalogue_argocd_load
39
- chart_require gitlab || return $?
40
- echo "▶ Application devzone-gitlab (Argo CD, charts/devzone-gitlab at $(argocd_revision))…"
41
- gitops_apply_application devzone-gitlab service "$GITLAB_NS" \
42
- "$DEVZONE_REPO_URL" "$(argocd_revision)" "charts/devzone-gitlab" \
43
- "gitlab-runner.gitlabUrl=http://gitlab-webservice-default.$GITLAB_NS.svc:8181" || return 1
44
- # Argo CD reads Git every 3 min: an immediate refresh of the Application
45
- kubectl --context devzone -n devzone-argocd annotate application.argoproj.io \
46
- devzone-gitlab argocd.argoproj.io/refresh=normal --overwrite >/dev/null 2>&1 || true
47
- }
48
-
49
- # The Application removed when GitLab is uninstalled: its resources leave with
50
- # it; nothing to do when the module argocd is off or the Application is absent
51
- gitlab_application_retirer() {
52
- catalogue_argocd_application_exists gitlab || return 0
53
- catalogue_argocd_delete gitlab
54
- }