devzone 2.0.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.
- package/.devcontainer/agent-errors.sh +6 -6
- package/.devcontainer/agent-pod-manifest.sh +4 -4
- package/.devcontainer/agent-session.sh +2 -2
- package/.devcontainer/agent-state-json.sh +2 -2
- package/.devcontainer/agent-workspace.sh +1 -1
- package/.devcontainer/agent.sh +7 -7
- package/.devcontainer/ai/host-models.sh +2 -2
- package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
- package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
- package/.devcontainer/argocd/argocd.sh +90 -89
- package/.devcontainer/argocd/catalog-argocd.sh +2 -2
- package/.devcontainer/argocd/services-hook.sh +3 -3
- package/.devcontainer/argocd/services.sh +1 -1
- package/.devcontainer/catalog/app.sh +114 -116
- package/.devcontainer/catalog/catalog-watcher.sh +62 -62
- package/.devcontainer/catalog/mysql/app.conf +1 -1
- package/.devcontainer/catalog/mysql/install.sh +40 -40
- package/.devcontainer/catalog/mysql/mysql.sh +141 -141
- package/.devcontainer/catalog/mysql/volume.sh +39 -39
- package/.devcontainer/catalog.sh +112 -112
- package/.devcontainer/chart-direct.sh +1 -1
- package/.devcontainer/cluster.sh +216 -218
- package/.devcontainer/clusters.sh +41 -41
- package/.devcontainer/devzone +92 -1495
- package/.devcontainer/devzone-ai-guard.sh +76 -0
- package/.devcontainer/devzone-ai.sh +201 -0
- package/.devcontainer/devzone-cluster.sh +210 -0
- package/.devcontainer/devzone-modules.sh +126 -0
- package/.devcontainer/devzone-platform.sh +189 -0
- package/.devcontainer/devzone-repair.sh +94 -0
- package/.devcontainer/devzone-services.sh +241 -0
- package/.devcontainer/devzone-skill.sh +97 -0
- package/.devcontainer/devzone-status.sh +140 -0
- package/.devcontainer/devzone-version.sh +78 -0
- package/.devcontainer/git-identity.sh +28 -0
- package/.devcontainer/gitlab/chart.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +81 -82
- package/.devcontainer/gitlab/installation.sh +109 -109
- package/.devcontainer/gitlab/secrets.sh +47 -47
- package/.devcontainer/gitlab/seed.sh +77 -77
- package/.devcontainer/gitlab/test-gitlab.sh +242 -243
- package/.devcontainer/help.sh +1 -1
- package/.devcontainer/isolation.sh +30 -30
- package/.devcontainer/kind-wrapper.sh +17 -17
- package/.devcontainer/kube-account.sh +112 -113
- package/.devcontainer/kube-config.sh +45 -46
- package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
- package/.devcontainer/kube-reachable.sh +40 -40
- package/.devcontainer/memory.sh +1 -1
- package/.devcontainer/metrics-server.sh +2 -2
- package/.devcontainer/opencode.jsonc +2 -2
- package/.devcontainer/packages.sh +136 -135
- package/.devcontainer/password.sh +1 -1
- package/.devcontainer/ports-auto.sh +152 -153
- package/.devcontainer/ports-json.sh +16 -15
- package/.devcontainer/ports.sh +126 -122
- package/.devcontainer/post-create.sh +52 -52
- package/.devcontainer/postgres/postgres.sh +174 -174
- package/.devcontainer/rename-legacy-files.sh +103 -0
- package/.devcontainer/services-admin.sh +3 -3
- package/.devcontainer/skills/devzone/SKILL.md +40 -41
- package/.devcontainer/startup.sh +48 -49
- package/.devcontainer/state-gitops.sh +1 -1
- package/.devcontainer/state-json.sh +36 -62
- package/.devcontainer/state.sh +2 -2
- package/.devcontainer/workspace-init.sh +16 -2
- package/Makefile +1 -1
- package/README.md +195 -194
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +5 -7
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/check-names.sh +6 -5
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +2 -2
- package/manage/scripts/devzone-create.sh +3 -3
- package/manage/scripts/devzone-manifest.sh +1 -1
- package/manage/scripts/devzone-update.sh +12 -8
- package/manage/scripts/launch.sh +7 -48
- package/manage/scripts/migrate-revert.sh +3 -3
- package/manage/scripts/migrate.sh +7 -13
- package/manage/scripts/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/uninstall.sh +8 -8
- package/manage/scripts/workspace-egress.sh +2 -2
- package/manage/scripts/workspace-update.sh +5 -2
- package/manage/scripts/workspace-wait.sh +2 -2
- package/package.json +1 -1
- package/.devcontainer/docker-relay.sh +0 -149
- package/.devcontainer/docker-without-host.sh +0 -12
- package/.devcontainer/git-identite.sh +0 -28
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# devzone, status summary of the modules.
|
|
4
|
+
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
+
# functions only, shared variables are defined in devzone.
|
|
6
|
+
|
|
7
|
+
# Full state: ✔ ready, ✖ required, ○ optional, ⚠ to fix; each point to do with
|
|
8
|
+
# its command (shown at each startup)
|
|
9
|
+
show_state() {
|
|
10
|
+
local name email status m late path ports_state ctx_work ctx_host packages_mark packages_names argocd_repo
|
|
11
|
+
echo "devzone: state (devzone to show it again)"
|
|
12
|
+
version_available_line
|
|
13
|
+
name="$(git config --get user.name || true)"
|
|
14
|
+
email="$(git config --get user.email || true)"
|
|
15
|
+
if [ -n "$name" ] && [ -n "$email" ]; then
|
|
16
|
+
echo " ✔ git identity $name <$email>"
|
|
17
|
+
else
|
|
18
|
+
echo " ✖ git identity needed to commit: gh auth login -s workflow (automatic),"
|
|
19
|
+
echo " or git config --file ~/.config/git/config user.name \"<name>\" and user.email \"<email>\""
|
|
20
|
+
fi
|
|
21
|
+
if [ "$(platform_read)" = gitlab ]; then
|
|
22
|
+
# gitlab platform: the instance and glab, then the lines specific to
|
|
23
|
+
# GitHub (gh checks) reported as not applicable here, pending the GitLab
|
|
24
|
+
# support of repowarden (#531)
|
|
25
|
+
platform_line
|
|
26
|
+
url="$(gitlab_url_read)"
|
|
27
|
+
if git config --global --get "credential.$url.helper" 2>/dev/null | grep -q 'glab auth git-credential'; then
|
|
28
|
+
echo " ✔ git via glab"
|
|
29
|
+
else
|
|
30
|
+
echo " ⚠ git via glab to set: devzone platform gitlab"
|
|
31
|
+
fi
|
|
32
|
+
echo " ○ GitHub not needed here (gitlab platform chosen)"
|
|
33
|
+
echo " ⚠ repowarden stays on GitHub (bots and tickets): GitLab support coming (simdevWarden/repowarden#531)"
|
|
34
|
+
else
|
|
35
|
+
platform_line
|
|
36
|
+
if ! status="$(gh auth status 2>&1)"; then
|
|
37
|
+
echo " ○ GitHub optional (push and PR, repowarden tickets) : gh auth login -s workflow"
|
|
38
|
+
elif grep -q "Token scopes:" <<<"$status" && ! grep -q "'workflow'" <<<"$status"; then
|
|
39
|
+
echo " ⚠ GitHub connected, without workflow permission (push of .github/workflows/ refused): gh auth refresh -h github.com -s workflow"
|
|
40
|
+
else
|
|
41
|
+
echo " ✔ GitHub connected"
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
if late="$(outdated_tools)"; then
|
|
45
|
+
if [ -z "$late" ]; then
|
|
46
|
+
echo " ✔ tools pinned versions"
|
|
47
|
+
else
|
|
48
|
+
while read -r package pinned installed; do
|
|
49
|
+
[ -n "$package" ] || continue
|
|
50
|
+
echo " ⚠ tools $package $installed installed, $pinned pinned: devzone apply"
|
|
51
|
+
done <<<"$late"
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
54
|
+
while IFS= read -r path; do
|
|
55
|
+
[ -n "$path" ] || continue
|
|
56
|
+
echo " ⚠ worktree $path absent here (created outside the container?): manage it on that side, never git worktree prune here (manage/docs/reference.md, Git worktrees)"
|
|
57
|
+
done < <(missing_worktrees)
|
|
58
|
+
for m in "${MODULES[@]}"; do
|
|
59
|
+
if in_pod && service_module "$m"; then
|
|
60
|
+
# Kubernetes workspace pod (#528): presence by the cluster DNS
|
|
61
|
+
service_pod_line "$m"
|
|
62
|
+
elif [ "$(value_of "$m")" = on ] && [ -f "$(failure_marker_file "$m")" ]; then
|
|
63
|
+
printf ' ✖ module %-10s failed: incomplete install (%s): devzone apply\n' "$m" "$(cat "$(failure_marker_file "$m")")"
|
|
64
|
+
elif [ "$(value_of "$m")" = on ] && [ "$m" = gitlab ]; then
|
|
65
|
+
# gitlab active: its real state (ready, runner, failed)
|
|
66
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/gitlab/gitlab.sh" status)"
|
|
67
|
+
elif [ "$(value_of "$m")" = on ] && [ "$m" = postgres ]; then
|
|
68
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/$m/$m.sh" status)"
|
|
69
|
+
elif [ "$(value_of "$m")" = on ] && [ "$m" = argocd ]; then
|
|
70
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/argocd/argocd.sh" status)"
|
|
71
|
+
elif [ "$(value_of "$m")" = on ] && [ "$m" = mysql ]; then
|
|
72
|
+
printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/catalog/mysql/mysql.sh" status)"
|
|
73
|
+
elif [ "$(value_of "$m")" = on ]; then
|
|
74
|
+
printf ' ✔ module %-10s active: %s\n' "$m" "$(description "$m")"
|
|
75
|
+
else
|
|
76
|
+
printf ' ○ module %-10s optional, %s: devzone enable %s\n' "$m" "$(description "$m")" "$m"
|
|
77
|
+
fi
|
|
78
|
+
done
|
|
79
|
+
# GitOps repository of the instance (#539): the designation of .argocd.conf
|
|
80
|
+
argocd_repo="$(conf_get argocd repo)"
|
|
81
|
+
if [ -n "$argocd_repo" ] && [ "$argocd_repo" != none ]; then
|
|
82
|
+
printf ' ○ argocd GitOps repository: %s\n' "$argocd_repo"
|
|
83
|
+
elif in_pod; then
|
|
84
|
+
gitops_state_line
|
|
85
|
+
else
|
|
86
|
+
printf ' ○ argocd no GitOps repository: devzone argocd init\n'
|
|
87
|
+
fi
|
|
88
|
+
# Catalog applications (#414)
|
|
89
|
+
if [ -d "$ICI/catalog" ]; then
|
|
90
|
+
bash "$ICI/catalog.sh" resume
|
|
91
|
+
fi
|
|
92
|
+
# GitLab Rails secret (#347): warning if the secrets were lost
|
|
93
|
+
if [ "$(value_of gitlab)" = on ] && [ ! -f "$RACINE/workspace/.gitlab/rails-secret.yaml" ]; then
|
|
94
|
+
echo " ⚠ gitlab GitLab reinstalled: if the browser shows 422, delete the site data of gitlab.localhost"
|
|
95
|
+
fi
|
|
96
|
+
# Remote devzone cluster: warning in the summary
|
|
97
|
+
current_cluster="$(cluster_saved)"
|
|
98
|
+
if [ -n "$current_cluster" ] && ! cluster_is_local "$current_cluster"; then
|
|
99
|
+
printf ' ⚠ cluster remote: %s — services on a remote cluster\n' "$current_cluster"
|
|
100
|
+
fi
|
|
101
|
+
# Old kind-gitlab cluster still present: invite to migrate (#396)
|
|
102
|
+
if kind get clusters 2>/dev/null | grep -qx "gitlab${INSTANCE_SUFFIX}"; then
|
|
103
|
+
printf ' ⚠ old kind-gitlab cluster%s: devzone gitlab migrate\n' "$INSTANCE_SUFFIX"
|
|
104
|
+
fi
|
|
105
|
+
# Internal working cluster (kind): warning in the summary
|
|
106
|
+
ctx_work="$(kubectl config current-context 2>/dev/null || true)"
|
|
107
|
+
case "$ctx_work" in
|
|
108
|
+
kind-gitlab* | kind-devzone*)
|
|
109
|
+
ctx_host="$(KUBECONFIG="${DEVZONE_KUBE_HOST:-$HOME/.kube/hote.config}" kubectl config current-context 2>/dev/null || true)"
|
|
110
|
+
if [ -n "$ctx_host" ] && cluster_reachable "$ctx_host"; then
|
|
111
|
+
printf ' ⚠ working cluster: %s (devzone internal cluster); go back: devzone use %s\n' "$ctx_work" "$ctx_host"
|
|
112
|
+
fi
|
|
113
|
+
;;
|
|
114
|
+
esac
|
|
115
|
+
# RBAC check: access check to the PostgreSQL secrets
|
|
116
|
+
ctx_rbac="$(kubectl auth can-i --as=system:serviceaccount:default:default get secrets -n devzone-postgres 2>/dev/null || true)"
|
|
117
|
+
if [ "$ctx_rbac" = "yes" ]; then
|
|
118
|
+
printf ' ⚠ rbac : access to devzone-postgres secrets not restricted\n'
|
|
119
|
+
fi
|
|
120
|
+
ports_state="$(bash "$ICI/ports.sh" resume 2>/dev/null || true)"
|
|
121
|
+
case "$ports_state" in
|
|
122
|
+
none*) printf ' ○ ports to the workstation %s\n' "$ports_state" ;;
|
|
123
|
+
*) printf ' ✔ ports to the workstation %s\n' "$ports_state" ;;
|
|
124
|
+
esac
|
|
125
|
+
# Grouped credentials (#332): the path only, never the content
|
|
126
|
+
if [ -f "$RACINE/.password" ]; then
|
|
127
|
+
printf ' ○ credentials: %s\n' "$RACINE/.password"
|
|
128
|
+
fi
|
|
129
|
+
# Mark set by packages.sh at the failed reapplication (351): names of the packages not installed
|
|
130
|
+
packages_mark="${DEVZONE_PACKAGES_MARKER:-/tmp/devzone-packages.failed}"
|
|
131
|
+
if [ -f "$packages_mark" ]; then
|
|
132
|
+
packages_names=""
|
|
133
|
+
while IFS= read -r n; do
|
|
134
|
+
if [ -n "$n" ]; then
|
|
135
|
+
packages_names="${packages_names:+$packages_names, }$n"
|
|
136
|
+
fi
|
|
137
|
+
done < "$packages_mark"
|
|
138
|
+
echo " ⚠ packages $packages_names: devzone packages"
|
|
139
|
+
fi
|
|
140
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# devzone, version of the folder and of the published release.
|
|
4
|
+
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
+
# functions only, shared variables are defined in devzone.
|
|
6
|
+
|
|
7
|
+
# Version of the devzone folder (manifest written by the workstation CLI),
|
|
8
|
+
# nothing if the folder predates the manifest
|
|
9
|
+
folder_version() {
|
|
10
|
+
local v
|
|
11
|
+
[ -f "$RACINE/.devzone.version" ] || return 1
|
|
12
|
+
v="$(sed -n '1s/^version //p' "$RACINE/.devzone.version" 2>/dev/null | head -1 || true)"
|
|
13
|
+
[ -n "$v" ] || return 1
|
|
14
|
+
printf '%s\n' "$v"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# True if the first version is newer than the second
|
|
18
|
+
version_is_newer() {
|
|
19
|
+
awk -v a="$1" -v b="$2" 'BEGIN {
|
|
20
|
+
na = split(a, x, ".")
|
|
21
|
+
nb = split(b, y, ".")
|
|
22
|
+
n = (na > nb ? na : nb)
|
|
23
|
+
for (i = 1; i <= n; i++) {
|
|
24
|
+
p = (i <= na ? x[i] : 0) + 0
|
|
25
|
+
q = (i <= nb ? y[i] : 0) + 0
|
|
26
|
+
if (p > q) exit 0
|
|
27
|
+
if (p < q) exit 1
|
|
28
|
+
}
|
|
29
|
+
exit 1
|
|
30
|
+
}'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Version published on npm, at most once a day, cached under
|
|
34
|
+
# ~/.cache/devzone/; 5 s at most, silent offline
|
|
35
|
+
published_version() {
|
|
36
|
+
local cache day npm v tmp pid waited
|
|
37
|
+
cache="$HOME/.cache/devzone/version-publiee"
|
|
38
|
+
day="$(date +%Y-%m-%d)"
|
|
39
|
+
if [ -f "$cache" ] && [ "$(sed -n '1p' "$cache" 2>/dev/null || true)" = "$day" ]; then
|
|
40
|
+
sed -n '2p' "$cache" 2>/dev/null || true
|
|
41
|
+
return 0
|
|
42
|
+
fi
|
|
43
|
+
npm="${DEVZONE_NPM:-npm}"
|
|
44
|
+
v=""
|
|
45
|
+
if command -v "$npm" >/dev/null 2>&1; then
|
|
46
|
+
mkdir -p "$(dirname "$cache")" 2>/dev/null || true
|
|
47
|
+
tmp="$cache.$$"
|
|
48
|
+
"$npm" view devzone version >"$tmp" 2>/dev/null &
|
|
49
|
+
pid=$!
|
|
50
|
+
waited=0
|
|
51
|
+
while kill -0 "$pid" 2>/dev/null; do
|
|
52
|
+
sleep 1
|
|
53
|
+
waited=$((waited + 1))
|
|
54
|
+
if [ "$waited" -ge 5 ]; then
|
|
55
|
+
kill "$pid" 2>/dev/null || true
|
|
56
|
+
break
|
|
57
|
+
fi
|
|
58
|
+
done
|
|
59
|
+
wait "$pid" 2>/dev/null || true
|
|
60
|
+
v="$(sed -n '1p' "$tmp" 2>/dev/null | tr -d '[:space:]' || true)"
|
|
61
|
+
rm -f "$tmp"
|
|
62
|
+
fi
|
|
63
|
+
mkdir -p "$(dirname "$cache")" 2>/dev/null || true
|
|
64
|
+
printf '%s\n%s\n' "$day" "$v" >"$cache" 2>/dev/null || true
|
|
65
|
+
[ -n "$v" ] && printf '%s\n' "$v"
|
|
66
|
+
return 0
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
version_available_line() {
|
|
70
|
+
local folder published
|
|
71
|
+
folder="$(folder_version)" || return 0
|
|
72
|
+
published="$(published_version)" || return 0
|
|
73
|
+
published="${published#v}"
|
|
74
|
+
[ -n "$published" ] || return 0
|
|
75
|
+
if version_is_newer "$published" "$folder"; then
|
|
76
|
+
printf ' ○ devzone %s available: on the workstation, devzone update\n' "$published"
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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)>"
|
|
@@ -23,7 +23,7 @@ gitlab_chart_depend() {
|
|
|
23
23
|
# is the main instance, so it is passed here
|
|
24
24
|
gitlab_helm_pass() {
|
|
25
25
|
local replicas="$1"
|
|
26
|
-
|
|
26
|
+
account_helm "$(account_context)" upgrade --install gitlab "$RACINE/charts/devzone-gitlab" \
|
|
27
27
|
--namespace "$GITLAB_NS" \
|
|
28
28
|
--create-namespace \
|
|
29
29
|
--timeout "${GITLAB_ATTENTE}s" \
|
|
@@ -35,5 +35,5 @@ gitlab_helm_pass() {
|
|
|
35
35
|
# Release gitlab-runner of the installations before the wrapper chart (#396):
|
|
36
36
|
# its runner now comes with the chart, the release leaves without touching data
|
|
37
37
|
gitlab_runner_ancien_retirer() {
|
|
38
|
-
|
|
38
|
+
account_helm "$(account_context)" uninstall gitlab-runner --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
39
39
|
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# set -euo pipefail
|
|
2
|
+
# GitLab module: test GitLab in the services cluster (#396).
|
|
3
|
+
# To enable it: devzone enable gitlab
|
|
4
|
+
# To disable it: devzone disable gitlab
|
|
5
|
+
# set -euo pipefail so that nothing fails silently.
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# Root of the devzone repository (two levels above the module); DEVZONE_ROOT for the tests
|
|
9
9
|
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
10
|
-
RACINE="${
|
|
10
|
+
RACINE="${DEVZONE_ROOT:-$(dirname "$(dirname "$ICI")")}"
|
|
11
11
|
# shellcheck source=SCRIPTDIR/../cluster.sh
|
|
12
12
|
. "$ICI/../cluster.sh"
|
|
13
13
|
# shellcheck source=SCRIPTDIR/../password.sh
|
|
14
14
|
# shellcheck disable=SC1091
|
|
15
15
|
. "$ICI/../password.sh"
|
|
16
|
-
#
|
|
16
|
+
# Network isolation: namespace_isolate, set with the devzone-gitlab namespace
|
|
17
17
|
# shellcheck source=SCRIPTDIR/../isolation.sh
|
|
18
18
|
# shellcheck disable=SC1091
|
|
19
19
|
. "$ICI/../isolation.sh"
|
|
20
20
|
|
|
21
|
-
# ----
|
|
22
|
-
# GITLAB_ATTENTE
|
|
21
|
+
# ---- Delay variables (seconds) ----
|
|
22
|
+
# GITLAB_ATTENTE: global wait for the installation (default 1200)
|
|
23
23
|
GITLAB_ATTENTE="${GITLAB_ATTENTE:-1200}"
|
|
24
24
|
|
|
25
|
-
# ----
|
|
26
|
-
# Secrets
|
|
25
|
+
# ---- Secret paths ----
|
|
26
|
+
# Secrets stored in $RACINE/workspace/.gitlab/ (chmod 600), never shown.
|
|
27
27
|
GITLAB_SECRETS_DIR="$RACINE/workspace/.gitlab"
|
|
28
28
|
|
|
29
|
-
#
|
|
29
|
+
# Grouped view of the credentials: a failure never prevents the operation
|
|
30
30
|
regenerer_identifiants() {
|
|
31
31
|
password_regenerate ||
|
|
32
|
-
echo "devzone : gitlab :
|
|
32
|
+
echo "devzone : gitlab : grouped credentials not updated (devzone passwords)" >&2
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
# ---- /etc/hosts
|
|
36
|
-
# DEVZONE_HOSTS
|
|
35
|
+
# ---- /etc/hosts of the container ----
|
|
36
|
+
# DEVZONE_HOSTS for the tests (never the real /etc/hosts)
|
|
37
37
|
HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
|
|
38
|
-
|
|
38
|
+
GITLAB_HOST_MARK="# devzone:gitlab"
|
|
39
39
|
|
|
40
|
-
#
|
|
41
|
-
#
|
|
40
|
+
# GitLab Rails secret (#347): kept in workspace/.gitlab, applied again
|
|
41
|
+
# before helm upgrade --install, and the password can be regenerated
|
|
42
42
|
# shellcheck source=SCRIPTDIR/secrets.sh
|
|
43
43
|
# shellcheck disable=SC1091
|
|
44
44
|
. "$ICI/secrets.sh"
|
|
45
45
|
|
|
46
|
-
# ---- Installation, migration
|
|
47
|
-
#
|
|
48
|
-
#
|
|
46
|
+
# ---- Installation, migration and relay of the services cluster ----
|
|
47
|
+
# New logic outside this file (#396): devzone-gitlab namespace,
|
|
48
|
+
# allocatable memory, Helm with the devzone context, migration from kind-gitlab.
|
|
49
49
|
# shellcheck source=SCRIPTDIR/installation.sh
|
|
50
50
|
# shellcheck disable=SC1091
|
|
51
51
|
. "$ICI/installation.sh"
|
|
52
|
-
#
|
|
52
|
+
# Wrapper chart (direct helm, chart.sh), Argo CD (argocd.sh), seed (seed.sh) (#538)
|
|
53
53
|
# shellcheck source=SCRIPTDIR/chart.sh
|
|
54
54
|
# shellcheck disable=SC1091
|
|
55
55
|
. "$ICI/chart.sh"
|
|
@@ -60,110 +60,109 @@ GITLAB_HOTE_MARQUE="# devzone:gitlab"
|
|
|
60
60
|
# shellcheck disable=SC1091
|
|
61
61
|
. "$ICI/seed.sh"
|
|
62
62
|
|
|
63
|
-
# ----
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
# glab
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
grep -qxF "$ligne" "$HOSTS" 2>/dev/null; then
|
|
63
|
+
# ---- host-set / host-remove: gitlab.localhost in /etc/hosts ----
|
|
64
|
+
# Why: ssh (clone ssh://git@gitlab.localhost:2224/…), glab and getent go through
|
|
65
|
+
# the system resolver. curl and git (libcurl) ignore /etc/hosts for the
|
|
66
|
+
# *.localhost names (RFC 6761) and go through the TCP relay above, which
|
|
67
|
+
# listens on 127.0.0.1. The name therefore points to 127.0.0.1 so that ssh and
|
|
68
|
+
# glab take the same path. /etc/hosts is a Docker mount that Docker regenerates
|
|
69
|
+
# when the container starts, hence the set again at each start (startup.sh) and
|
|
70
|
+
# at each activation. Never sed -i nor mv: the mount cannot be renamed (in-place
|
|
71
|
+
# write only); direct if the file is writable, otherwise sudo -n. A failure never
|
|
72
|
+
# fails: a warning on stderr and exit code 0, so that the installation does not
|
|
73
|
+
# fail for a host name.
|
|
74
|
+
gitlab_host_set() {
|
|
75
|
+
local line tmp
|
|
76
|
+
line="$(printf '127.0.0.1\tgitlab.localhost %s' "$GITLAB_HOST_MARK")"
|
|
77
|
+
# Already the right line, once: nothing (idempotent)
|
|
78
|
+
if [ "$(grep -c "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null || true)" = 1 ] &&
|
|
79
|
+
grep -qxF "$line" "$HOSTS" 2>/dev/null; then
|
|
81
80
|
return 0
|
|
82
81
|
fi
|
|
83
|
-
if grep -q "$
|
|
84
|
-
#
|
|
85
|
-
#
|
|
82
|
+
if grep -q "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null; then
|
|
83
|
+
# Line marked with another address (IPv6 of #320) or duplicate:
|
|
84
|
+
# it is replaced by the right one, keeping the rest of the file.
|
|
86
85
|
tmp="$(mktemp)"
|
|
87
|
-
grep -v "$
|
|
88
|
-
printf '%s\n' "$
|
|
86
|
+
grep -v "$GITLAB_HOST_MARK" "$HOSTS" >"$tmp" 2>/dev/null || true
|
|
87
|
+
printf '%s\n' "$line" >>"$tmp"
|
|
89
88
|
if [ -w "$HOSTS" ]; then
|
|
90
89
|
cp "$tmp" "$HOSTS" 2>/dev/null ||
|
|
91
|
-
echo "devzone : gitlab :
|
|
90
|
+
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (insufficient write rights)" >&2
|
|
92
91
|
elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
|
|
93
|
-
echo "devzone : gitlab :
|
|
92
|
+
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (sudo -n unavailable or refused)" >&2
|
|
94
93
|
fi
|
|
95
94
|
rm -f "$tmp"
|
|
96
95
|
return 0
|
|
97
96
|
fi
|
|
98
97
|
if [ -w "$HOSTS" ]; then
|
|
99
|
-
printf '%s\n' "$
|
|
100
|
-
echo "devzone : gitlab :
|
|
101
|
-
elif ! printf '%s\n' "$
|
|
102
|
-
echo "devzone : gitlab :
|
|
98
|
+
printf '%s\n' "$line" >>"$HOSTS" 2>/dev/null ||
|
|
99
|
+
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (insufficient write rights)" >&2
|
|
100
|
+
elif ! printf '%s\n' "$line" | sudo -n tee -a "$HOSTS" >/dev/null 2>&1; then
|
|
101
|
+
echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (sudo -n unavailable or refused)" >&2
|
|
103
102
|
fi
|
|
104
103
|
return 0
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
|
|
108
|
-
#
|
|
109
|
-
if ! grep -q "$
|
|
106
|
+
gitlab_host_remove() {
|
|
107
|
+
# No line found: nothing (including an unreadable file)
|
|
108
|
+
if ! grep -q "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null; then
|
|
110
109
|
return 0
|
|
111
110
|
fi
|
|
112
111
|
local tmp
|
|
113
112
|
tmp="$(mktemp)"
|
|
114
|
-
grep -v "$
|
|
113
|
+
grep -v "$GITLAB_HOST_MARK" "$HOSTS" >"$tmp" 2>/dev/null || true
|
|
115
114
|
if [ -w "$HOSTS" ]; then
|
|
116
115
|
cp "$tmp" "$HOSTS" 2>/dev/null ||
|
|
117
|
-
echo "devzone : gitlab :
|
|
116
|
+
echo "devzone : gitlab : gitlab.localhost line not removed from $HOSTS (insufficient write rights)" >&2
|
|
118
117
|
elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
|
|
119
|
-
echo "devzone : gitlab :
|
|
118
|
+
echo "devzone : gitlab : gitlab.localhost line not removed from $HOSTS (sudo -n unavailable or refused)" >&2
|
|
120
119
|
fi
|
|
121
120
|
rm -f "$tmp"
|
|
122
121
|
return 0
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
# ----
|
|
126
|
-
|
|
127
|
-
#
|
|
128
|
-
if !
|
|
129
|
-
echo "
|
|
124
|
+
# ---- status: check the state of GitLab ----
|
|
125
|
+
gitlab_status() {
|
|
126
|
+
# Disabled if the devzone-gitlab namespace does not exist
|
|
127
|
+
if ! gitlab_installed; then
|
|
128
|
+
echo "disabled"
|
|
130
129
|
return 0
|
|
131
130
|
fi
|
|
132
131
|
|
|
133
|
-
#
|
|
132
|
+
# Check that GitLab answers the readiness probe
|
|
134
133
|
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
|
|
135
|
-
#
|
|
136
|
-
local runner_status="
|
|
134
|
+
# Check whether the runner is online or offline
|
|
135
|
+
local runner_status="offline"
|
|
137
136
|
if [ -f "$GITLAB_SECRETS_DIR/root-token" ]; then
|
|
138
137
|
local token count
|
|
139
138
|
token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
140
139
|
count="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/runners/all?status=online" 2>/dev/null | jq -r 'length' 2>/dev/null || true)"
|
|
141
140
|
if [ "${count:-0}" -gt 0 ] 2>/dev/null; then
|
|
142
|
-
runner_status="
|
|
141
|
+
runner_status="online"
|
|
143
142
|
fi
|
|
144
143
|
fi
|
|
145
|
-
echo "
|
|
144
|
+
echo "ready: http://gitlab.localhost:8929, runner ${runner_status}"
|
|
146
145
|
else
|
|
147
|
-
echo "
|
|
146
|
+
echo "failed: devzone apply"
|
|
148
147
|
fi
|
|
149
148
|
return 0
|
|
150
149
|
}
|
|
151
150
|
|
|
152
|
-
#
|
|
151
|
+
# Subcommand dispatch
|
|
153
152
|
case "${1:-}" in
|
|
154
|
-
install)
|
|
155
|
-
uninstall)
|
|
156
|
-
migrate) shift;
|
|
157
|
-
installe)
|
|
158
|
-
status)
|
|
159
|
-
seed)
|
|
160
|
-
new-password)
|
|
161
|
-
relay-start)
|
|
162
|
-
relay-stop)
|
|
163
|
-
relay-status)
|
|
164
|
-
hote-poser)
|
|
165
|
-
hote-retirer)
|
|
166
|
-
*) echo "devzone :
|
|
153
|
+
install) gitlab_install ;;
|
|
154
|
+
uninstall) gitlab_uninstall "${@:2}" ;;
|
|
155
|
+
migrate) shift; gitlab_migrate "$@" ;;
|
|
156
|
+
installe) gitlab_installed ;;
|
|
157
|
+
status) gitlab_status ;;
|
|
158
|
+
seed) gitlab_seed_command ;;
|
|
159
|
+
new-password) gitlab_new_password "${@:2}" ;;
|
|
160
|
+
relay-start) gitlab_relay_start ;;
|
|
161
|
+
relay-stop) gitlab_relay_stop ;;
|
|
162
|
+
relay-status) gitlab_relay_status ;;
|
|
163
|
+
hote-poser) gitlab_host_set ;;
|
|
164
|
+
hote-retirer) gitlab_host_remove ;;
|
|
165
|
+
*) echo "devzone : unknown command : ${1:-} (devzone gitlab --help)" >&2
|
|
167
166
|
exit 1
|
|
168
167
|
;;
|
|
169
168
|
esac
|