Skip to content

Commit b1d98cb

Browse files
feat(cf-common): add nameOverride suffix (#22)
* feat(cf-common): add nameOverride suffix
1 parent 55c9150 commit b1d98cb

File tree

7 files changed

+37
-27
lines changed

7 files changed

+37
-27
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.20
5+
version: 0.0.21
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.20](https://img.shields.io/badge/Version-0.0.20-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.21](https://img.shields.io/badge/Version-0.0.21-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.20
21+
version: 0.0.21
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -75,6 +75,7 @@ dependencies:
7575
| controller.job.suspend | string | `nil` | Suspend specifies whether the Job controller should create Pods or not. (boolean) |
7676
| controller.job.ttlSecondsAfterFinished | string | `nil` | Set the limit on the lifetime of a Job that has finished execution (either Complete or Failed). (int) |
7777
| controller.labels | object | `{}` | Set labels on controller |
78+
| controller.nameOverride | string | `""` | Override the name suffix that is used for this controller |
7879
| controller.replicas | string | `nil` | Set number of pods |
7980
| controller.revisionHistoryLimit | string | `nil` | Set ReplicaSet revision history limit |
8081
| controller.rollout.analysis.successfulRunHistoryLimit | string | `nil` | Limits the number of successful analysis runs and experiments to be stored in a history |

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

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ Usage:
88

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

11-
{{ include "cf-common.controller.type" . }}
11+
{{- $defaultControllerValues := deepCopy .Values.controller -}}
12+
{{- $globalControllerValues := dict -}}
13+
{{- if .Values.global -}}
14+
{{- if .Values.global.controller -}}
15+
{{- $globalControllerValues = deepCopy .Values.global.controller -}}
16+
{{- end -}}
17+
{{- end -}}
18+
{{- $mergedControllerValues := mergeOverwrite $globalControllerValues $defaultControllerValues -}}
19+
{{- $_ := set .Values "controller" (deepCopy $mergedControllerValues) -}}
1220

1321
{{- if eq .Values.controller.type "rollout" }}
1422
{{ include "cf-common.controller.rollout" . | nindent 0 }}
@@ -25,22 +33,3 @@ Usage:
2533
{{- end -}}
2634

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

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ Usage:
1212
{{- fail (printf "ERROR: %s is invalid Deployment strategy!" $strategy) -}}
1313
{{- end -}}
1414

15+
{{- $deploymentName := include "cf-common.names.fullname" . -}}
16+
{{- if and (hasKey .Values.controller "nameOverride") .Values.controller.nameOverride -}}
17+
{{- $deploymentName = printf "%v-%v" $deploymentName .Values.controller.nameOverride -}}
18+
{{- end -}}
19+
1520
---
1621
apiVersion: apps/v1
1722
kind: Deployment
1823
metadata:
19-
name: {{ include "cf-common.names.fullname" . }}
24+
name: {{ $deploymentName }}
2025
labels: {{ include "cf-common.labels.standard" . | nindent 4 }}
2126
{{- if .Values.controller.labels }}
2227
{{- include "cf-common.tplrender" (dict "Values" .Values.controller.labels "context" $) | nindent 4 }}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ Usage:
1212
{{- fail (printf "ERROR: %s is invalid Rollout strategy!" $strategy) -}}
1313
{{- end -}}
1414

15+
{{- $rolloutName := include "cf-common.names.fullname" . -}}
16+
{{- if and (hasKey .Values.controller "nameOverride") .Values.controller.nameOverride -}}
17+
{{- $rolloutName = printf "%v-%v" $rolloutName .Values.controller.nameOverride -}}
18+
{{- end -}}
19+
1520
---
1621
apiVersion: argoproj.io/v1alpha1
1722
kind: Rollout
1823
metadata:
19-
name: {{ include "cf-common.names.fullname" . }}
24+
name: {{ $rolloutName }}
2025
labels: {{ include "cf-common.labels.standard" . | nindent 4 }}
2126
{{- if .Values.controller.labels }}
2227
{{- include "cf-common.tplrender" (dict "Values" .Values.controller.labels "context" $) | nindent 4 }}
@@ -38,7 +43,7 @@ spec:
3843
strategy:
3944
{{- if eq $strategy "Canary" }}
4045
{{- with .Values.controller.rollout }}
41-
canary:
46+
canary:
4247
maxUnavailable: {{ .canary.maxUnavailable }}
4348
maxSurge: {{ .canary.maxSurge }}
4449
stableMetadata: {{ .canary.stableMetadata| toYaml | nindent 8 }}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ Usage:
88

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

11-
{{ include "cf-common.controller.type" . }}
11+
{{- $defaultControllerValues := deepCopy .Values.controller -}}
12+
{{- $globalControllerValues := dict -}}
13+
{{- if .Values.global -}}
14+
{{- if .Values.global.controller -}}
15+
{{- $globalControllerValues = deepCopy .Values.global.controller -}}
16+
{{- end -}}
17+
{{- end -}}
18+
{{- $mergedControllerValues := mergeOverwrite $globalControllerValues $defaultControllerValues -}}
19+
{{- $_ := set .Values "controller" (deepCopy $mergedControllerValues) -}}
1220

1321
apiVersion: autoscaling/v2beta2
1422
kind: HorizontalPodAutoscaler

charts/cf-common/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ controller:
8383
labels: {}
8484
# -- Set annotations on controller
8585
annotations: {}
86+
# -- Override the name suffix that is used for this controller
87+
nameOverride: ""
8688
# -- Set number of pods
8789
replicas:
8890
# -- Set ReplicaSet revision history limit

0 commit comments

Comments
 (0)