Skip to content

Commit f6b664b

Browse files
feat(cf-common): create controller-type tpl (#19)
1 parent 6e3eb2a commit f6b664b

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

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.17
5+
version: 0.0.18
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

Lines changed: 3 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.17](https://img.shields.io/badge/Version-0.0.17-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.18](https://img.shields.io/badge/Version-0.0.18-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.17
21+
version: 0.0.18
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -149,6 +149,7 @@ dependencies:
149149
| serviceAccount.annotations | object | `{}` | Set annotations for Service Account |
150150
| serviceAccount.enabled | bool | `false` | Enable and create Service Account |
151151
| serviceAccount.nameOverride | string | `""` | Override Service Account name (by default, name is generated with `fullname` template) |
152+
| terminationGracePeriodSeconds | string | `nil` | Duration in seconds the pod needs to terminate gracefully |
152153
| tolerations | list | `[]` | Set tolerations constrains |
153154
| topologySpreadConstraints | list | `[]` | Set topologySpreadConstraints rules. Helm template supported. Passed through `tpl`, should be configured as string |
154155
| volumes | object | See below | Configure volume for the controller. Additional items can be added by adding a dictionary key similar to the 'config'/`secret` key. |

charts/cf-common/templates/controller/_controller.tpl

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,42 @@
22
Renders contoller object
33
Usage:
44
{{- include "cf-common.controller" . -}}
5-
{{ .Values.controller | mustToPrettyJson | fail }}
65
*/}}
76

87
{{- define "cf-common.controller" -}}
98

109
{{- if .Values.controller.enabled -}}
1110

12-
{{- $controllerDict := .Values.controller -}}
13-
{{- if .Values.global -}}
14-
{{- if .Values.global.controller -}}
15-
{{- $controllerDict = merge $controllerDict .Values.global.controller -}}
16-
{{- end -}}
17-
{{- end -}}
18-
{{- $_ := set .Values "controller" $controllerDict -}}
11+
{{ include "cf-common.controller.type" . }}
1912

20-
{{- if eq $controllerDict.type "rollout" }}
13+
{{- if eq .Values.controller.type "rollout" }}
2114
{{ include "cf-common.controller.rollout" . | nindent 0 }}
22-
{{- else if eq $controllerDict.type "deployment" }}
15+
{{- else if eq .Values.controller.type "deployment" }}
2316
{{ include "cf-common.controller.deployment" . | nindent 0 }}
24-
{{- else if eq $controllerDict.type "job" }}
17+
{{- else if eq .Values.controller.type "job" }}
2518
{{ include "cf-common.controller.job" . | nindent 0 }}
2619
{{- else }}
2720
{{ fail (printf "ERROR: %s is invalid controller type!" .Values.controller.type) }}
2821
{{- end }}
2922
{{- end -}}
3023

3124
{{- end -}}
25+
26+
27+
{{- /*
28+
Define controller type. Merges .Values.controller (takes precedence) with .Values.global.controller
29+
Usage:
30+
{{ include "cf-common.controller.type" . }}
31+
*/}}
32+
33+
{{- define "cf-common.controller.type" }}
34+
35+
{{- $controllerDict := .Values.controller -}}
36+
{{- if .Values.global -}}
37+
{{- if .Values.global.controller -}}
38+
{{- $controllerDict = merge $controllerDict .Values.global.controller -}}
39+
{{- end -}}
40+
{{- end -}}
41+
{{- $_ := set .Values "controller" $controllerDict -}}
42+
43+
{{- end }}

charts/cf-common/templates/render/_hpa.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Usage:
88

99
{{- if .Values.hpa.enabled -}}
1010

11+
{{ include "cf-common.controller.type" . }}
12+
1113
apiVersion: autoscaling/v2beta2
1214
kind: HorizontalPodAutoscaler
1315
metadata:

charts/cf-common/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ podLabels: {}
129129
# -- Set additional pod annotations
130130
podAnnotations: {}
131131

132+
# -- Duration in seconds the pod needs to terminate gracefully
133+
terminationGracePeriodSeconds:
134+
132135
# -- Main Container parameters
133136
# @default -- See below
134137
container:

0 commit comments

Comments
 (0)