Skip to content

Commit

Permalink
secrets are optional (#55)
Browse files Browse the repository at this point in the history
* secrets are optional

* [AUTO GITHUB] Bump chart versions

---------

Co-authored-by: dvdlevanon-miggo <[email protected]>
  • Loading branch information
dvdlevanon-miggo and dvdlevanon-miggo authored Dec 1, 2024
1 parent d2a77ae commit 562a6fc
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion charts/k8s-integration/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: k8s-integration
description: A Helm chart for miggo's k8s-integration
type: application
version: 0.0.8
version: 0.0.9
appVersion: "0.0.1"
dependencies:
- name: k8s-read
Expand Down
2 changes: 1 addition & 1 deletion charts/k8s-read/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: k8s-read
description: A Helm chart for miggo's k8s-read
type: application
version: 0.0.8
version: 0.0.9
appVersion: "0.0.1"
13 changes: 12 additions & 1 deletion charts/k8s-read/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ Create the name of the service account to use
{{- $emptyImagePullSecrets := list (dict "name" "") }}
{{- $global := .Values.global | default dict }}
{{- $globalImagePullSecrets := dig "imagePullSecrets" $emptyImagePullSecrets $global }}
{{- $globalImageCredentialsUsername := dig "imageCredentials" "username" "" $global }}
{{- $username := coalesce .Values.imageCredentials.username $globalImageCredentialsUsername }}
{{- if (not (empty (index .Values.imagePullSecrets 0).name)) }}
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 2 }}
{{- else if (not (empty (index $globalImagePullSecrets 0).name)) }}
imagePullSecrets:
{{- toYaml .Values.global.imagePullSecrets | nindent 2 }}
{{- else }}
{{- else if (not (empty $username)) }}
imagePullSecrets:
- name: k8s-read-miggo-regcred
{{- end }}
Expand All @@ -80,3 +82,12 @@ imagePullSecrets:
{{- define "k8s-read.configMapCacheName" -}}
{{- default (printf "%s-cache" (include "k8s-read.fullname" .)) .Values.config.cache.configMap.name }}
{{- end }}

{{- define "common.otlp.authHeader" -}}
{{- $global := .Values.global | default dict }}
{{- $globalOtlpHttpAuthHeader := dig "output" "otlp" "httpAuthHeader" "" $global }}
{{- $authHeader := coalesce .Values.output.otlp.httpAuthHeader $globalOtlpHttpAuthHeader "" }}
{{- if $authHeader }}
{{- $authHeader -}}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/k8s-read/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
{{- if .Values.output.otlp.existingSecret }}
- secretRef:
name: {{ .Values.output.otlp.existingSecret }}
{{- else }}
{{- else if (not (empty (include "common.otlp.authHeader" .))) }}
- secretRef:
name: k8s-read-otlp-secret
{{- end }}
Expand Down
9 changes: 3 additions & 6 deletions charts/k8s-read/templates/oltp-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{{- $global := .Values.global | default dict }}
{{- $globalOtlpHttpAuthHeader := dig "output" "otlp" "httpAuthHeader" "" $global }}
{{- $authHeader := coalesce .Values.output.otlp.httpAuthHeader $globalOtlpHttpAuthHeader }}
{{- if and (empty .Values.output.otlp.existingSecret) (not (empty $authHeader)) }}
{{- if and (empty .Values.output.otlp.existingSecret) (not (empty (include "common.otlp.authHeader" .))) }}
apiVersion: v1
kind: Secret
metadata:
name: k8s-read-otlp-secret
type: Opaque
data:
K8S_READ_OTLP_AUTH_HEADER: {{ $authHeader | b64enc | quote }}
K8S_READ_METRIC_OTLP_AUTH_HEADER: {{ $authHeader | b64enc | quote }}
K8S_READ_OTLP_AUTH_HEADER: {{ (include "common.otlp.authHeader" .) | b64enc | quote }}
K8S_READ_METRIC_OTLP_AUTH_HEADER: {{ (include "common.otlp.authHeader" .) | b64enc | quote }}
{{- end }}
---
2 changes: 1 addition & 1 deletion charts/static-sbom/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: static-sbom
description: A Helm chart for miggo's static-sbom
type: application
version: 0.0.11
version: 0.0.12
appVersion: "0.0.1"
13 changes: 12 additions & 1 deletion charts/static-sbom/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ Create the name of the service account to use
{{- $emptyImagePullSecrets := list (dict "name" "") }}
{{- $global := .Values.global | default dict }}
{{- $globalImagePullSecrets := dig "imagePullSecrets" $emptyImagePullSecrets $global }}
{{- $globalImageCredentialsUsername := dig "imageCredentials" "username" "" $global }}
{{- $username := coalesce .Values.imageCredentials.username $globalImageCredentialsUsername }}
{{- if (not (empty (index .Values.imagePullSecrets 0).name)) }}
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 2 }}
{{- else if (not (empty (index $globalImagePullSecrets 0).name)) }}
imagePullSecrets:
{{- toYaml .Values.global.imagePullSecrets | nindent 2 }}
{{- else }}
{{- else if (not (empty $username)) }}
imagePullSecrets:
- name: static-sbom-miggo-regcred
{{- end }}
Expand All @@ -80,3 +82,12 @@ imagePullSecrets:
{{- define "static-sbom.configMapCacheName" -}}
{{- default (printf "%s-cache" (include "static-sbom.fullname" .)) .Values.config.cache.configMap.name }}
{{- end }}

{{- define "common.otlp.authHeader" -}}
{{- $global := .Values.global | default dict }}
{{- $globalOtlpHttpAuthHeader := dig "output" "otlp" "httpAuthHeader" "" $global }}
{{- $authHeader := coalesce .Values.output.otlp.httpAuthHeader $globalOtlpHttpAuthHeader "" }}
{{- if $authHeader }}
{{- $authHeader -}}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/static-sbom/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ spec:
{{- if .Values.output.otlp.existingSecret }}
- secretRef:
name: {{ .Values.output.otlp.existingSecret }}
{{- else }}
{{- else if (not (empty (include "common.otlp.authHeader" .))) }}
- secretRef:
name: static-sbom-otlp-secret
{{- end }}
Expand Down
9 changes: 3 additions & 6 deletions charts/static-sbom/templates/oltp-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{{- $global := .Values.global | default dict }}
{{- $globalOtlpHttpAuthHeader := dig "output" "otlp" "httpAuthHeader" "" $global }}
{{- $authHeader := coalesce .Values.output.otlp.httpAuthHeader $globalOtlpHttpAuthHeader }}
{{- if and (empty .Values.output.otlp.existingSecret) (not (empty $authHeader)) }}
{{- if and (empty .Values.output.otlp.existingSecret) (not (empty (include "common.otlp.authHeader" .))) }}
apiVersion: v1
kind: Secret
metadata:
name: static-sbom-otlp-secret
type: Opaque
data:
STATIC_SBOM_OTLP_AUTH_HEADER: {{ $authHeader | b64enc | quote }}
STATIC_SBOM_METRIC_OTLP_AUTH_HEADER: {{ $authHeader | b64enc | quote }}
STATIC_SBOM_OTLP_AUTH_HEADER: {{ (include "common.otlp.authHeader" .) | b64enc | quote }}
STATIC_SBOM_METRIC_OTLP_AUTH_HEADER: {{ (include "common.otlp.authHeader" .) | b64enc | quote }}
{{- end }}
---

0 comments on commit 562a6fc

Please sign in to comment.