Skip to content

Commit

Permalink
Trim suffix dash from port name in gcloud-sqlproxy (#108)
Browse files Browse the repository at this point in the history
When your instance name has '-' as 15th character, it caused invalid name to be generated
  • Loading branch information
sbienkow-ninja authored Jul 13, 2021
1 parent 8994506 commit 6b81d1e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion stable/gcloud-sqlproxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ maintainers:
name: gcloud-sqlproxy
sources:
- https://github.com/rimusz/charts
version: 0.20.5
version: 0.20.6
7 changes: 7 additions & 0 deletions stable/gcloud-sqlproxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Create the short instance name
*/}}
{{- define "gcloud-sqlproxy.instanceShortName" -}}
{{ .instanceShortName | default (.instance | trunc 15 | trimSuffix "-") }}
{{- end -}}
3 changes: 2 additions & 1 deletion stable/gcloud-sqlproxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ spec:
{{- end }}
ports:
{{- range .Values.cloudsql.instances }}
- name: {{ .instanceShortName | default (.instance | trunc 15) }}
{{- $instanceShortName := include "gcloud-sqlproxy.instanceShortName" . }}
- name: {{ $instanceShortName }}
containerPort: {{ .port }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
Expand Down
5 changes: 3 additions & 2 deletions stable/gcloud-sqlproxy/templates/svc-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ spec:
clusterIP: None
ports:
{{- range .Values.cloudsql.instances }}
- name: {{ .instanceShortName | default (.instance | trunc 15) }}
{{- $instanceShortName := include "gcloud-sqlproxy.instanceShortName" . }}
- name: {{ $instanceShortName }}
protocol: TCP
port: {{ .port }}
targetPort: {{ .instanceShortName | default (.instance | trunc 15) }}
targetPort: {{ $instanceShortName }}
{{- end }}
selector:
{{- include "gcloud-sqlproxy.selectorLabels" . | nindent 4 }}
Expand Down
5 changes: 3 additions & 2 deletions stable/gcloud-sqlproxy/templates/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ spec:
{{- end }}
ports:
{{- range .Values.cloudsql.instances }}
- name: {{ .instanceShortName | default (.instance | trunc 15) }}
{{- $instanceShortName := include "gcloud-sqlproxy.instanceShortName" . }}
- name: {{ $instanceShortName }}
protocol: TCP
port: {{ .port }}
targetPort: {{ .instanceShortName | default (.instance | trunc 15) }}
targetPort: {{ $instanceShortName }}
{{- end }}
selector:
{{- include "gcloud-sqlproxy.selectorLabels" . | nindent 4 }}

0 comments on commit 6b81d1e

Please sign in to comment.