Skip to content

Commit f039ff8

Browse files
feat(cf-common): improve ingress tpl (#33)
1 parent 707ef94 commit f039ff8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+394
-300
lines changed

charts/cf-common-test/tests/ingress/error_test.yaml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,6 @@ suite: ingress error handler
33
templates:
44
- templates/ingress.yaml
55
tests:
6-
- it: Test no service name specified
7-
set:
8-
ingress:
9-
main:
10-
enabled: true
11-
hosts:
12-
- host: host.domain.local
13-
paths:
14-
- path: /path
15-
service:
16-
port: 80
17-
asserts:
18-
- failedTemplate:
19-
errorMessage: "service.name is required for ingress main!"
20-
21-
- it: Test no service port specified
22-
set:
23-
ingress:
24-
main:
25-
enabled: true
26-
hosts:
27-
- host: host.domain.local
28-
paths:
29-
- path: /path
30-
service:
31-
name: svc-test
32-
asserts:
33-
- failedTemplate:
34-
errorMessage: "service.port is required for ingress main!"
35-
366
- it: Test tls as invalid type
377
values:
388
- values.yaml

charts/cf-common-test/tests/ingress/metadata_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tests:
2222
helm.sh/chart: cf-common-test-0.0.0
2323
- equal:
2424
path: metadata.name
25-
value: RELEASE-NAME-cf-common-test-main
25+
value: RELEASE-NAME-cf-common-test
2626

2727
- it: Test Ingress custom metadata
2828
values:

charts/cf-common-test/tests/ingress/spec_test.yaml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,35 @@ tests:
1414
path: spec.rules[0].http.paths[0].path
1515
value: /path
1616

17-
- it: Test service and port
17+
- it: Test default (from service) service and port
1818
values:
1919
- values.yaml
2020
asserts:
2121
- equal:
2222
path: spec.rules[0].http.paths[0].backend.service.name
23-
value: svc-test
23+
value: RELEASE-NAME-cf-common-test
24+
- equal:
25+
path: spec.rules[0].http.paths[0].backend.service.port.number
26+
value: 80
27+
28+
- it: Test override service and port
29+
values:
30+
- values.yaml
31+
set:
32+
ingress:
33+
main:
34+
hosts:
35+
- host: host.domain.local
36+
paths:
37+
- path: /path
38+
pathType: ImplementationSpecific
39+
service:
40+
name: some-other-svc
41+
port: 8080
42+
asserts:
43+
- equal:
44+
path: spec.rules[0].http.paths[0].backend.service.name
45+
value: some-other-svc
2446
- equal:
2547
path: spec.rules[0].http.paths[0].backend.service.port.number
2648
value: 8080

charts/cf-common-test/tests/ingress/values.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ ingress:
1111
- path: /path
1212
pathType: ImplementationSpecific
1313
service:
14-
name: svc-test
15-
port: 8080
14+
port: 80
1615
tls: []
16+
17+
service:
18+
main:
19+
enabled: false
20+
type: ClusterIP
21+
ports:
22+
http:
23+
port: 80
24+
protocol: HTTP
25+
targetPort: 8080

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

charts/cf-common/README.md

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

33
Codefresh library chart
44

5-
![Version: 0.4.0](https://img.shields.io/badge/Version-0.4.0-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.5.0](https://img.shields.io/badge/Version-0.5.0-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.4.0
21+
version: 0.5.0
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
@@ -117,8 +117,8 @@ dependencies:
117117
| ingress.main.hosts[0].host | string | `"domain.example.com"` | Host address. Helm template can be passed. |
118118
| ingress.main.hosts[0].paths[0].path | string | `"/"` | Path. Helm template can be passed. |
119119
| ingress.main.hosts[0].paths[0].pathType | string | `nil` | Path Type (`Prefix`/`ImplementationSpecific`(default)/`Exact`) |
120-
| ingress.main.hosts[0].paths[0].service.name | string | `nil` | Set the service name reference for this path. Helm template can be passed. |
121-
| ingress.main.hosts[0].paths[0].service.port | string | `nil` | Set the service port reference for this path. Helm template can be passed. |
120+
| ingress.main.hosts[0].paths[0].service.name | string | `nil` | Overrides the service name reference for this path. Helm template can be passed. |
121+
| ingress.main.hosts[0].paths[0].service.port | string | `nil` | Overrides the service port reference for this path. Helm template can be passed. |
122122
| ingress.main.ingressClassName | string | `nil` | Set the ingressClass that is used for the ingress. |
123123
| ingress.main.labels | object | `{}` | Add additional labels for ingress. |
124124
| ingress.main.tls | list | `[]` | Configure TLS for the ingress. Both secretName and hosts can process a Helm template. |

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Calculate RabbitMQ URI (for On-Prem)
33
Must me called from chart root context.
44
Usage:
5-
{{ include "cf-common-0.4.0.classic.calculateRabbitMqUri" . }}
5+
{{ include "cf-common-0.5.0.classic.calculateRabbitMqUri" . }}
66
*/}}
77

8-
{{- define "cf-common-0.4.0.classic.calculateRabbitMqUri" }}
8+
{{- define "cf-common-0.5.0.classic.calculateRabbitMqUri" }}
99

