-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPSEXP-1862: move named tpl in alfresco-common (#91)
- Loading branch information
Showing
10 changed files
with
335 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{/* | ||
Compute Secret checksum whether it's read from values or from secrets | ||
Usage: include "alfresco-common.secret-checksum" (dict "ns" $.Release.Namespace "context" (dict "some-key" (dict "existingSecret" (dict "keys" (dict "username" "" "password" "")))) "configKey" "some-key") | ||
*/}} | ||
{{- define "alfresco-common.secret-checksum" -}} | ||
{{- $ns := required "template needs to be given the release namepace" .ns }} | ||
{{- with (index .context .configKey) }} | ||
{{- if .existingSecret.name }} | ||
checksum.config.alfresco.org/{{ $.configKey }}-existing: | ||
{{- $defaultLookup := dict "data" dict }} | ||
{{- $lookup := lookup "v1" "Secret" $ns (.existingSecret.name) | default $defaultLookup }} | ||
{{- pick $lookup.data .existingSecret.keys.username .existingSecret.keys.password | toJson | sha256sum | indent 1}} | ||
{{- else }} | ||
checksum.config.alfresco.org/{{ $.configKey }}-values: {{ omit . "existingSecret" | toJson | sha256sum }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} |
12 changes: 11 additions & 1 deletion
12
charts/alfresco-common/templates/_helpers-image-pull-secrets.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
{{- define "alfresco-content-services.imagePullSecrets" }} | ||
{{/* | ||
Read pull secrets from .Values.global | ||
Usage: include "alfresco-common.imagePullSecrets" $ | ||
*/}} | ||
{{- define "alfresco-common.imagePullSecrets" }} | ||
{{- if .Values.global.alfrescoRegistryPullSecrets }} | ||
imagePullSecrets: | ||
- name: {{ .Values.global.alfrescoRegistryPullSecrets }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- define "alfresco-content-services.imagePullSecrets" }} | ||
{{- template "alfresco-common.imagePullSecrets" . }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{{/* | ||
Compute a JDBC URL object | ||
We're just manipulating the string URl to make it parseable by urlParse. | ||
This template SHOULD NOT be used directly. | ||
Usage: include "alfresco-common.jdbc.parser" "URL" | ||
*/}} | ||
{{- define "alfresco-common.jdbc.parser" -}} | ||
{{- $jdbc_url := required "Alfresco repository needs a database to start. Please provide a valid URL in db.url value" . }} | ||
{{- if hasPrefix "jdbc:" $jdbc_url }} | ||
{{- fail "database URL MUST be provided WITHOUT the 'jdbc' prefix." }} | ||
{{- end }} | ||
{{- if hasPrefix "oracle:thin:@" $jdbc_url }} | ||
{{- $ora_url := trimPrefix "oracle:thin:" $jdbc_url }} | ||
{{- $ora_url = (mustRegexReplaceAllLiteral "^@(tcps?://)?" $ora_url "oracle://") }} | ||
{{- $jdbc_url = $ora_url }} | ||
{{- end }} | ||
{{- if hasPrefix "sqlserver://" $jdbc_url }} | ||
{{- $jdbc_url = trimPrefix "sqlserver://" $jdbc_url }} | ||
{{- $query := $jdbc_url | splitList ";" }} | ||
{{- $host := "" }} | ||
{{- if and (not (empty (index $query 0))) (not (contains "=" (index $query 0))) }} | ||
{{- $host = index $query 0 }} | ||
{{- $query = rest $query }} | ||
{{- end }} | ||
{{- $path := "" }} | ||
{{- range $query }} | ||
{{- if and (hasPrefix "serverName=" .) (empty $host) }} | ||
{{- $host = trimPrefix "serverName=" . }} | ||
{{- $_ := mustWithout $query . }} | ||
{{- end }} | ||
{{- if hasPrefix "databaseName=" . }} | ||
{{- $path = trimPrefix "databaseName=" . }} | ||
{{- $_ := mustWithout $query . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- $ms_url := printf "sqlserver://%s/%s?%s" $host $path ($query | join "&") }} | ||
{{- $jdbc_url = $ms_url }} | ||
{{- end }} | ||
{{- $parsed_url := urlParse $jdbc_url }} | ||
{{- if or (empty $parsed_url.host) (empty $parsed_url.hostname) (empty $parsed_url.scheme) (eq "/" $parsed_url.path) }} | ||
{{- fail "The provided JDBC URL cannot be parsed please check or raise a bug." }} | ||
{{- end }} | ||
{{- mustToJson (dict "jdbc" $parsed_url) }} | ||
{{- end -}} | ||
{{/* | ||
Compute default ports based on URL | ||
Usage: include "alfresco-common.db.default.port" "URL" | ||
*/}} | ||
{{- define "alfresco-common.db.default.port" -}} | ||
{{- $pg_rdbms := dict "name" "postgresql" "port" 5432 }} | ||
{{- $my_rdbms := dict "name" "mysql" "port" 3306 }} | ||
{{- $maria_rdbms := dict "name" "mariadb" "port" 3306 }} | ||
{{- $ora_rdbms := dict "name" "oracle" "port" 1521 }} | ||
{{- $ms_rdbms := dict "name" "sqlserver" "port" 1434 }} | ||
{{- range $rdbms := list $pg_rdbms $my_rdbms $maria_rdbms $ora_rdbms $ms_rdbms }} | ||
{{- eq $rdbms.name $ | ternary $rdbms.port "" }} | ||
{{- end }} | ||
{{- end -}} | ||
{{/* | ||
Compute default driver based on URL | ||
Usage: include "alfresco-common.db.default.driver" "URL" | ||
*/}} | ||
{{- define "alfresco-common.db.default.driver" -}} | ||
{{- $pg_rdbms := dict "name" "postgresql" "driver" "org.postgresql.Driver" }} | ||
{{- $my_rdbms := dict "name" "mysql" "driver" "com.mysql.jdbc.Driver" }} | ||
{{- $maria_rdbms := dict "name" "mariadb" "driver" "org.mariadb.jdbc.Driver" }} | ||
{{- $ora_rdbms := dict "name" "oracle" "driver" "oracle.jdbc.OracleDriver" }} | ||
{{- $ms_rdbms := dict "name" "sqlserver" "driver" "com.microsoft.sqlserver.jdbc.SQLServerDriver" }} | ||
{{- range $rdbms := list $pg_rdbms $my_rdbms $maria_rdbms $ora_rdbms $ms_rdbms }} | ||
{{- eq $rdbms.name $ | ternary $rdbms.driver "" }} | ||
{{- end }} | ||
{{- end -}} | ||
{{/* | ||
Provide repository database engine from URL | ||
Usage: include "alfresco-common.db.rdbms" "URL" | ||
*/}} | ||
{{- define "alfresco-common.db.rdbms" -}} | ||
{{- index (include "alfresco-common.jdbc.parser" . | fromJson) "jdbc" "scheme" }} | ||
{{- end -}} | ||
{{/* | ||
Provide repository database hostname | ||
Usage: include "alfresco-common.db.hostname" "URL" | ||
*/}} | ||
{{- define "alfresco-common.db.hostname" -}} | ||
{{- index (include "alfresco-common.jdbc.parser" . | fromJson) "jdbc" "hostname" }} | ||
{{- end -}} | ||
{{/* | ||
Provide database port from JDBC URL | ||
Usage: include "alfresco-common.db.port" (dict "url" "someurl") | ||
*/}} | ||
{{- define "alfresco-common.db.port" -}} | ||
{{- $socket := (index (include "alfresco-common.jdbc.parser" .url | fromJson) "jdbc" "host") }} | ||
{{- if gt ($socket | splitList ":" | len) 1 }} | ||
{{- $socket | splitList ":" | last }} | ||
{{- else }} | ||
{{- template "alfresco-common.db.default.port" (index (include "alfresco-common.jdbc.parser" .url | fromJson) "jdbc" "scheme") }} | ||
{{- end }} | ||
{{- end -}} | ||
{{/* | ||
Provide database driverClass based on JDBC URL | ||
Usage: include "alfresco-common.db.driver" (dict "url" "someurl" "driver" "driverclass") | ||
*/}} | ||
{{- define "alfresco-common.db.driver" -}} | ||
{{- $scheme := index (include "alfresco-common.jdbc.parser" .url | fromJson) "jdbc" "scheme" }} | ||
{{- coalesce .driver (include "alfresco-common.db.default.driver" $scheme) }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.