devzone 2.0.0 → 4.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/command-aliases.sh +17 -8
- package/.devcontainer/devzone +93 -1496
- 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 +191 -195
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +7 -11
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/{check-charts.sh → ci/check-charts.sh} +1 -1
- package/manage/scripts/{check-english.sh → ci/check-english.sh} +1 -1
- package/manage/scripts/{check-go-layout.sh → ci/check-go-layout.sh} +1 -1
- package/manage/scripts/{check-names.sh → ci/check-names.sh} +7 -6
- package/manage/scripts/{check-utf8-vars.sh → ci/check-utf8-vars.sh} +1 -1
- package/manage/scripts/{versions.sh → ci/versions.sh} +8 -8
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +11 -18
- package/manage/scripts/devzone-create.sh +7 -35
- 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/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/poste.sh +6 -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/manage/workspace.sh +2 -12
- 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
- package/manage/scripts/docker-workstation.sh +0 -73
- package/manage/scripts/migrate-revert.sh +0 -60
- package/manage/scripts/migrate.sh +0 -243
- /package/manage/scripts/{ci-dns.sh → ci/ci-dns.sh} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Installation
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
2
|
+
# Installation and migration of GitLab in the services cluster (#396).
|
|
3
|
+
# Sourced by gitlab.sh: devzone-gitlab namespace (suffixed per instance),
|
|
4
|
+
# check of the allocatable memory, Helm with the devzone context, port-forward
|
|
5
|
+
# relay, runner and migration from the old kind cluster.
|
|
6
|
+
# The wrapper chart charts/devzone-gitlab (#538) holds the dependencies and the
|
|
7
|
+
# values; chart.sh (direct helm) and argocd.sh (Application) install it.
|
|
8
8
|
|
|
9
9
|
# Shared memory check of the services cluster (#608): quantity_ki,
|
|
10
10
|
# memory_cluster_ki and check_module_memory.
|
|
@@ -12,38 +12,38 @@
|
|
|
12
12
|
# shellcheck disable=SC1091
|
|
13
13
|
. "$ICI/../memory.sh"
|
|
14
14
|
|
|
15
|
-
# Namespace
|
|
15
|
+
# Namespace isolated from the module: one per instance, like postgres
|
|
16
16
|
GITLAB_NS="devzone-gitlab${INSTANCE_SUFFIX}"
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Namespace
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
# Old kind cluster of GitLab, deleted by "devzone gitlab migrate"
|
|
18
|
+
GITLAB_OLD_CLUSTER="gitlab${INSTANCE_SUFFIX}"
|
|
19
|
+
GITLAB_OLD_CONTEXT="kind-gitlab${INSTANCE_SUFFIX}"
|
|
20
|
+
|
|
21
|
+
# Namespace present in the services cluster: GitLab is installed.
|
|
22
|
+
# Reading the namespaces is reserved to the administrator (#430).
|
|
23
|
+
gitlab_installed() {
|
|
24
|
+
account_admin "$(account_context)" get namespace "$GITLAB_NS" >/dev/null 2>&1
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
#
|
|
28
|
-
|
|
27
|
+
# Creates the namespace, labels it and allows the limited account (#430), sets the isolation.
|
|
28
|
+
gitlab_namespace_prepare() {
|
|
29
29
|
local ctx
|
|
30
|
-
ctx="$(
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
ctx="$(account_context)"
|
|
31
|
+
account_namespace "$ctx" "$GITLAB_NS"
|
|
32
|
+
namespace_isolate "$GITLAB_NS"
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
echo "▶
|
|
35
|
+
# Installs GitLab and its runner in the services cluster, then prepares the
|
|
36
|
+
# access (web/SSH relay, /etc/hosts) and the seed of the test data.
|
|
37
|
+
gitlab_install() {
|
|
38
|
+
echo "▶ Checking the allocatable memory of the services cluster…"
|
|
39
39
|
check_module_memory gitlab 8 || return 2
|
|
40
40
|
|
|
41
41
|
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
42
|
-
|
|
42
|
+
gitlab_namespace_prepare
|
|
43
43
|
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
|
|
44
|
+
# Rails secret (#347): reinstallation -> apply the kept secret again before
|
|
45
|
+
# the installation (the chart reuses it, browser sessions stay valid)
|
|
46
|
+
gitlab_secrets_apply
|
|
47
47
|
gitlab_runner_ancien_retirer
|
|
48
48
|
|
|
49
49
|
# Argo CD holds the chart when the module is on (#538): the Application
|
|
@@ -55,139 +55,139 @@ gitlab_installer() {
|
|
|
55
55
|
gitlab_release_adopter
|
|
56
56
|
gitlab_application_apply || return 1
|
|
57
57
|
else
|
|
58
|
-
echo "▶
|
|
58
|
+
echo "▶ Installing the GitLab chart in ${GITLAB_NS}…"
|
|
59
59
|
gitlab_chart_depend
|
|
60
60
|
gitlab_helm_pass 0 || return 1
|
|
61
61
|
fi
|
|
62
62
|
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
|
|
63
|
+
# Relay before the wait: curl and git in HTTP resolve *.localhost to the
|
|
64
|
+
# loopback and reach GitLab only through these port-forwards (#320)
|
|
65
|
+
gitlab_relay_start || return 1
|
|
66
66
|
|
|
67
|
-
#
|
|
68
|
-
# getent
|
|
69
|
-
|
|
67
|
+
# gitlab.localhost name in /etc/hosts before the wait: ssh, glab and
|
|
68
|
+
# getent need it as soon as the service is up (curl resolves it itself)
|
|
69
|
+
gitlab_host_set || true
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
gitlab_wait_ready
|
|
72
72
|
gitlab_seed
|
|
73
|
-
if [ ! -f "$
|
|
74
|
-
|
|
73
|
+
if [ ! -f "$GITLAB_RAILS_FILE" ]; then
|
|
74
|
+
gitlab_secrets_copy
|
|
75
75
|
fi
|
|
76
76
|
if [ "$par_argocd" = 0 ]; then
|
|
77
|
-
echo "▶
|
|
77
|
+
echo "▶ GitLab Runner executor…"
|
|
78
78
|
gitlab_helm_pass 1 || return 1
|
|
79
79
|
fi
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
gitlab_secrets_warn
|
|
82
82
|
|
|
83
|
-
echo "▶ Installation
|
|
84
|
-
echo " URL
|
|
85
|
-
echo "
|
|
86
|
-
echo "
|
|
83
|
+
echo "▶ Installation complete."
|
|
84
|
+
echo " URL: http://gitlab.localhost:8929"
|
|
85
|
+
echo " User: root"
|
|
86
|
+
echo " Root password: $GITLAB_SECRETS_DIR/root-password (chmod 600)"
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
local
|
|
89
|
+
# Removes GitLab: relays, Helm releases and the namespace of the instance only.
|
|
90
|
+
# The Rails secret is kept (browser sessions valid at the reinstallation),
|
|
91
|
+
# unless a complete uninstall is wanted (--yes): it then goes with the data.
|
|
92
|
+
gitlab_uninstall() {
|
|
93
|
+
local delete_secret="" arg
|
|
94
94
|
for arg in "$@"; do
|
|
95
95
|
case "$arg" in
|
|
96
|
-
--yes)
|
|
97
|
-
*) echo "devzone : gitlab uninstall : argument
|
|
96
|
+
--yes) delete_secret=1 ;;
|
|
97
|
+
*) echo "devzone : gitlab uninstall : unknown argument : $arg" >&2; return 2 ;;
|
|
98
98
|
esac
|
|
99
99
|
done
|
|
100
|
-
echo "▶
|
|
101
|
-
|
|
102
|
-
rm -rf "$(
|
|
103
|
-
"$(
|
|
104
|
-
# Application
|
|
100
|
+
echo "▶ Uninstalling GitLab…"
|
|
101
|
+
gitlab_relay_stop
|
|
102
|
+
rm -rf "$(relay_dir gitlab-web)" "$(relay_dir gitlab-ssh)" \
|
|
103
|
+
"$(relay_dir gitlab-8929)" "$(relay_dir gitlab-2224)"
|
|
104
|
+
# Application held by Argo CD (#538): its resources go with it
|
|
105
105
|
gitlab_application_retirer || true
|
|
106
|
-
|
|
106
|
+
account_helm "$(account_context)" uninstall gitlab --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
107
107
|
gitlab_runner_ancien_retirer
|
|
108
|
-
# RoleBinding
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if [ -n "$
|
|
108
|
+
# RoleBinding removed, then the namespace deleted by the administrator (#430)
|
|
109
|
+
account_remove "$(account_context)" "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
110
|
+
account_admin "$(account_context)" delete namespace "$GITLAB_NS" --ignore-not-found >/dev/null 2>&1 || true
|
|
111
|
+
if [ -n "$delete_secret" ]; then
|
|
112
112
|
rm -rf "$GITLAB_SECRETS_DIR"
|
|
113
|
-
echo "
|
|
113
|
+
echo "Rails secret deleted with the GitLab data."
|
|
114
114
|
elif [ -d "$GITLAB_SECRETS_DIR" ]; then
|
|
115
115
|
find "$GITLAB_SECRETS_DIR" -mindepth 1 ! -name rails-secret.yaml -exec rm -rf {} + 2>/dev/null || true
|
|
116
|
-
if [ -f "$
|
|
117
|
-
echo "secret
|
|
116
|
+
if [ -f "$GITLAB_RAILS_FILE" ]; then
|
|
117
|
+
echo "Rails secret kept in workspace/.gitlab/rails-secret.yaml (browser sessions valid at reinstallation)"
|
|
118
118
|
fi
|
|
119
119
|
fi
|
|
120
|
-
|
|
121
|
-
echo "✔ GitLab
|
|
120
|
+
gitlab_host_remove
|
|
121
|
+
echo "✔ GitLab uninstalled."
|
|
122
122
|
regenerer_identifiants
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
# Migration
|
|
126
|
-
#
|
|
127
|
-
|
|
128
|
-
local
|
|
125
|
+
# Migration: installs and seeds in the services cluster, then deletes the old
|
|
126
|
+
# kind-gitlab cluster after confirmation (or --yes).
|
|
127
|
+
gitlab_migrate() {
|
|
128
|
+
local yes_flag="" arg answer
|
|
129
129
|
for arg in "$@"; do
|
|
130
130
|
case "$arg" in
|
|
131
|
-
--yes)
|
|
132
|
-
*) echo "devzone : gitlab migrate : argument
|
|
131
|
+
--yes) yes_flag=1 ;;
|
|
132
|
+
*) echo "devzone : gitlab migrate : unknown argument : $arg (devzone gitlab migrate [--yes])" >&2; return 2 ;;
|
|
133
133
|
esac
|
|
134
134
|
done
|
|
135
135
|
|
|
136
|
-
echo "▶
|
|
137
|
-
echo "
|
|
138
|
-
|
|
136
|
+
echo "▶ Migrating GitLab from the old kind cluster…"
|
|
137
|
+
echo " This is a test GitLab: the demo project and the runner are recreated, the rest is lost."
|
|
138
|
+
gitlab_install || return $?
|
|
139
139
|
|
|
140
|
-
if ! kind get clusters 2>/dev/null | grep -qx "$
|
|
141
|
-
echo "✔
|
|
140
|
+
if ! kind get clusters 2>/dev/null | grep -qx "$GITLAB_OLD_CLUSTER"; then
|
|
141
|
+
echo "✔ No old cluster $GITLAB_OLD_CONTEXT to delete."
|
|
142
142
|
return 0
|
|
143
143
|
fi
|
|
144
144
|
|
|
145
|
-
if [ -z "$
|
|
146
|
-
if !
|
|
147
|
-
echo "devzone : gitlab : confirmation impossible
|
|
145
|
+
if [ -z "$yes_flag" ]; then
|
|
146
|
+
if ! cluster_interactive; then
|
|
147
|
+
echo "devzone : gitlab : confirmation impossible without a terminal: devzone gitlab migrate --yes (old cluster $GITLAB_OLD_CONTEXT kept)" >&2
|
|
148
148
|
return 2
|
|
149
149
|
fi
|
|
150
|
-
printf "
|
|
151
|
-
read -r
|
|
152
|
-
case "$
|
|
153
|
-
|
|
154
|
-
*) echo "
|
|
150
|
+
printf "Delete the old cluster %s and its data? [y/N] " "$GITLAB_OLD_CONTEXT" >&2
|
|
151
|
+
read -r answer || answer=""
|
|
152
|
+
case "$answer" in
|
|
153
|
+
y | Y | yes) ;;
|
|
154
|
+
*) echo "Aborted: old cluster $GITLAB_OLD_CONTEXT kept."; return 0 ;;
|
|
155
155
|
esac
|
|
156
156
|
fi
|
|
157
157
|
|
|
158
|
-
kind delete cluster --name "$
|
|
159
|
-
kubectl config delete-context "$
|
|
160
|
-
kubectl config delete-cluster "$
|
|
161
|
-
kubectl config delete-user "$
|
|
162
|
-
echo "✔
|
|
158
|
+
kind delete cluster --name "$GITLAB_OLD_CLUSTER"
|
|
159
|
+
kubectl config delete-context "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
|
|
160
|
+
kubectl config delete-cluster "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
|
|
161
|
+
kubectl config delete-user "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
|
|
162
|
+
echo "✔ Old cluster $GITLAB_OLD_CONTEXT deleted."
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
#
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
# Web and SSH access: port-forward to the ClusterIP services of the namespace.
|
|
166
|
+
gitlab_relay_start() {
|
|
167
|
+
relay_start gitlab-web devzone "$GITLAB_NS" svc/gitlab-webservice-default 8929:8181
|
|
168
|
+
relay_start gitlab-ssh devzone "$GITLAB_NS" svc/gitlab-gitlab-shell 2224:22
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
#
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
# Stops the two relays of the module.
|
|
172
|
+
gitlab_relay_stop() {
|
|
173
|
+
relay_stop gitlab-web
|
|
174
|
+
relay_stop gitlab-ssh
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
#
|
|
178
|
-
|
|
179
|
-
local
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if [ -n "$
|
|
183
|
-
echo "
|
|
177
|
+
# State of the relays: code 0 only if both are running.
|
|
178
|
+
gitlab_relay_status() {
|
|
179
|
+
local missing=""
|
|
180
|
+
relay_active gitlab-web || missing="$missing 8929"
|
|
181
|
+
relay_active gitlab-ssh || missing="$missing 2224"
|
|
182
|
+
if [ -n "$missing" ]; then
|
|
183
|
+
echo "gitlab relay stopped on${missing}"
|
|
184
184
|
return 1
|
|
185
185
|
fi
|
|
186
186
|
return 0
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
#
|
|
190
|
-
#
|
|
191
|
-
|
|
192
|
-
kind get clusters 2>/dev/null | grep -qx "$
|
|
189
|
+
# True if an old kind-gitlab cluster still exists (warning of the summary,
|
|
190
|
+
# as long as the migration has not been done).
|
|
191
|
+
gitlab_old_cluster_exists() {
|
|
192
|
+
kind get clusters 2>/dev/null | grep -qx "$GITLAB_OLD_CLUSTER"
|
|
193
193
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# workspace/.gitlab/rails-secret.yaml (600,
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
2
|
+
# GitLab Rails secret (#347): kept in workspace/.gitlab, the gitlab-rails-secret
|
|
3
|
+
# secret of the devzone-gitlab namespace, source of the Rails secrets.
|
|
4
|
+
# At the first installation, the secret of the cluster is copied to
|
|
5
|
+
# workspace/.gitlab/rails-secret.yaml (600, ignored by git); at a reinstallation,
|
|
6
|
+
# if it exists, it is applied again before helm upgrade --install (the chart
|
|
7
|
+
# reuses it and the browser sessions stay valid, without 422). Otherwise, if the
|
|
8
|
+
# secrets were lost, the end of the installation and the summary warn.
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# Name of the Rails secret and source file of the secrets of the module
|
|
11
11
|
GITLAB_RAILS_SECRET="gitlab-rails-secret"
|
|
12
|
-
|
|
12
|
+
GITLAB_RAILS_FILE="$GITLAB_SECRETS_DIR/rails-secret.yaml"
|
|
13
13
|
|
|
14
|
-
#
|
|
15
|
-
# annotations
|
|
14
|
+
# jq filter: removes the fields specific to the cluster (identity, version,
|
|
15
|
+
# management, annotations of the last apply) and keeps a re-appliable JSON manifest.
|
|
16
16
|
GITLAB_RAILS_JQ='del(.metadata.resourceVersion, .metadata.uid, .metadata.creationTimestamp, .metadata.managedFields, .metadata.ownerReferences, .metadata.annotations["kubectl.kubernetes.io/last-applied-configuration"])'
|
|
17
17
|
|
|
18
|
-
#
|
|
19
|
-
# installation).
|
|
20
|
-
|
|
18
|
+
# Reads the Rails secret of the cluster and writes a real Secret manifest in JSON
|
|
19
|
+
# (first installation). Nothing is written if the read fails or if the secret is missing.
|
|
20
|
+
gitlab_secrets_copy() {
|
|
21
21
|
local secret tmp
|
|
22
22
|
secret="$(kubectl --context devzone get secret -n "$GITLAB_NS" \
|
|
23
23
|
"$GITLAB_RAILS_SECRET" -o json 2>/dev/null)" || return 0
|
|
@@ -32,64 +32,64 @@ gitlab_secrets_copier() {
|
|
|
32
32
|
rm -f "$tmp"
|
|
33
33
|
return 0
|
|
34
34
|
}
|
|
35
|
-
mv -f "$tmp" "$
|
|
35
|
+
mv -f "$tmp" "$GITLAB_RAILS_FILE"
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
#
|
|
39
|
-
# --install
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
if [ ! -f "$
|
|
38
|
+
# Applies the Rails secret again from the source file before a helm upgrade
|
|
39
|
+
# --install: the chart reuses the existing secret, the browser sessions stay
|
|
40
|
+
# valid after a reinstallation. A failure is shown and returned.
|
|
41
|
+
gitlab_secrets_apply() {
|
|
42
|
+
if [ ! -f "$GITLAB_RAILS_FILE" ]; then
|
|
43
43
|
return 0
|
|
44
44
|
fi
|
|
45
|
-
kubectl --context devzone -n "$GITLAB_NS" apply -f "$
|
|
45
|
+
kubectl --context devzone -n "$GITLAB_NS" apply -f "$GITLAB_RAILS_FILE"
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
if [ ! -f "$
|
|
52
|
-
echo "GitLab
|
|
48
|
+
# Warns if the Rails secret could not be kept: the reinstallation generates a new
|
|
49
|
+
# secret and the browser sessions are invalidated (422).
|
|
50
|
+
gitlab_secrets_warn() {
|
|
51
|
+
if [ ! -f "$GITLAB_RAILS_FILE" ]; then
|
|
52
|
+
echo "GitLab reinstalled: if the browser shows 422, delete the site data of gitlab.localhost"
|
|
53
53
|
fi
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
local
|
|
62
|
-
case "$
|
|
56
|
+
# Random password (root | dev): Ruby script passed on the standard input of
|
|
57
|
+
# gitlab-rails runner (never on the pod command line), then the source file and
|
|
58
|
+
# the grouped .password are updated if the runner confirms. Nothing is shown,
|
|
59
|
+
# only the path.
|
|
60
|
+
gitlab_new_password() {
|
|
61
|
+
local user="${1:-}" pass pod script output file
|
|
62
|
+
case "$user" in
|
|
63
63
|
root | dev) ;;
|
|
64
64
|
*)
|
|
65
|
-
echo "devzone : gitlab :
|
|
65
|
+
echo "devzone : gitlab : unknown user : ${user:-(missing)} (devzone gitlab new-password [root|dev])" >&2
|
|
66
66
|
return 2
|
|
67
67
|
;;
|
|
68
68
|
esac
|
|
69
|
-
|
|
69
|
+
pass="$(openssl rand -hex 24)"
|
|
70
70
|
pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
|
|
71
71
|
if [ -z "$pod" ]; then
|
|
72
|
-
echo "devzone : gitlab : pod
|
|
72
|
+
echo "devzone : gitlab : toolbox pod (label app=toolbox) not found, password not changed." >&2
|
|
73
73
|
return 1
|
|
74
74
|
fi
|
|
75
|
-
script="u = User.find_by_username(\"$
|
|
76
|
-
u.password = \"$
|
|
77
|
-
u.password_confirmation = \"$
|
|
75
|
+
script="u = User.find_by_username(\"$user\")
|
|
76
|
+
u.password = \"$pass\"
|
|
77
|
+
u.password_confirmation = \"$pass\"
|
|
78
78
|
u.save!
|
|
79
79
|
puts \"OK\""
|
|
80
|
-
if !
|
|
81
|
-
echo "devzone : gitlab :
|
|
80
|
+
if ! output="$(printf '%s\n' "$script" | kubectl --context devzone exec -i -n "$GITLAB_NS" "$pod" -- gitlab-rails runner -)"; then
|
|
81
|
+
echo "devzone : gitlab : password (gitlab-rails runner) not applied." >&2
|
|
82
82
|
return 1
|
|
83
83
|
fi
|
|
84
|
-
if [[ "$
|
|
85
|
-
echo "devzone : gitlab :
|
|
84
|
+
if [[ "$output" != *OK* ]]; then
|
|
85
|
+
echo "devzone : gitlab : password not confirmed by gitlab-rails runner." >&2
|
|
86
86
|
return 1
|
|
87
87
|
fi
|
|
88
|
-
|
|
88
|
+
file="$GITLAB_SECRETS_DIR/$user-password"
|
|
89
89
|
mkdir -p "$GITLAB_SECRETS_DIR" || return 1
|
|
90
|
-
(umask 077 && printf '%s' "$
|
|
91
|
-
chmod 600 "$
|
|
90
|
+
(umask 077 && printf '%s' "$pass" >"$file") || return 1
|
|
91
|
+
chmod 600 "$file"
|
|
92
92
|
password_regenerate ||
|
|
93
|
-
echo "devzone : gitlab :
|
|
93
|
+
echo "devzone : gitlab : grouped credentials not updated (devzone passwords)" >&2
|
|
94
94
|
printf '%s\n' "$RACINE/.password"
|
|
95
95
|
}
|