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,204 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Seed of the GitLab of devzone (#396, #538): the data a fresh instance needs,
3
- # group devzone, demo project, dev user, runner. Sourced by gitlab.sh. The
4
- # installer starts the relays and waits for GitLab before the seed; the seed
5
- # command (devzone gitlab seed, run in the pod by services-admin.sh when Argo
6
- # CD holds the chart) does it itself (gitlab_seed_command).
7
- # gitlab_wait_ready waits for the readiness of GitLab (GITLAB_ATTENTE)
8
- # gitlab_seed group, project, user, runner token and its Secret
9
- # gitlab_seed_command devzone gitlab seed: relays, readiness, seed
10
-
11
- # ---- Helper: wait until GitLab is ready ----
12
- gitlab_wait_ready() {
13
- local start
14
- start=$(date +%s)
15
- echo "▶ Waiting for GitLab to be ready (timeout ${GITLAB_ATTENTE}s)…"
16
- while [ $(( $(date +%s) - start )) -lt "$GITLAB_ATTENTE" ]; do
17
- if curl -sf http://gitlab.localhost:8929/-/readiness >/dev/null 2>&1 || curl -sf http://gitlab.localhost:8929/users/sign_in >/dev/null 2>&1; then
18
- echo "▶ GitLab ready."
19
- return 0
20
- fi
21
- sleep 5
22
- done
23
- echo "devzone : timeout waiting for GitLab." >&2
24
- return 1
25
- }
26
-
27
- # ---- seed: fill GitLab with the base data ----
28
- gitlab_seed() {
29
- echo "▶ Seeding GitLab…"
30
-
31
- mkdir -p "$GITLAB_SECRETS_DIR"
32
-
33
- # Root password read from the gitlab-gitlab-initial-root-password secret
34
- local password
35
- password="$(kubectl --context devzone get secret -n "$GITLAB_NS" gitlab-gitlab-initial-root-password -o jsonpath='{.data.password}' 2>/dev/null | base64 -d 2>/dev/null || true)"
36
- if [ -z "$password" ]; then
37
- echo "devzone : seed GitLab : root secret (gitlab-gitlab-initial-root-password) not found, seed stopped." >&2
38
- return 1
39
- fi
40
- printf '%s' "$password" > "$GITLAB_SECRETS_DIR/root-password"
41
- chmod 600 "$GITLAB_SECRETS_DIR/root-password"
42
-
43
- # Root access token created by kubectl exec in the toolbox pod with gitlab-rails runner
44
- local toolbox_pod root_token
45
- toolbox_pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
46
- if [ -z "$toolbox_pod" ]; then
47
- echo "devzone : seed GitLab : toolbox pod (label app=toolbox) not found, seed stopped." >&2
48
- return 1
49
- fi
50
- root_token="$(kubectl --context devzone exec -n "$GITLAB_NS" "$toolbox_pod" -- gitlab-rails runner 'puts User.find_by_username("root").personal_access_tokens.create(name: "devzone", scopes: ["api", "write_repository"], expires_at: 30.days.from_now).token' 2>/dev/null | tail -n 1 || true)"
51
- if [ -z "$root_token" ]; then
52
- echo "devzone : seed GitLab : creation of the root token (gitlab-rails runner) failed, seed stopped." >&2
53
- return 1
54
- fi
55
- printf '%s' "$root_token" > "$GITLAB_SECRETS_DIR/root-token"
56
- chmod 600 "$GITLAB_SECRETS_DIR/root-token"
57
-
58
- # Through the curl API with the token (never shown in clear)
59
- local token group_id
60
- token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
61
-
62
- # Group devzone (tested before creation)
63
- if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" >/dev/null 2>&1; then
64
- if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/groups" --data "name=devzone&path=devzone&visibility=private" >/dev/null 2>&1; then
65
- echo "devzone : seed GitLab : creation of the devzone group failed, seed stopped." >&2
66
- return 1
67
- fi
68
- fi
69
- group_id="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" | jq -r '.id // empty')"
70
- if [ -z "$group_id" ]; then
71
- echo "devzone : seed GitLab : reading the numeric id of the devzone group failed, seed stopped." >&2
72
- return 1
73
- fi
74
-
75
- # Project devzone/demo (tested before creation, namespace_id = numeric ID of the group)
76
- if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo" >/dev/null 2>&1; then
77
- if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/projects" --data "name=demo&namespace_id=$group_id" >/dev/null 2>&1; then
78
- echo "devzone : seed GitLab : creation of the devzone/demo project failed, seed stopped." >&2
79
- return 1
80
- fi
81
- fi
82
-
83
- # Dev user (tested before creation, password generated at random):
84
- # an existing dev-password is reused only if the dev user still exists
85
- # (checked through the API); otherwise it is created again with a new user.
86
- local users_json dev_password
87
- users_json="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/users?username=dev")"
88
- if [ "$(jq length <<<"$users_json")" -eq 0 ]; then
89
- dev_password="$(openssl rand -base64 18 | tr -d '\n')"
90
- if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/users" --data "email=dev@gitlab.localhost&username=dev&name=dev&skip_confirmation=true" --data-urlencode "password=$dev_password" >/dev/null 2>&1; then
91
- echo "devzone : seed GitLab : creation of the dev user failed, seed stopped." >&2
92
- return 1
93
- fi
94
- printf '%s' "$dev_password" > "$GITLAB_SECRETS_DIR/dev-password"
95
- chmod 600 "$GITLAB_SECRETS_DIR/dev-password"
96
- fi
97
-
98
- # Runner token: checked through POST /api/v4/runners/verify; a valid token
99
- # is kept, a refused token (403/404) is created again, GitLab unreachable stops the seed.
100
- local runner_saved runner_code runner_token
101
- if [ -f "$GITLAB_SECRETS_DIR/runner-token" ]; then
102
- runner_saved="$(cat "$GITLAB_SECRETS_DIR/runner-token")"
103
- runner_code="$(curl -s -o /dev/null -w '%{http_code}' --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/runners/verify" --data "token=${runner_saved}" || true)"
104
- if [ "$runner_code" = "200" ]; then
105
- echo "✔ Runner token valid: kept."
106
- elif [ "$runner_code" = "403" ] || [ "$runner_code" = "404" ]; then
107
- echo "devzone : runner token of a previous installation refused: recreated."
108
- runner_token="$(curl -s --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/user/runners" --data "runner_type=instance_type" 2>/dev/null | jq -r '.token // empty' || true)"
109
- if [ -z "$runner_token" ]; then
110
- echo "devzone : seed GitLab : creation of the runner token (POST /api/v4/user/runners) failed, seed stopped." >&2
111
- return 1
112
- fi
113
- printf '%s' "$runner_token" > "$GITLAB_SECRETS_DIR/runner-token"
114
- chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
115
- else
116
- echo "devzone : seed GitLab : runner token check impossible (code ${runner_code}), seed stopped." >&2
117
- return 1
118
- fi
119
- else
120
- runner_token="$(curl -s --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/user/runners" --data "runner_type=instance_type" 2>/dev/null | jq -r '.token // empty' || true)"
121
- if [ -z "$runner_token" ]; then
122
- echo "devzone : seed GitLab : creation of the runner token (POST /api/v4/user/runners) failed, seed stopped." >&2
123
- return 1
124
- fi
125
- printf '%s' "$runner_token" > "$GITLAB_SECRETS_DIR/runner-token"
126
- chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
127
- fi
128
-
129
- # Secret of the runner of the chart (runners.secret, #538): created apart, out
130
- # of Git; the token is read from its file, never on a command line
131
- if ! kubectl --context devzone -n "$GITLAB_NS" create secret generic gitlab-runner-secret \
132
- --from-file=runner-token="$GITLAB_SECRETS_DIR/runner-token" \
133
- --from-literal=runner-registration-token= \
134
- --dry-run=client -o yaml |
135
- kubectl --context devzone -n "$GITLAB_NS" apply -f - >/dev/null 2>&1; then
136
- echo "devzone : seed GitLab : secret gitlab-runner-secret not created, seed stopped." >&2
137
- return 1
138
- fi
139
- # A runner already running may hold the previous token: restarted on the
140
- # one just written (no runner yet: nothing to restart)
141
- kubectl --context devzone -n "$GITLAB_NS" rollout restart deployment \
142
- --selector=app=gitlab-gitlab-runner >/dev/null 2>&1 || true
143
-
144
- # Push of the content of demo/ to devzone/demo (temporary git repository, http remote with the token in the URL, never shown; branch main)
145
- # The push uses the root token (write_repository): the runner token cannot push.
146
- local push_token=""
147
- push_token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
148
- if [ -z "$push_token" ]; then
149
- echo "devzone : seed GitLab : root token not found, seed stopped." >&2
150
- return 1
151
- fi
152
- # Already pushed (installation run again): nothing to do
153
- if curl -sf --header "PRIVATE-TOKEN: $push_token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo/repository/branches/main" >/dev/null 2>&1; then
154
- echo "✔ GitLab seed complete (demo project already pushed)."
155
- regenerer_identifiants
156
- return 0
157
- fi
158
- if [ -d "$ICI/demo" ]; then
159
- local tmpdir
160
- tmpdir="$(mktemp -d)"
161
- cp -r "$ICI/demo/." "$tmpdir/"
162
- if (
163
- cd "$tmpdir"
164
- # Throwaway repository of the script: the global git hooks (repowarden)
165
- # have nothing to check here and would refuse the commit
166
- export GIT_CONFIG_PARAMETERS="'core.hooksPath=/dev/null'"
167
- git init -q -b main
168
- git add -A
169
- git -c user.email=dev@gitlab.localhost -c user.name=dev commit -q -m "chore: projet de démonstration"
170
- # gitlab.localhost is not always resolved by git: local address,
171
- # and the host expected by the ingress passed as a header
172
- git remote add origin "http://oauth2:${push_token}@127.0.0.1:8929/devzone/demo.git"
173
- git -c http.extraHeader="Host: gitlab.localhost" push -q -u origin main >/dev/null 2>&1
174
- ); then
175
- # Checks the push: the main branch exists on the project
176
- if ! curl -sf --header "PRIVATE-TOKEN: $push_token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo/repository/branches/main" >/dev/null 2>&1; then
177
- echo "devzone : seed GitLab : push of the demo project to /devzone/demo.git succeeded but branch main is missing, seed stopped." >&2
178
- rm -rf "$tmpdir"
179
- return 1
180
- fi
181
- else
182
- echo "devzone : seed GitLab : push of the demo project to /devzone/demo.git failed, seed stopped." >&2
183
- rm -rf "$tmpdir"
184
- return 1
185
- fi
186
- rm -rf "$tmpdir"
187
- fi
188
-
189
- echo "✔ GitLab seed complete."
190
- regenerer_identifiants
191
- }
192
-
193
- # devzone gitlab seed: the seed alone, when Argo CD holds the chart (the
194
- # workstation runs it in the pod, services-admin.sh seed gitlab). The API and
195
- # the push go through the relays: they start, GitLab is awaited, then the seed.
196
- # The Rails secret of the pod is mirrored when it is not kept yet.
197
- gitlab_seed_command() {
198
- gitlab_relay_start || return 1
199
- gitlab_wait_ready || return 1
200
- gitlab_seed || return 1
201
- if [ ! -f "$GITLAB_RAILS_FILE" ]; then
202
- gitlab_secrets_copy
203
- fi
204
- }
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Leftovers of the gitlab instance after disable (test-gitlab.sh --complet, #517).
3
- # Sourced by test-gitlab.sh. Docker workstation: containers labelled with the
4
- # instance, from docker ps. Kubernetes workspace (DEVZONE_WORKSPACE=kubernetes):
5
- # pods labelled with the instance, from kubectl get pods. Read-only commands.
6
-
7
- # Prints the leftovers of instance $1, one per line (nothing when clean).
8
- gitlab_restes_conteneurs() {
9
- local instance="$1"
10
- if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
11
- kubectl --context devzone get pods --all-namespaces \
12
- -l "devzone.instance=$instance" -o name 2>/dev/null || true
13
- else
14
- docker ps -aq --filter "label=devzone.instance=$instance" 2>/dev/null || true
15
- fi
16
- }