|
| 1 | +# Copyright 2017 The Openstack-Helm Authors. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# fqdn |
| 16 | +{{- define "helm-toolkit.region"}}cluster{{- end}} |
| 17 | +{{- define "helm-toolkit.tld"}}local{{- end}} |
| 18 | + |
| 19 | +{{- define "helm-toolkit.fqdn" -}} |
| 20 | +{{- $fqdn := .Release.Namespace -}} |
| 21 | +{{- if .Values.endpoints.fqdn -}} |
| 22 | +{{- $fqdn := .Values.endpoints.fqdn -}} |
| 23 | +{{- end -}} |
| 24 | +{{- $fqdn -}} |
| 25 | +{{- end -}} |
| 26 | + |
| 27 | +#----------------------------------------- |
| 28 | +# hosts |
| 29 | +#----------------------------------------- |
| 30 | + |
| 31 | +# infrastructure services |
| 32 | +{{- define "helm-toolkit.postgresql_host"}}postgresql.{{.Release.Namespace}}.svc.{{ include "helm-toolkit.region" . }}.{{ include "helm-toolkit.tld" . }}{{- end}} |
| 33 | + |
| 34 | + |
| 35 | +{{- define "helm-toolkit.joinListWithComma" -}} |
| 36 | +{{ range $k, $v := . }}{{ if $k }},{{ end }}{{ $v }}{{ end }} |
| 37 | +{{- end -}} |
| 38 | + |
| 39 | +{{- define "helm-toolkit.template" -}} |
| 40 | +{{- $name := index . 0 -}} |
| 41 | +{{- $context := index . 1 -}} |
| 42 | +{{- $v:= $context.Template.Name | split "/" -}} |
| 43 | +{{- $n := len $v -}} |
| 44 | +{{- $last := sub $n 1 | printf "_%d" | index $v -}} |
| 45 | +{{- $wtf := $context.Template.Name | replace $last $name -}} |
| 46 | +{{ include $wtf $context }} |
| 47 | +{{- end -}} |
| 48 | + |
| 49 | +{{- define "helm-toolkit.hash" -}} |
| 50 | +{{- $name := index . 0 -}} |
| 51 | +{{- $context := index . 1 -}} |
| 52 | +{{- $v:= $context.Template.Name | split "/" -}} |
| 53 | +{{- $n := len $v -}} |
| 54 | +{{- $last := sub $n 1 | printf "_%d" | index $v -}} |
| 55 | +{{- $wtf := $context.Template.Name | replace $last $name -}} |
| 56 | +{{- include $wtf $context | sha256sum | quote -}} |
| 57 | +{{- end -}} |
| 58 | + |
| 59 | + |
| 60 | +{{- define "helm-toolkit.kubernetes_entrypoint_init_container" -}} |
| 61 | +{{- $envAll := index . 0 -}} |
| 62 | +{{- $deps := index . 1 -}} |
| 63 | +{ |
| 64 | + "name": "init", |
| 65 | + "image": {{ $envAll.Values.images.dep_check | quote }}, |
| 66 | + "imagePullPolicy": {{ $envAll.Values.images.pull_policy | quote }}, |
| 67 | + "env": [ |
| 68 | + { |
| 69 | + "name": "POD_NAME", |
| 70 | + {{- if $deps.pod -}} |
| 71 | + "value": "{{ index $deps.pod 0 }}" |
| 72 | + {{- else -}} |
| 73 | + "valueFrom": { |
| 74 | + "fieldRef": { |
| 75 | + "APIVersion": "v1", |
| 76 | + "fieldPath": "metadata.name" |
| 77 | + } |
| 78 | + } |
| 79 | + {{- end -}} |
| 80 | + }, |
| 81 | + { |
| 82 | + "name": "NAMESPACE", |
| 83 | + "valueFrom": { |
| 84 | + "fieldRef": { |
| 85 | + "APIVersion": "v1", |
| 86 | + "fieldPath": "metadata.namespace" |
| 87 | + } |
| 88 | + } |
| 89 | + }, |
| 90 | + { |
| 91 | + "name": "INTERFACE_NAME", |
| 92 | + "value": "eth0" |
| 93 | + }, |
| 94 | + { |
| 95 | + "name": "DEPENDENCY_SERVICE", |
| 96 | + "value": "{{ include "helm-toolkit.joinListWithComma" $deps.service }}" |
| 97 | + }, |
| 98 | + { |
| 99 | + "name": "DEPENDENCY_JOBS", |
| 100 | + "value": "{{ include "helm-toolkit.joinListWithComma" $deps.jobs }}" |
| 101 | + }, |
| 102 | + { |
| 103 | + "name": "DEPENDENCY_DAEMONSET", |
| 104 | + "value": "{{ include "helm-toolkit.joinListWithComma" $deps.daemonset }}" |
| 105 | + }, |
| 106 | + { |
| 107 | + "name": "DEPENDENCY_CONTAINER", |
| 108 | + "value": "{{ include "helm-toolkit.joinListWithComma" $deps.container }}" |
| 109 | + }, |
| 110 | + { |
| 111 | + "name": "COMMAND", |
| 112 | + "value": "echo done" |
| 113 | + } |
| 114 | + ] |
| 115 | +} |
| 116 | +{{- end -}} |
0 commit comments