Skip to content

Commit 59dcd5c

Browse files
feat(cf-common): merge .env with .container.env (#4)
* feat(cf-common): merge .env with .container.env * bump version * clean up
1 parent 60e6fba commit 59dcd5c

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ tests:
6060
path: spec.template.spec.containers[0].env[0].value
6161
value: BOB
6262

63+
# For backward compatibility
64+
- it: Test .Values.env precedence over .Values.container.env
65+
values:
66+
- values.yaml
67+
set:
68+
container:
69+
env:
70+
SERVICE_ROLE: all
71+
env:
72+
SERVICE_ROLE: internal
73+
asserts:
74+
- contains:
75+
path: spec.template.spec.containers[0].env
76+
content:
77+
name: SERVICE_ROLE
78+
value: internal
79+
6380
- it: Test main container TPL Env
6481
values:
6582
- 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.0.3
5+
version: 0.0.4
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.0.3](https://img.shields.io/badge/Version-0.0.3-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.0.4](https://img.shields.io/badge/Version-0.0.4-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.0.3
21+
version: 0.0.4
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,15 @@ Usage:
5555
{{- end }}
5656

5757
{{- with .Values.env }}
58-
env:
59-
{{- include "cf-common.env-vars" (dict "Values" . "context" $) | trim | nindent 2 }}
60-
{{- /* For backward compatibility */}}
58+
{{- /*
59+
For backward compatibility (.Values.env takes precedence over .Values.container.env)
60+
*/}}
61+
{{- $mergedEnv := . }}
6162
{{- if $.Values.env }}
62-
{{- include "cf-common.env-vars" (dict "Values" $.Values.env "context" $) | trim | nindent 2 }}
63+
{{- $mergedEnv = mergeOverwrite . $.Values.env }}
6364
{{- end }}
64-
{{- end }}
65-
66-
{{- with .Values.extraEnvVars }}
67-
{{- include "cf-common.tplrender" (dict "Values" . "context" $) | trim | nindent 2 }}
65+
env:
66+
{{- include "cf-common.env-vars" (dict "Values" $mergedEnv "context" $) | trim | nindent 2 }}
6867
{{- end }}
6968

7069
ports: {{- include "cf-common.ports" $ | trim | nindent 2 }}

0 commit comments

Comments
 (0)