Add function to check the externalURL http prefix

Signed-off-by: Miguel A. Cabrera Minagorri <macabrera@bitnami.com>
This commit is contained in:
Miguel A. Cabrera Minagorri
2019-11-20 12:29:52 +00:00
parent 9f1ff85c74
commit 7f0069e114
7 changed files with 23 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
apiVersion: v1
name: harbor
version: 3.0.6
version: 3.0.7
appVersion: 1.9.3
description: Harbor is an an open source trusted cloud native registry project that stores, signs, and scans content
keywords:

View File

@@ -4,7 +4,7 @@
{{- if contains "Ingress" .Values.service.type }}
You should be able to access your new Harbor installation through {{ .Values.externalURL }}
You should be able to access your new Harbor installation through {{ include "harbor.externalUrl" . }}
{{- else if contains "LoadBalancer" .Values.service.type }}
@@ -43,4 +43,4 @@
echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "harbor.core" . }}-envvars -o jsonpath="{.data.HARBOR_ADMIN_PASSWORD}" | base64 --decode)
{{ include "harbor.validateValues" . }}
{{ include "harbor.checkRollingTags" . }}
{{ include "harbor.checkRollingTags" . }}

View File

@@ -837,9 +837,20 @@ Usage:
{{ include "harbor.tplValue" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "harbor.tplValue" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- if typeIs "string" .value -}}
{{- tpl .value .context -}}
{{- else -}}
{{- tpl (.value | toYaml) .context -}}
{{- end -}}
{{- end -}}
{{/*
Set the http prefix if the externalURl dont have it
*/}}
{{- define "harbor.externalUrl" -}}
{{- if hasPrefix "http" .Values.externalURL -}}
{{- print .Values.externalURL -}}
{{- else -}}
{{- printf "http://%s" .Values.externalURL -}}
{{- end -}}
{{- end -}}

View File

@@ -15,7 +15,7 @@ data:
# The user is hardcoded because the core binary has it hardcoded so it is not configurable.
BASIC_AUTH_USER: "chart_controller"
{{- if .Values.chartmuseum.absoluteUrl }}
CHART_URL: "{{ .Values.externalURL }}/{{ .Values.chartmuseum.chartRepoName }}"
CHART_URL: "{{ template "harbor.externalUrl" . }}/{{ .Values.chartmuseum.chartRepoName }}"
{{- end }}
DEPTH: {{ .Values.chartmuseum.depth | quote }}
{{- if or (eq .Values.logLevel "debug") .Values.chartMuseumImage.debug }}

View File

@@ -10,7 +10,7 @@ data:
POSTGRESQL_USERNAME: "{{ .Values.postgresql.postgresqlUsername }}"
POSTGRESQL_DATABASE: "registry"
POSTGRESQL_SSLMODE: "{{ template "harbor.database.sslmode" . }}"
EXT_ENDPOINT: "{{ .Values.externalURL }}"
EXT_ENDPOINT: "{{ template "harbor.externalUrl" . }}"
CORE_URL: "http://{{ template "harbor.core" . }}"
JOBSERVICE_URL: "http://{{ template "harbor.fullname" . }}-jobservice"
REGISTRY_URL: "http://{{ template "harbor.registry" . }}:5000"

View File

@@ -42,7 +42,7 @@ data:
"auth": {
"type": "token",
"options": {
"realm": "{{ .Values.externalURL }}/service/token",
"realm": "{{ template "harbor.externalUrl" . }}/service/token",
"service": "harbor-notary",
"issuer": "harbor-token-issuer",
"rootcertbundle": "/root.crt"

View File

@@ -150,7 +150,7 @@ data:
auth:
token:
issuer: harbor-token-issuer
realm: "{{ .Values.externalURL }}/service/token"
realm: "{{ template "harbor.externalUrl" . }}/service/token"
rootcertbundle: /etc/registry/root.crt
service: harbor-registry
validation: