Skip to content

Commit

Permalink
Merge pull request #34 from port-labs/PORT-4960-ocean-helm-chart-supp…
Browse files Browse the repository at this point in the history
…ort-passing-config-through-env-vars

ocean replace config.yaml with env vars
  • Loading branch information
talsabagport authored Oct 16, 2023
2 parents f767ded + e9bcff8 commit 5f1670e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 38 deletions.
2 changes: 1 addition & 1 deletion charts/port-ocean/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: port-ocean
description: A Helm chart for Port Ocean integrations
type: application
version: 0.1.3
version: 0.1.4
appVersion: "0.1.0"
home: https://getport.io/
sources:
Expand Down
42 changes: 17 additions & 25 deletions charts/port-ocean/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,20 @@ kind: ConfigMap
metadata:
name: {{ include "port-ocean.configMapName" . }}
data:
config.yaml: |-
port:
clientId: "{{ printf "{{ from env PORT_CLIENT_ID }}" }}"
clientSecret: "{{ printf "{{ from env PORT_CLIENT_SECRET }}" }}"
baseUrl: {{ .Values.port.baseUrl | quote }}
initializePortResources: {{ .Values.initializePortResources | default false }}
scheduledResyncInterval: {{ .Values.scheduledResyncInterval }}
eventListener:
{{- range $key, $value := .Values.integration.eventListener }}
{{ $key }}: {{ $value | quote }}
{{- end}}
integration:
identifier: {{ .Values.integration.identifier }}
type: {{ .Values.integration.type }}
config:
{{- if .Values.integration.config -}}
{{- range $key, $value := .Values.integration.config }}
{{ $key }}: {{ $value | quote }}
{{- end -}}
{{- end -}}
{{- if .Values.integration.secrets -}}
{{- range $key, $value := .Values.integration.secrets }}
{{ $key }}: "{{ printf "{{ from env %s }}" $key }}"
{{- end -}}
{{- end -}}
OCEAN__PORT__BASE_URL: {{ .Values.port.baseUrl | quote }}
OCEAN__INITIALIZE_PORT_RESOURCES: "{{ .Values.initializePortResources | default false }}"
{{- if .Values.scheduledResyncInterval }}
OCEAN__SCHEDULED_RESYNC_INTERVAL: "{{ .Values.scheduledResyncInterval }}"
{{- end }}
OCEAN__EVENT_LISTENER: {{ .Values.integration.eventListener | toJson | quote }}
{{- if .Values.integration.identifier }}
OCEAN__INTEGRATION__IDENTIFIER: "{{ .Values.integration.identifier }}"
{{- end }}
{{- if .Values.integration.type }}
OCEAN__INTEGRATION__TYPE: "{{ .Values.integration.type }}"
{{- end }}
{{- if .Values.integration.config }}
{{- range $key, $value := .Values.integration.config }}
OCEAN__INTEGRATION__CONFIG__{{ $key | snakecase | upper }}: {{ $value | quote }}
{{- end }}
{{- end }}
10 changes: 2 additions & 8 deletions charts/port-ocean/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ spec:
- containerPort: {{.Values.service.port}}
protocol: TCP
{{- end }}
volumeMounts:
- name: config-volume
mountPath: "/app/config.yaml"
subPath: "config.yaml"
envFrom:
- configMapRef:
name: {{ include "port-ocean.configMapName" . }}
- secretRef:
name: {{ include "port-ocean.secretName" . }}
volumes:
- name: config-volume
configMap:
name: {{ include "port-ocean.configMapName" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
9 changes: 5 additions & 4 deletions charts/port-ocean/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ metadata:
labels:
{{- include "port-ocean.labels" $ | nindent 4 }}
type: opaque
data:
PORT_CLIENT_ID: {{ required "port.clientId is required" .Values.port.clientId | b64enc | quote }}
PORT_CLIENT_SECRET: {{ required "port.clientSecret is required" .Values.port.clientSecret | b64enc | quote }}
data:
OCEAN__PORT__CLIENT_ID: {{ required "port.clientId is required" .Values.port.clientId | b64enc | quote }}
OCEAN__PORT__CLIENT_SECRET: {{ required "port.clientSecret is required" .Values.port.clientSecret | b64enc | quote }}
{{- if .Values.integration.secrets }}
{{- range $key, $value := .Values.integration.secrets }}
{{ $key }}: {{ $value | b64enc | quote }}
OCEAN__INTEGRATION__CONFIG__{{ $key | snakecase | upper }}:
{{ if kindIs "map" $value }}{{ $value | toJson | b64enc | quote }}{{ else }}{{ $value | b64enc | quote }}{{ end }}
{{- end }}
{{- end }}

0 comments on commit 5f1670e

Please sign in to comment.