Skip to content

Commit 364a48f

Browse files
authored
feat(controller): allow endpoint to be specified through secret (#28)
1 parent e2b2aaa commit 364a48f

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

charts/controller/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.2.0
18+
version: 0.2.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/controller/templates/_helpers.tpl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,27 @@ Expand the name of the default pod spec config map.
122122
{{- end }}
123123
{{- join " " $startupParameters }}
124124
{{- end }}
125+
126+
{{/*
127+
The name of the secret containing the endpoint URL.
128+
By default, this is the secret created by the chart.
129+
*/}}
130+
{{- define "controller.endpoint.secretName" -}}
131+
{{- if ne .Values.endpointSecret.name "" }}
132+
{{- .Values.endpointSecret.name }}
133+
{{- else }}
134+
{{- include "controller.fullname" . }}
135+
{{- end }}
136+
{{- end }}
137+
138+
{{/*
139+
The key of the secret containing the endpoint URL.
140+
By default, this is "endpoint".
141+
*/}}
142+
{{- define "controller.endpoint.secretKey" -}}
143+
{{- if ne .Values.endpointSecret.name "" }}
144+
{{- .Values.endpointSecret.key }}
145+
{{- else }}
146+
{{- "endpoint" }}
147+
{{- end }}
148+
{{- end }}

charts/controller/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ spec:
3333
- name: SEMAPHORE_ENDPOINT
3434
valueFrom:
3535
secretKeyRef:
36-
name: {{ include "controller.fullname" . }}
37-
key: endpoint
36+
name: {{ include "controller.endpoint.secretName" . }}
37+
key: {{ include "controller.endpoint.secretKey" . }}
3838
- name: SEMAPHORE_AGENT_IMAGE
3939
value: "{{ .Values.agent.image }}:{{ .Values.agent.version }}"
4040
- name: SEMAPHORE_AGENT_STARTUP_PARAMETERS

charts/controller/templates/secret.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{{- $endpoint := .Values.endpoint | required ".Values.endpoint is required." -}}
1+
{{- if and (eq .Values.endpointSecret.name "") (eq .Values.endpoint "") }}
2+
{{- fail "Either .Values.endpoint or .Values.endpointSecret.name must be set" }}
3+
{{- end }}
24

35
apiVersion: v1
46
kind: Secret
@@ -7,7 +9,9 @@ metadata:
79
labels:
810
{{- include "controller.labels" . | nindent 4 }}
911
stringData:
10-
endpoint: {{ $endpoint }}
12+
{{- if ne .Values.endpoint "" }}
13+
endpoint: {{ .Values.endpoint }}
14+
{{- end }}
1115
{{- if and .Values.agent.defaultPodSpec.preJobHook.enabled .Values.agent.defaultPodSpec.preJobHook.customScript }}
1216
pre-job-hook: |
1317
{{ .Values.agent.defaultPodSpec.preJobHook.customScript | b64dec | indent 4 }}

charts/controller/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
# The Semaphore endpoint used by the controller to look into the job queue.
66
# This is the only required value for this chart.
7+
# It can be specified as a raw value with .Values.endpoint,
8+
# or as a secret with .Values.endpointSecret.name and .Values.endpointSecret.key
79
endpoint: ""
10+
endpointSecret:
11+
name: ""
12+
key: "endpoint"
813

914
image: semaphoreci/controller
1015
imageTag: ""

0 commit comments

Comments
 (0)