Skip to content

Commit b383cc5

Browse files
fix(cf-common): fix calculateRabbitMqUri tpl (#29)
1 parent 6f18d52 commit b383cc5

30 files changed

+177
-210
lines changed

charts/cf-common-test/tests/deployment/classic_conn_uri_test.yaml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ suite: classic connection Uri
33
templates:
44
- templates/controller.yaml
55
tests:
6-
- it: Test External RabbitMQ connection Uri
6+
- it: Test RabbitMQ connection Uri
77
values:
88
- values.yaml
99
set:
@@ -24,29 +24,6 @@ tests:
2424
name: RABBIT_URL
2525
value: "amqps://username:[email protected]:5671"
2626

27-
- it: Test Internal RabbitMQ connection Uri
28-
release:
29-
name: cf
30-
values:
31-
- values.yaml
32-
set:
33-
global:
34-
rabbitmqService: rabbitmq
35-
rabbitmq:
36-
enabled: true
37-
auth:
38-
username: user
39-
password: pass
40-
container:
41-
env:
42-
RABBIT_URL: '{{ include (printf "cf-common-%s.classic.calculateRabbitMqUri" (index .Subcharts "cf-common").Chart.Version) . }}'
43-
asserts:
44-
- contains:
45-
path: spec.template.spec.containers[0].env
46-
content:
47-
name: RABBIT_URL
48-
value: "amqp://user:pass@cf-rabbitmq"
49-
5027
- it: Test External MongoDB connection Uri
5128
values:
5229
- values.yaml

charts/cf-common/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: v0.0.0
33
description: Codefresh library chart
44
name: cf-common
5-
version: 0.1.1
5+
version: 0.1.2
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Codefresh library chart
44

5-
![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
5+
![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
66

77
## Installing the Chart
88

@@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
1818
# Chart.yaml
1919
dependencies:
2020
- name: cf-common
21-
version: 0.1.1
21+
version: 0.1.2
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424

charts/cf-common/templates/classic/_helpers.tpl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
{{/*
22
Calculate RabbitMQ URI (for On-Prem)
33
Usage
4-
{{ include "cf-common-0.1.1.classic.calculateRabbitMqUri" . }}
4+
{{ include "cf-common-0.1.2.classic.calculateRabbitMqUri" . }}
55
*/}}
66

7-
{{- define "cf-common-0.1.1.classic.calculateRabbitMqUri" }}
7+
{{- define "cf-common-0.1.2.classic.calculateRabbitMqUri" }}
88

99
{{- $rabbitmqProtocol := .Values.global.rabbitmqProtocol | default "amqp" -}}
1010
{{- $rabbitmqUsername := .Values.global.rabbitmqUsername -}}
1111
{{- $rabbitmqPassword := .Values.global.rabbitmqPassword -}}
1212

13-
{{- /*
14-
If built-in bitnami/rabbitmq chart enabled get username/password there
15-
*/}}
16-
{{- if .Values.rabbitmq }}
17-
{{- if .Values.rabbitmq.enabled }}
18-
{{- $rabbitmqUsername = .Values.rabbitmq.auth.username -}}
19-
{{- $rabbitmqPassword = .Values.rabbitmq.auth.password -}}
20-
{{- end }}
21-
{{- end }}
22-
2313
{{- /*
2414
coalesce here for backward compatibility
2515
*/}}
@@ -32,9 +22,9 @@ coalesce here for backward compatibility
3222
{{/*
3323
Calculate Mongo Uri (for On-Prem)
3424
Usage:
35-
{{ include "cf.common-0.1.1.classic.calculateMongoUri" (dict "dbName" $.Values.global.pipelineManagerService "mongoURI" $.Values.global.mongoURI) }}
25+
{{ include "cf.common-0.1.2.classic.calculateMongoUri" (dict "dbName" $.Values.global.pipelineManagerService "mongoURI" $.Values.global.mongoURI) }}
3626
*/}}
37-
{{- define "cf-common-0.1.1.classic.calculateMongoUri" -}}
27+
{{- define "cf-common-0.1.2.classic.calculateMongoUri" -}}
3828
{{- if contains "?" .mongoURI -}}
3929
{{- $mongoURI := (splitList "?" .mongoURI) -}}
4030
{{- printf "%s%s?%s" (first $mongoURI) .dbName (last $mongoURI) }}

charts/cf-common/templates/common/_annotations.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
Render checksum annotation
33
Usage:
44
*/}}
5-
{{- define "cf-common-0.1.1.annotations.podAnnotations" -}}
5+
{{- define "cf-common-0.1.2.annotations.podAnnotations" -}}
66

77
{{- if .Values.podAnnotations -}}
8-
{{- include "cf-common-0.1.1.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 0 }}
8+
{{- include "cf-common-0.1.2.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 0 }}
99
{{- end -}}
1010

1111
{{- $configMapFound := dict -}}
1212
{{- range $configMapIndex, $configMapItem := .Values.configMaps -}}
1313

1414
{{- if $configMapItem.enabled -}}
15-
{{- $_ := set $configMapFound $configMapIndex ( include "cf-common-0.1.1.tplrender" (dict "Values" $configMapItem.data "context" $) | sha256sum) -}}
15+
{{- $_ := set $configMapFound $configMapIndex ( include "cf-common-0.1.2.tplrender" (dict "Values" $configMapItem.data "context" $) | sha256sum) -}}
1616
{{- end -}}
1717

1818
{{- if $configMapFound -}}
@@ -25,7 +25,7 @@ Usage:
2525
{{- range $secretIndex, $secretItem := .Values.secrets -}}
2626

2727
{{- if $secretItem.enabled -}}
28-
{{- $_ := set $secretFound $secretIndex ( include "cf-common-0.1.1.tplrender" (dict "Values" $secretItem.stringData "context" $) | sha256sum) -}}
28+
{{- $_ := set $secretFound $secretIndex ( include "cf-common-0.1.2.tplrender" (dict "Values" $secretItem.stringData "context" $) | sha256sum) -}}
2929
{{- end -}}
3030

3131
{{- if $secretFound -}}

charts/cf-common/templates/common/_labels.tpl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{{/*
22
Kubernetes standard labels
33
*/}}
4-
{{- define "cf-common-0.1.1.labels.standard" -}}
5-
app.kubernetes.io/name: {{ include "cf-common-0.1.1.names.name" . }}
6-
helm.sh/chart: {{ include "cf-common-0.1.1.names.chart" . }}
4+
{{- define "cf-common-0.1.2.labels.standard" -}}
5+
app.kubernetes.io/name: {{ include "cf-common-0.1.2.names.name" . }}
6+
helm.sh/chart: {{ include "cf-common-0.1.2.names.chart" . }}
77
app.kubernetes.io/instance: {{ .Release.Name }}
88
app.kubernetes.io/managed-by: {{ .Release.Service }}
99
{{- end -}}
1010

1111
{{/*
1212
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
1313
*/}}
14-
{{- define "cf-common-0.1.1.labels.matchLabels" -}}
15-
app.kubernetes.io/name: {{ include "cf-common-0.1.1.names.name" . }}
14+
{{- define "cf-common-0.1.2.labels.matchLabels" -}}
15+
app.kubernetes.io/name: {{ include "cf-common-0.1.2.names.name" . }}
1616
app.kubernetes.io/instance: {{ .Release.Name }}
1717
{{- end -}}
1818

1919

2020
{{/*
2121
Extra labels
2222
Usage:
23-
{{ include "cf-common-0.1.1.labels.extraLabels" ( dict "Values" .Values.path.to.the.labels "context" $) }}
23+
{{ include "cf-common-0.1.2.labels.extraLabels" ( dict "Values" .Values.path.to.the.labels "context" $) }}
2424
*/}}
25-
{{- define "cf-common-0.1.1.labels.extraLabels" -}}
25+
{{- define "cf-common-0.1.2.labels.extraLabels" -}}
2626
{{- if not (kindIs "map" .Values) -}}
2727
{{- fail "ERROR: labels block must be a map" -}}
2828
{{- end -}}
@@ -34,9 +34,9 @@ Usage:
3434
{{/*
3535
Annotations
3636
Usage:
37-
{{ include "cf-common-0.1.1.annotations" ( dict "Values" .Values.path.to.the.annotations "context" $) }}
37+
{{ include "cf-common-0.1.2.annotations" ( dict "Values" .Values.path.to.the.annotations "context" $) }}
3838
*/}}
39-
{{- define "cf-common-0.1.1.annotations" -}}
39+
{{- define "cf-common-0.1.2.annotations" -}}
4040
{{- if not (kindIs "map" .Values) -}}
4141
{{- fail "ERROR: annotations block must be a map" -}}
4242
{{- end -}}

charts/cf-common/templates/common/_names.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{{/*
22
Expand the name of the chart.
33
*/}}
4-
{{- define "cf-common-0.1.1.names.name" -}}
4+
{{- define "cf-common-0.1.2.names.name" -}}
55
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
66
{{- end -}}
77

88
{{/*
99
Create chart name and version as used by the chart label.
1010
*/}}
11-
{{- define "cf-common-0.1.1.names.chart" -}}
11+
{{- define "cf-common-0.1.2.names.chart" -}}
1212
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
1313
{{- end -}}
1414

@@ -17,7 +17,7 @@ Create a default fully qualified app name.
1717
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
1818
If release name contains chart name it will be used as a full name.
1919
*/}}
20-
{{- define "cf-common-0.1.1.names.fullname" -}}
20+
{{- define "cf-common-0.1.2.names.fullname" -}}
2121
{{- if .Values.fullnameOverride -}}
2222
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
2323
{{- else -}}
@@ -33,10 +33,10 @@ If release name contains chart name it will be used as a full name.
3333
{{/*
3434
ServiceAccount Name
3535
*/}}
36-
{{- define "cf-common-0.1.1.names.serviceAccountName" -}}
36+
{{- define "cf-common-0.1.2.names.serviceAccountName" -}}
3737
{{- if .Values.serviceAccount -}}
3838
{{- if .Values.serviceAccount.enabled -}}
39-
{{- .Values.serviceAccount.nameOverride | default (include "cf-common-0.1.1.names.fullname" .) -}}
39+
{{- .Values.serviceAccount.nameOverride | default (include "cf-common-0.1.2.names.fullname" .) -}}
4040
{{- else -}}
4141
{{- print "default" -}}
4242
{{- end -}}

charts/cf-common/templates/common/_tpl.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{{/*
22
Renders a value that contains template.
33
Usage:
4-
{{ include "cf-common-0.1.1.tplrender" ( dict "Values" .Values.path.to.the.Value "context" $) }}
4+
{{ include "cf-common-0.1.2.tplrender" ( dict "Values" .Values.path.to.the.Value "context" $) }}
55
*/}}
6-
{{- define "cf-common-0.1.1.tplrender" -}}
6+
{{- define "cf-common-0.1.2.tplrender" -}}
77
{{- $tpl := .Values -}}
88
{{- if not (typeIs "string" $tpl) -}}
99
{{- $tpl = toYaml $tpl -}}

charts/cf-common/templates/container/_container.tpl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{{/*
22
Renders main container in pod template
33
Usage:
4-
{{ include "cf-common-0.1.1.container" (dict "Values" .Values.container "context" $) }}
4+
{{ include "cf-common-0.1.2.container" (dict "Values" .Values.container "context" $) }}
55
*/}}
6-
{{- define "cf-common-0.1.1.container" -}}
6+
{{- define "cf-common-0.1.2.container" -}}
77

88
{{/* Restoring root $ context */}}
99
{{- $ := .context -}}
1010

11-
- name: {{ include "cf-common-0.1.1.names.fullname" $ }}
12-
image: {{ include "cf-common-0.1.1.image.name" (dict "image" .Values.image "context" $) }}
11+
- name: {{ include "cf-common-0.1.2.names.fullname" $ }}
12+
image: {{ include "cf-common-0.1.2.image.name" (dict "image" .Values.image "context" $) }}
1313
imagePullPolicy: {{ .Values.image.pullPolicy | default "Always" }}
1414

1515
{{- with .Values.command }}
1616
{{- if not (kindIs "slice" .) }}
1717
{{- fail "ERROR: container.command block must be a list!" }}
1818
{{- end }}
19-
command: {{- include "cf-common-0.1.1.tplrender" (dict "Values" . "context" $) | nindent 2 }}
19+
command: {{- include "cf-common-0.1.2.tplrender" (dict "Values" . "context" $) | nindent 2 }}
2020
{{- end }}
2121

2222
{{- with .Values.args }}
@@ -46,11 +46,11 @@ Usage:
4646
{{- if not (kindIs "slice" .) }}
4747
{{ fail "ERROR: container.envFrom block must be a list!"}}
4848
{{- end }}
49-
{{- include "cf-common-0.1.1.tplrender" (dict "Values" . "context" $) | trim | nindent 4 }}
49+
{{- include "cf-common-0.1.2.tplrender" (dict "Values" . "context" $) | trim | nindent 4 }}
5050
{{- end }}
5151
{{- range $secretName, $_ := $.Values.secrets }}
5252
- secretRef:
53-
name: {{ printf "%s-%s" (include "cf-common-0.1.1.names.fullname" $) $secretName }}
53+
name: {{ printf "%s-%s" (include "cf-common-0.1.2.names.fullname" $) $secretName }}
5454
{{- end }}
5555
{{- end }}
5656

@@ -66,18 +66,18 @@ For backward compatibility (.Values.env takes precedence over .Values.container.
6666
{{- $mergedEnv = merge $mergedEnv $.Values.global.env }}
6767
{{- end }}
6868
env:
69-
{{- include "cf-common-0.1.1.env-vars" (dict "Values" $mergedEnv "context" $) | trim | nindent 2 }}
69+
{{- include "cf-common-0.1.2.env-vars" (dict "Values" $mergedEnv "context" $) | trim | nindent 2 }}
7070
{{- end }}
7171

72-
ports: {{- include "cf-common-0.1.1.ports" $ | trim | nindent 2 }}
72+
ports: {{- include "cf-common-0.1.2.ports" $ | trim | nindent 2 }}
7373

7474
{{- with .Values.volumeMounts }}
7575
volumeMounts:
76-
{{- include "cf-common-0.1.1.volumeMounts" (dict "Values" . "context" $) | trim | nindent 2 }}
76+
{{- include "cf-common-0.1.2.volumeMounts" (dict "Values" . "context" $) | trim | nindent 2 }}
7777
{{- end }}
7878

7979
{{- with .Values.probes }}
80-
{{- include "cf-common-0.1.1.probes" . | trim | nindent 2 }}
80+
{{- include "cf-common-0.1.2.probes" . | trim | nindent 2 }}
8181
{{- end }}
8282

8383
{{- with .Values.resources }}

charts/cf-common/templates/container/_env_vars.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ Create environment variables from the following structure:
88
secretKeyRef/configMapKeyRef/fieldRef
99
Accepts: env Dict
1010
*/}}
11-
{{- define "cf-common-0.1.1.env-vars"}}
11+
{{- define "cf-common-0.1.2.env-vars"}}
1212
{{- $ := .context }}
1313
{{- if .Values }}
1414
{{- if not (kindIs "map" .Values) }}
1515
{{ fail "ERROR: env block must be a map"}}
1616
{{- end }}
1717
{{- end }}
1818
{{- $env := .Values }}
19-
{{- $templatedEnv := include "cf-common-0.1.1.tplrender" (dict "Values" $env "context" $) | fromYaml }}
19+
{{- $templatedEnv := include "cf-common-0.1.2.tplrender" (dict "Values" $env "context" $) | fromYaml }}
2020
{{- range $name, $val := $templatedEnv }}
2121
{{- if or (kindIs "string" $val) (kindIs "bool" $val) (kindIs "int" $val) (kindIs "float64" $val) }}
2222
- name: {{ $name }}

0 commit comments

Comments
 (0)