Skip to content

Commit

Permalink
fix(vector): Create ports for api from customConfig (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Gilbert <[email protected]>
  • Loading branch information
spencergilbert authored Sep 14, 2021
1 parent 47f9e2b commit b82c6b6
Showing 1 changed file with 43 additions and 30 deletions.
73 changes: 43 additions & 30 deletions charts/vector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,28 @@ Create the name of the service account to use
Generate an array of ServicePorts based on customConfig
*/}}
{{- define "vector.ports" -}}
{{- range $componentKind, $configs := .Values.customConfig }}
{{- if eq $componentKind "sources" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generatePort" -}}
{{- end }}
{{- end }}
{{- else if eq $componentKind "sinks" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generatePort" -}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- range $componentKind, $configs := .Values.customConfig }}
{{- if eq $componentKind "sources" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generatePort" -}}
{{- end }}
{{- end }}
{{- else if eq $componentKind "sinks" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generatePort" -}}
{{- end }}
{{- end }}
{{- else if eq $componentKind "api" }}
{{- if $configs.enabled }}
- name: api
port: {{ mustRegexFind "[0-9]+$" (get $configs "address") }}
protocol: TCP
targetPort: {{ mustRegexFind "[0-9]+$" (get $configs "address") }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Expand All @@ -106,21 +113,27 @@ Generate a single ServicePort based on a component configuration
Generate an array of ContainerPorts based on customConfig
*/}}
{{- define "vector.containerPorts" -}}
{{- range $componentKind, $configs := .Values.customConfig }}
{{- if eq $componentKind "sources" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generateContainerPort" -}}
{{- end }}
{{- end }}
{{- else if eq $componentKind "sinks" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generateContainerPort" -}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- range $componentKind, $configs := .Values.customConfig }}
{{- if eq $componentKind "sources" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generateContainerPort" -}}
{{- end }}
{{- end }}
{{- else if eq $componentKind "sinks" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if (hasKey $componentConfig "address") }}
{{- tuple $componentId $componentConfig | include "_helper.generateContainerPort" -}}
{{- end }}
{{- end }}
{{- else if eq $componentKind "api" }}
{{- if $configs.enabled }}
- name: api
containerPort: {{ mustRegexFind "[0-9]+$" (get $configs "address") }}
protocol: TCP
{{- end }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Expand Down

0 comments on commit b82c6b6

Please sign in to comment.