Skip to content

Commit

Permalink
Use monitoring.grafana.namespace value for namespace when creating gr…
Browse files Browse the repository at this point in the history
…afanadashboard or configmap resources for grafana

Signed-off-by: Vidar Anima Normann <1858786+vidarno@users.noreply.github.com>
  • Loading branch information
vidarno committed Nov 20, 2024
1 parent db77adc commit 42134ae
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions charts/policy-reporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end -}}
{{- end -}}

{{/* Get the namespace name for grafana. */}}
{{- define "grafana.namespace" -}}
{{- if .Values.monitoring.grafana.namespace -}}
{{- .Values.monitoring.grafana.namespace -}}
{{- else -}}
{{- include "policyreporter.namespace" . -}}
{{- end -}}
{{- end -}}

{{/* Get the namespace name. */}}
{{- define "policyreporter.logLevel" -}}
{{- if .Values.logging.server -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "monitoring.fullname" . }}-clusterpolicy-details-dashboard
namespace: {{ include "policyreporter.namespace" . }}
namespace: {{ include "grafana.namespace" . }}
annotations:
{{ $root.grafana.folder.annotation }}: {{ $root.grafana.folder.name }}
{{- with .Values.annotations }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{ .Values.monitoring.grafana.dashboards.label }}: {{ .Values.monitoring.grafana.dashboards.value | quote }}
{{- include "monitoring.labels" . | nindent 4 }}
name: {{ include "monitoring.fullname" . }}-clusterpolicy-details-dashboard
namespace: {{ include "policyreporter.namespace" . }}
namespace: {{ include "grafana.namespace" . }}
spec:
allowCrossNamespaceImport: {{ .Values.monitoring.grafana.grafanaDashboard.allowCrossNamespaceImport }}
folder: {{ .Values.monitoring.grafana.grafanaDashboard.folder }}
Expand All @@ -16,4 +16,4 @@ spec:
configMapRef:
name: {{ include "monitoring.fullname" . }}-clusterpolicy-details-dashboard
key: cluster-policy-reporter-details-dashboard.json
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "monitoring.fullname" . }}-overview-dashboard
namespace: {{ include "policyreporter.namespace" . }}
namespace: {{ include "grafana.namespace" . }}
annotations:
{{ $root.grafana.folder.annotation }}: {{ $root.grafana.folder.name }}
{{- with .Values.annotations }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{ .Values.monitoring.grafana.dashboards.label }}: {{ .Values.monitoring.grafana.dashboards.value | quote }}
{{- include "monitoring.labels" . | nindent 4 }}
name: {{ include "monitoring.fullname" . }}-overview-dashboard
namespace: {{ include "policyreporter.namespace" . }}
namespace: {{ include "grafana.namespace" . }}
spec:
allowCrossNamespaceImport: {{ .Values.monitoring.grafana.grafanaDashboard.allowCrossNamespaceImport }}
folder: {{ .Values.monitoring.grafana.grafanaDashboard.folder }}
Expand All @@ -16,4 +16,4 @@ spec:
configMapRef:
name: {{ include "monitoring.fullname" . }}-overview-dashboard
key: policy-reporter-dashboard.json
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "monitoring.fullname" . }}-policy-details-dashboard
namespace: {{ include "policyreporter.namespace" . }}
namespace: {{ include "grafana.namespace" . }}
annotations:
{{ $root.grafana.folder.annotation }}: {{ $root.grafana.folder.name }}
{{- with .Values.annotations }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{ .Values.monitoring.grafana.dashboards.label }}: {{ .Values.monitoring.grafana.dashboards.value | quote }}
{{- include "monitoring.labels" . | nindent 4 }}
name: {{ include "monitoring.fullname" . }}-policy-details-dashboard
namespace: {{ include "policyreporter.namespace" . }}
namespace: {{ include "grafana.namespace" . }}
spec:
allowCrossNamespaceImport: {{ .Values.monitoring.grafana.grafanaDashboard.allowCrossNamespaceImport }}
folder: {{ .Values.monitoring.grafana.grafanaDashboard.folder }}
Expand All @@ -16,4 +16,4 @@ spec:
configMapRef:
name: {{ include "monitoring.fullname" . }}-policy-details-dashboard
key: policy-reporter-details-dashboard.json
{{- end }}
{{- end }}

0 comments on commit 42134ae

Please sign in to comment.