1010
{{- $rabbitmqProtocol := .Values.global.rabbitmqProtocol | default "amqp" -}}
1111
{{- $rabbitmqUsername := .Values.global.rabbitmqUsername -}}
@@ -23,9 +23,9 @@ coalesce here for backward compatibility
2323
{{/*
2424
Calculate Mongo Uri (for On-Prem)
2525
Usage:
26-
{{ include "cf.common-0.4.0.classic.calculateMongoUri" (dict "dbName" $.Values.global.pipelineManagerService "mongoURI" $.Values.global.mongoURI) }}
26+
{{ include "cf.common-0.5.0.classic.calculateMongoUri" (dict "dbName" $.Values.global.pipelineManagerService "mongoURI" $.Values.global.mongoURI) }}
2727
*/}}
28-
{{- define "cf-common-0.4.0.classic.calculateMongoUri" -}}
28+
{{- define "cf-common-0.5.0.classic.calculateMongoUri" -}}
2929
{{- if contains "?" .mongoURI -}}
3030
{{- $mongoURI := (splitList "?" .mongoURI) -}}
3131
{{- printf "%s%s?%s" (first $mongoURI) .dbName (last $mongoURI) }}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
Render checksum annotation
33
Must be called from chart root context.
44
Usage:
5-
annotations: {{ include "cf-common-0.4.0.annotations.podAnnotations" . | nindent }}
5+
annotations: {{ include "cf-common-0.5.0.annotations.podAnnotations" . | nindent }}
66
*/}}
7-
{{- define "cf-common-0.4.0.annotations.podAnnotations" -}}
7+
{{- define "cf-common-0.5.0.annotations.podAnnotations" -}}
88

99
{{- if .Values.podAnnotations -}}
10-
{{- include "cf-common-0.4.0.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 0 }}
10+
{{- include "cf-common-0.5.0.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 0 }}
1111
{{- end -}}
1212

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

1616
{{- if $configMapItem.enabled -}}
17-
{{- $_ := set $configMapFound $configMapIndex ( include "cf-common-0.4.0.tplrender" (dict "Values" $configMapItem.data "context" $) | sha256sum) -}}
17+
{{- $_ := set $configMapFound $configMapIndex ( include "cf-common-0.5.0.tplrender" (dict "Values" $configMapItem.data "context" $) | sha256sum) -}}
1818
{{- end -}}
1919

2020
{{- if $configMapFound -}}
@@ -27,7 +27,7 @@ annotations: {{ include "cf-common-0.4.0.annotations.podAnnotations" . | nindent
2727
{{- range $secretIndex, $secretItem := .Values.secrets -}}
2828

2929
{{- if $secretItem.enabled -}}
30-
{{- $_ := set $secretFound $secretIndex ( include "cf-common-0.4.0.tplrender" (dict "Values" $secretItem.stringData "context" $) | sha256sum) -}}
30+
{{- $_ := set $secretFound $secretIndex ( include "cf-common-0.5.0.tplrender" (dict "Values" $secretItem.stringData "context" $) | sha256sum) -}}
3131
{{- end -}}
3232

3333
{{- 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.4.0.labels.standard" -}}
5-
app.kubernetes.io/name: {{ include "cf-common-0.4.0.names.name" . }}
6-
helm.sh/chart: {{ include "cf-common-0.4.0.names.chart" . }}
4+
{{- define "cf-common-0.5.0.labels.standard" -}}
5+
app.kubernetes.io/name: {{ include "cf-common-0.5.0.names.name" . }}
6+
helm.sh/chart: {{ include "cf-common-0.5.0.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.4.0.labels.matchLabels" -}}
15-
app.kubernetes.io/name: {{ include "cf-common-0.4.0.names.name" . }}
14+
{{- define "cf-common-0.5.0.labels.matchLabels" -}}
15+
app.kubernetes.io/name: {{ include "cf-common-0.5.0.names.name" . }}
1616
app.kubernetes.io/instance: {{ .Release.Name }}
1717
{{- end -}}
1818

1919

2020
{{/*
2121
Extra labels
2222
Usage:
23-
{{ include "cf-common-0.4.0.labels.extraLabels" ( dict "Values" .Values.path.to.the.labels "context" $) }}
23+
{{ include "cf-common-0.5.0.labels.extraLabels" ( dict "Values" .Values.path.to.the.labels "context" $) }}
2424
*/}}
25-
{{- define "cf-common-0.4.0.labels.extraLabels" -}}
25+
{{- define "cf-common-0.5.0.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.4.0.annotations" ( dict "Values" .Values.path.to.the.annotations "context" $) }}
37+
{{ include "cf-common-0.5.0.annotations" ( dict "Values" .Values.path.to.the.annotations "context" $) }}
3838
*/}}
39-
{{- define "cf-common-0.4.0.annotations" -}}
39+
{{- define "cf-common-0.5.0.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.4.0.names.name" -}}
4+
{{- define "cf-common-0.5.0.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.4.0.names.chart" -}}
11+
{{- define "cf-common-0.5.0.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.4.0.names.fullname" -}}
20+
{{- define "cf-common-0.5.0.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.4.0.names.serviceAccountName" -}}
36+
{{- define "cf-common-0.5.0.names.serviceAccountName" -}}
3737
{{- if .Values.serviceAccount -}}
3838
{{- if .Values.serviceAccount.enabled -}}
39-
{{- .Values.serviceAccount.nameOverride | default (include "cf-common-0.4.0.names.fullname" .) -}}
39+
{{- .Values.serviceAccount.nameOverride | default (include "cf-common-0.5.0.names.fullname" .) -}}
4040
{{- else -}}
4141
{{- print "default" -}}
4242
{{- end -}}

0 commit comments

Comments
 (0)