devzone 1.1.0 → 3.0.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 (118) hide show
  1. package/.devcontainer/Dockerfile +4 -4
  2. package/.devcontainer/{agent-erreurs.sh → agent-errors.sh} +6 -6
  3. package/.devcontainer/agent-local.sh +2 -2
  4. package/.devcontainer/{agent-modele.messages → agent-model.messages} +1 -1
  5. package/.devcontainer/{agent-modele.sh → agent-model.sh} +5 -5
  6. package/.devcontainer/agent-pod-manifest.sh +4 -4
  7. package/.devcontainer/{agent-droits.sh → agent-rights.sh} +2 -2
  8. package/.devcontainer/agent-session.sh +3 -3
  9. package/.devcontainer/{agent-etat-json.sh → agent-state-json.sh} +6 -6
  10. package/.devcontainer/agent-workspace.sh +1 -1
  11. package/.devcontainer/agent.sh +14 -14
  12. package/.devcontainer/{ia/docker-garde.sh → ai/docker-guard.sh} +1 -1
  13. package/.devcontainer/{ia → ai}/host-models.sh +2 -2
  14. package/.devcontainer/{ia/plugins/devzone-garde-v2.js → ai/plugins/devzone-guard-v2.js} +7 -7
  15. package/.devcontainer/{ia/plugins/devzone-garde.js → ai/plugins/devzone-guard.js} +6 -6
  16. package/.devcontainer/argocd/argocd.sh +94 -93
  17. package/.devcontainer/argocd/{catalogue-argocd.sh → catalog-argocd.sh} +3 -3
  18. package/.devcontainer/argocd/services-hook.sh +8 -8
  19. package/.devcontainer/argocd/services.sh +1 -1
  20. package/.devcontainer/catalog/app.sh +209 -0
  21. package/.devcontainer/catalog/catalog-watcher.sh +130 -0
  22. package/.devcontainer/{catalogue → catalog}/mysql/app.conf +1 -1
  23. package/.devcontainer/catalog/mysql/install.sh +87 -0
  24. package/.devcontainer/catalog/mysql/mysql.sh +262 -0
  25. package/.devcontainer/catalog/mysql/volume.sh +71 -0
  26. package/.devcontainer/catalog.sh +231 -0
  27. package/.devcontainer/chart-direct.sh +1 -1
  28. package/.devcontainer/cluster.sh +222 -224
  29. package/.devcontainer/clusters.sh +41 -41
  30. package/.devcontainer/devcontainer.json +1 -1
  31. package/.devcontainer/devzone +103 -1506
  32. package/.devcontainer/devzone-ai-guard.sh +76 -0
  33. package/.devcontainer/devzone-ai.sh +201 -0
  34. package/.devcontainer/devzone-cluster.sh +210 -0
  35. package/.devcontainer/devzone-modules.sh +126 -0
  36. package/.devcontainer/devzone-platform.sh +189 -0
  37. package/.devcontainer/devzone-repair.sh +94 -0
  38. package/.devcontainer/devzone-services.sh +241 -0
  39. package/.devcontainer/devzone-skill.sh +97 -0
  40. package/.devcontainer/devzone-status.sh +140 -0
  41. package/.devcontainer/devzone-version.sh +78 -0
  42. package/.devcontainer/git-identity.sh +28 -0
  43. package/.devcontainer/gitlab/argocd.sh +2 -2
  44. package/.devcontainer/gitlab/chart.sh +2 -2
  45. package/.devcontainer/gitlab/gitlab.sh +83 -84
  46. package/.devcontainer/gitlab/installation.sh +111 -111
  47. package/.devcontainer/gitlab/secrets.sh +47 -47
  48. package/.devcontainer/gitlab/seed.sh +77 -77
  49. package/.devcontainer/gitlab/test-gitlab.sh +242 -243
  50. package/.devcontainer/help.sh +1 -1
  51. package/.devcontainer/isolation.sh +65 -0
  52. package/.devcontainer/kind-wrapper.sh +45 -0
  53. package/.devcontainer/kube-account.sh +199 -0
  54. package/.devcontainer/kube-config.sh +45 -46
  55. package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
  56. package/.devcontainer/kube-reachable.sh +64 -0
  57. package/.devcontainer/{memoire.sh → memory.sh} +1 -1
  58. package/.devcontainer/metrics-server.sh +2 -2
  59. package/.devcontainer/opencode.jsonc +2 -2
  60. package/.devcontainer/packages.sh +228 -0
  61. package/.devcontainer/password.sh +1 -1
  62. package/.devcontainer/ports-auto.sh +152 -153
  63. package/.devcontainer/ports-json.sh +16 -15
  64. package/.devcontainer/ports.sh +127 -123
  65. package/.devcontainer/post-create.sh +52 -52
  66. package/.devcontainer/postgres/postgres.sh +176 -176
  67. package/.devcontainer/rename-legacy-files.sh +103 -0
  68. package/.devcontainer/services-admin.sh +5 -5
  69. package/.devcontainer/skills/devzone/SKILL.md +40 -41
  70. package/.devcontainer/startup.sh +65 -0
  71. package/.devcontainer/{etat-gitops.sh → state-gitops.sh} +1 -1
  72. package/.devcontainer/{etat-json.sh → state-json.sh} +39 -65
  73. package/.devcontainer/{etat-verrou.sh → state-lock.sh} +1 -1
  74. package/.devcontainer/{etat.sh → state.sh} +4 -4
  75. package/.devcontainer/workspace-init.sh +17 -3
  76. package/Makefile +8 -8
  77. package/README.md +195 -194
  78. package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
  79. package/manage/devzone +8 -10
  80. package/manage/scripts/argocd-workspace.sh +1 -1
  81. package/manage/scripts/check-go-layout.sh +40 -0
  82. package/manage/scripts/check-names.sh +61 -0
  83. package/manage/scripts/create-cluster.sh +1 -1
  84. package/manage/scripts/create-mode.sh +2 -2
  85. package/manage/scripts/devzone-create.sh +5 -5
  86. package/manage/scripts/devzone-manifest.sh +3 -3
  87. package/manage/scripts/devzone-update.sh +12 -8
  88. package/manage/scripts/docker-workstation.sh +2 -2
  89. package/manage/scripts/docker.sh +2 -2
  90. package/manage/scripts/{lancer.sh → launch.sh} +10 -51
  91. package/manage/scripts/{migrer-retour.sh → migrate-revert.sh} +4 -4
  92. package/manage/scripts/{migrer.sh → migrate.sh} +8 -14
  93. package/manage/scripts/ports-apps.sh +1 -1
  94. package/manage/scripts/ports-workspace.sh +7 -7
  95. package/manage/scripts/{desinstaller.sh → uninstall.sh} +8 -8
  96. package/manage/scripts/workspace-egress.sh +2 -2
  97. package/manage/scripts/workspace-update.sh +5 -2
  98. package/manage/scripts/workspace-wait.sh +2 -2
  99. package/manage/workspace.sh +4 -4
  100. package/package.json +1 -1
  101. package/.devcontainer/catalogue/app.sh +0 -211
  102. package/.devcontainer/catalogue/catalogue-veilleur.sh +0 -130
  103. package/.devcontainer/catalogue/mysql/installer.sh +0 -87
  104. package/.devcontainer/catalogue/mysql/mysql.sh +0 -262
  105. package/.devcontainer/catalogue/mysql/volume.sh +0 -71
  106. package/.devcontainer/catalogue.sh +0 -231
  107. package/.devcontainer/demarrage.sh +0 -66
  108. package/.devcontainer/docker-relais.sh +0 -149
  109. package/.devcontainer/docker-sans-hote.sh +0 -12
  110. package/.devcontainer/git-identite.sh +0 -28
  111. package/.devcontainer/isolement.sh +0 -65
  112. package/.devcontainer/kind-enveloppe.sh +0 -45
  113. package/.devcontainer/kube-compte.sh +0 -200
  114. package/.devcontainer/kube-joignable.sh +0 -64
  115. package/.devcontainer/paquets.sh +0 -227
  116. /package/.devcontainer/{ia/docker-garde.message → ai/docker-guard.message} +0 -0
  117. /package/.devcontainer/{ia → ai}/host-check.message +0 -0
  118. /package/.devcontainer/{ia → ai}/host-check.sh +0 -0
