fix: create user from main pod instead of job
All checks were successful
/ deploy (push) Successful in 43s
All checks were successful
/ deploy (push) Successful in 43s
This commit is contained in:
parent
5395428902
commit
db7a6b226d
@ -12,19 +12,25 @@ name="$1"
|
||||
scopes="$2"
|
||||
email="$name@$BASE_URL"
|
||||
secret="gitea-$name"
|
||||
passwd="$(kgseckey "$secret" password)"
|
||||
|
||||
if ! kubectl get secret "$secret" > /dev/null 2>&1; then
|
||||
kcreatesec "$secret" \
|
||||
--from-literal=email="$email" \
|
||||
--from-literal=username="$name" \
|
||||
--from-literal=password="$(openssl rand -hex 32)"
|
||||
NAME="$name" SECRET="$secret" kapply common/createadmin.yaml
|
||||
if [ -z "$passwd" ]; then
|
||||
passwd="$(openssl rand -hex 32)"
|
||||
kubectl exec statefulset/app -- \
|
||||
gitea admin user create --admin --must-change-password=false \
|
||||
--email "$email" \
|
||||
--username "$name" \
|
||||
--password "$passwd"
|
||||
fi
|
||||
|
||||
if [ -n "$scopes" ]; then
|
||||
kcreatesec "$secret" \
|
||||
--from-literal=email="$email" \
|
||||
--from-literal=username="$name" \
|
||||
--from-literal=password="$(kgseckey "$secret" password)" \
|
||||
--from-literal=token="$(kgseckey "$secret" token || get_token)"
|
||||
fi
|
||||
opts=()
|
||||
[ -n "$scopes" ] && opts+=(
|
||||
--from-literal=token="$(kgseckey "$secret" token || get_token)"
|
||||
--from-literal=tokenscopes="$scopes"
|
||||
)
|
||||
|
||||
kcreatesec "$secret" \
|
||||
--from-literal=email="$email" \
|
||||
--from-literal=username="$name" \
|
||||
--from-literal=password="$passwd" \
|
||||
"${opts[@]}"
|
||||
|
@ -1,39 +0,0 @@
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: "createadmin-$NAME"
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: createuser
|
||||
image: "$IMAGEAPP"
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: "$SECRET"
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- gitea admin user change-password --must-change-password=false \
|
||||
--username "$username" \
|
||||
--password "$password" \
|
||||
|| gitea admin user create --admin --must-change-password=false \
|
||||
--email "$email" \
|
||||
--username "$username" \
|
||||
--password "$password" \
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/gitea/app.ini
|
||||
subPath: app.ini
|
||||
- name: secrets
|
||||
mountPath: /etc/gitea/secrets/
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: gitea
|
||||
- name: secrets
|
||||
secret:
|
||||
secretName: gitea
|
||||
backoffLimit: 4
|
Loading…
Reference in New Issue
Block a user