Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

secrets are optional #55

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
---