@@ -0,0 +1,231 @@
1
+ #!/usr/bin/env bash
2
+ # Application catalog (#414): one preconfigured application per folder
3
+ # .devcontainer/catalog/<app>/ (app.conf; the chart charts/devzone-<app>, #559),
4
+ # installed in the devzone services cluster under the namespace of its app.conf;
5
+ # the wanted state is the line <app>=on|off of .devzone.modules.
6
+ # catalog.sh sync | apply | list | resume | json | remove <app>
7
+ set -euo pipefail
8
+
9
+ ICI="$(cd "$(dirname "$0")" && pwd)"
10
+ RACINE="${DEVZONE_ROOT:-$(dirname "$ICI")}"
11
+ ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
12
+ # shellcheck source=SCRIPTDIR/cluster.sh
13
+ # shellcheck disable=SC1091
14
+ . "$ICI/cluster.sh"
15
+ # shellcheck source=SCRIPTDIR/state.sh
16
+ # shellcheck disable=SC1091
17
+ . "$ICI/state.sh"
18
+ # shellcheck source=SCRIPTDIR/password.sh
19
+ # shellcheck disable=SC1091
20
+ . "$ICI/password.sh"
21
+ # shellcheck source=SCRIPTDIR/isolation.sh
22
+ # shellcheck disable=SC1091
23
+ . "$ICI/isolation.sh"
24
+ # shellcheck source=SCRIPTDIR/catalog/app.sh
25
+ # shellcheck disable=SC1091
26
+ . "$ICI/catalog/app.sh"
27
+
28
+ refuse() { echo "devzone : catalog : $*" >&2; exit 2; }
29
+
30
+ # Catalog folder (overridable by the tests)
31
+ catalog_dir() { echo "${DEVZONE_CATALOG:-$ICI/catalog}"; }
32
+
33
+ # Catalog applications: folders holding an app.conf, sorted
34
+ catalog_apps() {
35
+ local d
36
+ for d in "$(catalog_dir)"/*; do
37
+ [ -f "$d/app.conf" ] || continue
38
+ echo "${d##*/}"
39
+ done | LC_ALL=C sort
40
+ }
41
+
42
+ # app.conf key (name, description, image, port, memoire, taille, namespace)
43
+ app_read() {
44
+ grep -E "^$2=" "$(catalog_dir)/$1/app.conf" 2>/dev/null | tail -1 | cut -d= -f2- || true
45
+ }
46
+
47
+ # Application namespace: the one of app.conf (required)
48
+ app_namespace() {
49
+ local ns
50
+ ns="$(app_read "$1" namespace)"
51
+ [ -n "$ns" ] || refuse "missing namespace in app.conf of $1"
52
+ echo "$ns"
53
+ }
54
+
55
+ # Failure marker of an application: same scheme as the failure file of the modules
56
+ failure_file() { echo "$ETAT-failed-$1"; }
57
+
58
+ # Wanted state: on if the line <app>=on exists, off by default
59
+ wanted() {
60
+ local v
61
+ v="$(grep -E "^$1=" "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
62
+ [ "$v" = on ] && echo on || echo off
63
+ }
64
+
65
+ # Application present in the cluster. In the Kubernetes workspace pod: its
66
+ # service resolves in the cluster DNS (no RBAC needed, #515). Elsewhere: labelled
67
+ # namespace and StatefulSet of the app name; reading the namespaces is reserved
68
+ # to the administrator (#430). Nothing without a chosen cluster or when absent.
69
+ present() {
70
+ local ctx ns
71
+ ns="$(app_namespace "$1")"
72
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
73
+ # In the pod there is no kubeconfig and the limited service account
74
+ # cannot list StatefulSets (#430): presence is the cluster DNS
75
+ # resolving the service, no RBAC needed, the pod service account
76
+ # stays limited
77
+ getent hosts "$(app_read "$1" name).${ns}.svc" >/dev/null 2>&1
78
+ return
79
+ fi
80
+ ctx="$(cluster_saved)"
81
+ [ -n "$ctx" ] || return 1
82
+ account_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 &&
83
+ kubectl --context devzone -n "$ns" get statefulset "$1" >/dev/null 2>&1
84
+ }
85
+
86
+ # Application ready: the StatefulSet has one ready replica
87
+ app_ready() {
88
+ local ns
89
+ ns="$(app_namespace "$1")"
90
+ [ "$(kubectl --context devzone -n "$ns" get statefulset "$1" \
91
+ -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" = 1 ]
92
+ }
93
+
94
+ # Adds to the state the <app>=off lines of the absent applications (once each,
95
+ # an existing line is never changed), preceded once by the comment; reading and
96
+ # writing hold the same lock (#417): a concurrent write cannot be lost between the two
97
+ catalog_sync() (
98
+ local app header missing="" tmp
99
+ [ -f "$ETAT" ] || return 0
100
+ header="# Catalog applications: set to on to install (devzone catalog)"
101
+ state_lock_take || return 1
102
+ # The lock is released on exit, including on an error under set -e
103
+ trap 'state_lock_release' EXIT
104
+ while IFS= read -r app; do
105
+ [ -n "$app" ] || continue
106
+ grep -qE "^${app}=" "$ETAT" 2>/dev/null && continue
107
+ missing="${missing}${missing:+$'\n'}${app}=off"
108
+ done <<<"$(catalog_apps)"
109
+ [ -n "$missing" ] || return 0
110
+ tmp="$(mktemp)"
111
+ {
112
+ cat "$ETAT"
113
+ grep -qF -e "$header" "$ETAT" || echo "$header"
114
+ echo "$missing"
115
+ } >"$tmp"
116
+ state_replace "$tmp"
117
+ rm -f "$tmp"
118
+ )
119
+
120
+ # Real state of an application: available, expected, installed, failed. These
121
+ # values are the etat field of devzone status --json: keep them
122
+ app_state() {
123
+ local app="$1"
124
+ if [ "$(wanted "$app")" != on ]; then
125
+ echo available
126
+ elif [ -f "$(failure_file "$app")" ]; then
127
+ echo failed
128
+ elif present "$app"; then
129
+ echo installed
130
+ else
131
+ echo expected
132
+ fi
133
+ }
134
+
135
+ # devzone catalog: name, state (off, on installed, on failed), description
136
+ catalog_list() {
137
+ local app state label
138
+ while IFS= read -r app; do
139
+ [ -n "$app" ] || continue
140
+ state="$(app_state "$app")"
141
+ case "$state" in
142
+ available) label='off available' ;;
143
+ installed) label='on installed' ;;
144
+ failed) label='on failed' ;;
145
+ *) label='on expected' ;;
146
+ esac
147
+ printf ' %-12s %-14s %s\n' "$app" "$label" "$(app_read "$app" description)"
148
+ done <<<"$(catalog_apps)"
149
+ }
150
+
151
+ # Relay of the installed application: state of its script, else the relay pid
152
+ app_relay_stopped() {
153
+ local app="$1" script state
154
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
155
+ # In the pod, no relay: the access goes through the workspace ports
156
+ return 1
157
+ fi
158
+ script="$ICI/catalog/$app/$app.sh"
159
+ if [ -f "$script" ]; then
160
+ state="$(bash "$script" status 2>/dev/null || true)"
161
+ case "$state" in *"relay stopped"*) return 0 ;; esac
162
+ fi
163
+ ! relay_active "$app"
164
+ }
165
+
166
+ # Application lines of devzone's summary: ○ available, ✔ installed (relay
167
+ # address), ✖ failed, ⚠ expected
168
+ catalog_summary() {
169
+ local app
170
+ while IFS= read -r app; do
171
+ [ -n "$app" ] || continue
172
+ case "$(app_state "$app")" in
173
+ available) printf ' ○ application %-12s available, %s: devzone enable %s\n' \
174
+ "$app" "$(app_read "$app" description)" "$app" ;;
175
+ installed)
176
+ if app_relay_stopped "$app"; then
177
+ printf ' ⚠ application %-12s installed, relay stopped: devzone repair\n' "$app"
178
+ else
179
+ if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
180
+ printf ' ✔ application %-12s installed: local access: devzone workspace ports\n' "$app"
181
+ else
182
+ printf ' ✔ application %-12s installed: 127.0.0.1:%s\n' \
183
+ "$app" "$(app_read "$app" port)"
184
+ fi
185
+ fi ;;
186
+ expected) printf ' ⚠ application %-12s expected: devzone apply\n' "$app" ;;
187
+ *) printf ' ✖ application %s failed: %s: devzone apply\n' \
188
+ "$app" "$(head -1 "$(failure_file "$app")")" ;;
189
+ esac
190
+ done <<<"$(catalog_apps)"
191
+ app_unused_mysql_volumes 2>/dev/null || true
192
+ }
193
+
194
+ # Applications section of devzone status --json: same fields as the modules
195
+ catalog_json() {
196
+ local app active state failure cmd json='[]'
197
+ while IFS= read -r app; do
198
+ [ -n "$app" ] || continue
199
+ active=false
200
+ [ "$(wanted "$app")" = on ] && active=true
201
+ state="$(app_state "$app")"
202
+ failure=""
203
+ cmd="devzone apply"
204
+ case "$state" in
205
+ available) cmd="devzone enable $app" ;;
206
+ installed) cmd="devzone disable $app" ;;
207
+ failed) failure="$(head -1 "$(failure_file "$app")")" ;;
208
+ esac
209
+ json="$(jq -cn --argjson before "$json" --arg name "$app" --argjson active "$active" \
210
+ --arg description "$(app_read "$app" description)" \
211
+ --arg state "$state" --arg port "$(app_read "$app" port)" \
212
+ --arg failure "$failure" --arg command "$cmd" \
213
+ '$before + [{name:$name,active:$active,description:$description,port:$port,state:$state,failed:(if $failure=="" then null else $failure end),command:(if $command=="" then null else $command end)}]')"
214
+ done <<<"$(catalog_apps)"
215
+ printf '%s\n' "$json"
216
+ }
217
+
218
+ case "${1:-}" in
219
+ sync) catalog_sync ;;
220
+ apply) catalog_apply ;;
221
+ list) catalog_list ;;
222
+ resume) catalog_summary ;;
223
+ json) catalog_json ;;
224
+ # Removal of an application: StatefulSet and service, volume kept (#441)
225
+ remove) app_remove "$2" ;;
226
+ -h | --help | aide) sed -n '2,6p' "$0" | sed 's/^# \{0,1\}//' ;;
227
+ *)
228
+ echo "devzone : catalog : sync | apply | list | resume | json | remove <app>" >&2
229
+ exit 1
230
+ ;;
231
+ esac
@@ -33,7 +33,7 @@ chart_install() {
33
33
  shift 2
34
34
  chart="$CHART_CODE/charts/devzone-$svc"
35
35
  if [ ! -f "$chart/Chart.yaml" ]; then
36
- echo "✖ $svc : chart charts/devzone-$svc missing (manage/docs/reference.md#charts-de-devzone)" >&2
36
+ echo "✖ $svc : chart charts/devzone-$svc missing (manage/docs/reference.md#devzone-charts)" >&2
37
37
  return 2
38
38
  fi
39
39
  sets=()