fix(gitea): default to nodeIP for DOMAIN and ROOT_URL (#5003)
* fix(gitea): default to nodeIP for DOMAIN and ROOT_URL * fix issue #4118 * add regex validation
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# Input Validation
|
||||
|
||||
**`username`**
|
||||
Accepted formats are:
|
||||
|
||||
- Any character except the word `admin`
|
||||
|
||||
Regex used to match this: `^(?!^admin$).*$`
|
||||
You can try live [here](https://regex101.com/r/n91qZM/1)
|
||||
|
||||
---
|
||||
|
||||
_If you find a field that you think it needs validation, please open an issue on github_
|
||||
@@ -20,6 +20,7 @@ questions:
|
||||
label: "username"
|
||||
schema:
|
||||
type: string
|
||||
valid_chars: '^(?!^admin$).*$'
|
||||
required: true
|
||||
- variable: password
|
||||
label: "password"
|
||||
@@ -63,6 +64,14 @@ questions:
|
||||
type: string
|
||||
default: "127.0.0.1"
|
||||
required: true
|
||||
- variable: nodeIP
|
||||
label: Node IP
|
||||
description: Used to generate configuration, when installed without ingress
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
$ref:
|
||||
- "definitions/nodeIP"
|
||||
- variable: customConfig
|
||||
group: "App Configuration"
|
||||
label: "Custom Configuration parameters"
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
{{- define "gitea.secrets" -}}
|
||||
|
||||
---
|
||||
{{ $DOMAIN := .Values.config.nodeIP | quote -}}
|
||||
{{ $URL := (printf "http://%s/" .Values.config.nodeIP) }}
|
||||
|
||||
{{ $DOMAIN := ( printf "%s-gitea.%s.svc.%s" .Release.Name .Release.Namespace "cluster.local" | quote ) -}}
|
||||
{{- if and ( .Values.ingress.main.enabled ) ( gt (len .Values.ingress.main.hosts) 0 ) -}}
|
||||
{{- $DOMAIN = (index .Values.ingress.main.hosts 0).host -}}
|
||||
{{- if and (.Values.ingress.main.enabled) (gt (len .Values.ingress.main.hosts) 0) -}}
|
||||
{{- $DOMAIN = (index .Values.ingress.main.hosts 0).host -}}
|
||||
{{- $URL = (printf "https://%s/" (index .Values.ingress.main.hosts 0).host) -}}
|
||||
{{- end -}}
|
||||
|
||||
apiVersion: v1
|
||||
@@ -86,11 +88,7 @@ stringData:
|
||||
ENABLE_PPROF = false
|
||||
HTTP_PORT = {{ .Values.service.main.ports.main.targetPort }}
|
||||
PROTOCOL = http
|
||||
{{- if and ( .Values.ingress.main.enabled ) ( gt (len .Values.ingress.main.hosts) 0 ) }}
|
||||
ROOT_URL = {{ printf "https://%s" $DOMAIN }}
|
||||
{{- else }}
|
||||
ROOT_URL = {{ printf "http://%s" $DOMAIN }}
|
||||
{{- end }}
|
||||
ROOT_URL = {{ $URL }}
|
||||
SSH_DOMAIN = {{ $DOMAIN }}
|
||||
SSH_LISTEN_PORT = {{ .Values.service.ssh.ports.ssh.targetPort }}
|
||||
SSH_PORT = {{ .Values.service.ssh.ports.ssh.port }}
|
||||
@@ -189,13 +187,13 @@ stringData:
|
||||
|
||||
{{- if or .Values.admin.existingSecret (and .Values.admin.username .Values.admin.password) }}
|
||||
function configure_admin_user() {
|
||||
local ACCOUNT_ID=$(gitea admin user list --admin | grep -e "\s\+${GITEA_ADMIN_USERNAME}\s\+" | awk -F " " "{printf \$1}")
|
||||
local ACCOUNT_ID=$(gitea admin user list --admin | grep -e "\s\+${GITEA_ADMIN_USERNAME}\|{{ .Values.admin.email }}\s\+" | awk -F " " "{printf \$1}")
|
||||
if [[ -z "${ACCOUNT_ID}" ]]; then
|
||||
echo "No admin user '${GITEA_ADMIN_USERNAME}' found. Creating now..."
|
||||
echo "No admin user '${GITEA_ADMIN_USERNAME}' found, neither email '{{ .Values.admin.email }}' is assigned to an admin. Creating now..."
|
||||
gitea admin user create --admin --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}" --email {{ .Values.admin.email | quote }} --must-change-password=false
|
||||
echo '...created.'
|
||||
else
|
||||
echo "Admin account '${GITEA_ADMIN_USERNAME}' already exist. Running update to sync password..."
|
||||
echo "Admin account '${GITEA_ADMIN_USERNAME}' or email {{ .Values.admin.email }} already exist. Running update to sync password..."
|
||||
gitea admin user change-password --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}"
|
||||
echo '...password sync done.'
|
||||
fi
|
||||
|
||||
@@ -121,6 +121,7 @@ config:
|
||||
APP_NAME: "Gitea: Git with a cup of tea"
|
||||
RUN_MODE: dev
|
||||
ALLOWED_HOST_LIST: "127.0.0.1"
|
||||
nodeIP: 127.0.0.1
|
||||
|
||||
customConfig:
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user