Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port definitions in values #116

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/common/templates/_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ports:
protocol: TCP
{{- else }}
{{- range .Values.ports }}
- name: {{ .name }}
- name: {{ .name | default (printf "tcp-%g" .containerPort) }}
containerPort: {{ .containerPort }}
protocol: TCP
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions charts/onechart/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ spec:
{{- end }}
{{- else }}
{{- range .Values.ports }}
- name: {{ .name }}
- name: {{ if .name }}{{ .name }}{{ else if .svcPort }}{{ printf "tcp-%g" .svcPort }}{{ else if .containerPort }}{{ printf "tcp-%g" .containerPort }}{{ end }}
port: {{ if .svcPort }}{{ .svcPort }}{{ else }}{{ .containerPort }}{{ end }}
{{- if .nodePort }}
nodePort: {{ .nodePort }}
{{- end }}
targetPort: {{ .name }}
targetPort: {{ .name | default (printf "tcp-%g" .containerPort) }}
protocol: TCP
{{- end }}
{{- end }}
Expand Down
13 changes: 13 additions & 0 deletions charts/onechart/tests/deployment_ports_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ tests:
- name: passive-2
containerPort: 3002
protocol: TCP
- it: Should set port definition if name is not set
set:
ports:
- containerPort: 21
asserts:
- template: deployment.yaml
documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports
value:
- name: tcp-21
containerPort: 21
protocol: TCP
- it: Should set default port
asserts:
- template: deployment.yaml
Expand Down
13 changes: 13 additions & 0 deletions charts/onechart/tests/service_ports_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ tests:
port: 3002
targetPort: passive-2
protocol: TCP
- it: Should set port definition if name is not set
set:
ports:
- svcPort: 445
containerPort: 21
asserts:
- equal:
path: spec.ports
value:
- name: tcp-445
port: 445
targetPort: tcp-21
protocol: TCP
- it: Should set default port
asserts:
- equal:
Expand Down
Loading