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

chore: reformat chart templates #1439

Merged
merged 1 commit into from
Aug 19, 2023
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
37 changes: 18 additions & 19 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Expand the name of the chart.
*/}}
{{- define "trivy-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand All @@ -12,23 +12,23 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
as a full name.
*/}}
{{- define "trivy-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "trivy-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand Down Expand Up @@ -57,17 +57,16 @@ app.kubernetes.io/instance: {{ .Release.Name }}
Create the name of the service account to use.
*/}}
{{- define "trivy-operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "trivy-operator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- if .Values.serviceAccount.create }}
{{- default (include "trivy-operator.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the service account to use.
*/}}
{{- define "trivy-operator.namespace" -}}
{{- default .Release.Namespace .Values.operator.namespace }}
{{- default .Release.Namespace .Values.operator.namespace }}
{{- end }}

157 changes: 73 additions & 84 deletions deploy/helm/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: trivy-operator
namespace: {{ include "trivy-operator.namespace" . }}
labels:
{{- include "trivy-operator.labels" . | nindent 4 }}
labels: {{- include "trivy-operator.labels" . | nindent 4 }}
data:
{{- with .Values.trivyOperator.scanJobTolerations }}
scanJob.tolerations: {{ . | toJson | quote }}
Expand Down Expand Up @@ -58,31 +56,30 @@ data:
{{- if .Values.operator.clusterComplianceEnabled }}
compliance.failEntriesLimit: {{ required ".Values.compliance.failEntriesLimit is required" .Values.compliance.failEntriesLimit | quote }}
{{- end }}
{{- if .Values.trivyOperator.reportResourceLabels }}
report.resourceLabels: {{ .Values.trivyOperator.reportResourceLabels | quote }}
metrics.resourceLabelsPrefix: {{ .Values.trivyOperator.metricsResourceLabelsPrefix | quote }}
{{- with .Values.trivyOperator.reportResourceLabels }}
report.resourceLabels: {{ . | quote }}
metrics.resourceLabelsPrefix: {{ $.Values.trivyOperator.metricsResourceLabelsPrefix | quote }}
{{- end }}
{{- if .Values.trivyOperator.reportRecordFailedChecksOnly }}
report.recordFailedChecksOnly: {{ .Values.trivyOperator.reportRecordFailedChecksOnly | quote }}
{{- with .Values.trivyOperator.reportRecordFailedChecksOnly }}
report.recordFailedChecksOnly: {{ . | quote }}
{{- end }}
{{- if .Values.trivyOperator.skipResourceByLabels }}
skipResourceByLabels: {{ .Values.trivyOperator.skipResourceByLabels | quote }}
{{- with .Values.trivyOperator.skipResourceByLabels }}
skipResourceByLabels: {{ . | quote }}
{{- end }}
{{- if .Values.operator.builtInTrivyServer }}
trivy.serverURL: {{ printf "http://%s.%s:%s" .Values.trivy.serverServiceName (include "trivy-operator.namespace" .) "4954" | quote }}
{{- end }}
node.collector.imageRef: "{{ .Values.nodeCollector.registry }}/{{ .Values.nodeCollector.repository }}:{{ .Values.nodeCollector.tag }}"
{{- if .Values.nodeCollector.imagePullSecret }}
node.collector.imagePullSecret: "{{ .Values.nodeCollector.imagePullSecret }}"
{{- with .Values.nodeCollector.imagePullSecret }}
node.collector.imagePullSecret: "{{ . }}"
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: trivy-operator
namespace: {{ include "trivy-operator.namespace" . }}
labels:
{{- include "trivy-operator.labels" . | nindent 4 }}
labels: {{- include "trivy-operator.labels" . | nindent 4 }}
{{- if eq .Values.trivyOperator.vulnerabilityReportsPlugin "Trivy" }}
{{- if .Values.trivy.createConfig }}
---
Expand All @@ -91,29 +88,28 @@ kind: ConfigMap
metadata:
name: trivy-operator-trivy-config
namespace: {{ include "trivy-operator.namespace" $ }}
labels:
{{- include "trivy-operator.labels" $ | nindent 4 }}
labels: {{- include "trivy-operator.labels" $ | nindent 4 }}
data:
trivy.repository: "{{ required ".Values.trivy.image.registry is required" .Values.trivy.image.registry }}/{{ required ".Values.trivy.image.repository is required" .Values.trivy.image.repository }}"
trivy.tag: {{ required ".Values.trivy.image.tag is required" .Values.trivy.image.tag | quote }}
{{- if .Values.trivy.image.imagePullSecret }}
trivy.imagePullSecret: {{ .Values.trivy.image.imagePullSecret | quote }}
{{- with .Values.trivy.image.imagePullSecret }}
trivy.imagePullSecret: {{ . | quote }}
{{- end }}
trivy.additionalVulnerabilityReportFields: {{ .Values.trivy.additionalVulnerabilityReportFields | quote}}
{{- if .Values.trivy.httpProxy }}
trivy.httpProxy: {{ .Values.trivy.httpProxy | quote }}
{{- with .Values.trivy.httpProxy }}
trivy.httpProxy: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.httpsProxy }}
trivy.httpsProxy: {{ .Values.trivy.httpsProxy | quote }}
{{- with .Values.trivy.httpsProxy }}
trivy.httpsProxy: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.serverInsecure }}
trivy.serverInsecure: {{ .Values.trivy.serverInsecure | quote }}
{{- with .Values.trivy.serverInsecure }}
trivy.serverInsecure: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.sslCertDir }}
trivy.sslCertDir: {{ .Values.trivy.sslCertDir | quote }}
{{- with .Values.trivy.sslCertDir }}
trivy.sslCertDir: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.noProxy }}
trivy.noProxy: {{ .Values.trivy.noProxy | quote }}
{{- with .Values.trivy.noProxy }}
trivy.noProxy: {{ . | quote }}
{{- end }}
{{- range $key, $registry := .Values.trivy.nonSslRegistries }}
trivy.nonSslRegistry.{{ $key }}: {{ $registry | quote }}
Expand All @@ -129,38 +125,38 @@ data:
trivy.dbRepository: "{{ .Values.trivy.dbRegistry }}/{{ .Values.trivy.dbRepository }}"
trivy.javaDbRepository: "{{ .Values.trivy.javaDbRegistry }}/{{ .Values.trivy.javaDbRepository }}"
trivy.command: {{ .Values.trivy.command | quote }}
{{- if .Values.trivy.skipDirs }}
trivy.skipDirs: {{ .Values.trivy.skipDirs | quote }}
{{- with .Values.trivy.skipDirs }}
trivy.skipDirs: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.vulnType }}
trivy.vulnType: {{ .Values.trivy.vulnType | quote }}
{{- with .Values.trivy.vulnType }}
trivy.vulnType: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.dbRepositoryInsecure }}
trivy.dbRepositoryInsecure: {{ .Values.trivy.dbRepositoryInsecure | quote }}
{{- with .Values.trivy.dbRepositoryInsecure }}
trivy.dbRepositoryInsecure: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.useBuiltinRegoPolicies }}
trivy.useBuiltinRegoPolicies: {{ .Values.trivy.useBuiltinRegoPolicies | quote }}
{{- with .Values.trivy.useBuiltinRegoPolicies }}
trivy.useBuiltinRegoPolicies: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.offlineScan }}
trivy.offlineScan: {{ .Values.trivy.offlineScan | quote }}
{{- with .Values.trivy.offlineScan }}
trivy.offlineScan: {{ . | quote }}
{{- end }}
trivy.supportedConfigAuditKinds: {{ .Values.trivy.supportedConfigAuditKinds | quote }}
{{- if .Values.trivy.ignoreUnfixed }}
trivy.ignoreUnfixed: {{ .Values.trivy.ignoreUnfixed | quote }}
{{- with .Values.trivy.ignoreUnfixed }}
trivy.ignoreUnfixed: {{ . | quote }}
{{- end }}
{{- if .Values.trivy.timeout }}
trivy.timeout: {{ .Values.trivy.timeout | quote }}
{{- with .Values.trivy.timeout }}
trivy.timeout: {{ . | quote }}
{{- end }}
{{- with .Values.trivy.ignoreFile }}
trivy.ignoreFile: |
{{- . | trim | nindent 4 }}
{{- . | trim | nindent 4 }}
{{- end }}
{{- range $k, $v := .Values.trivy }}
{{- range $k, $v := .Values.trivy }}
{{- if hasPrefix "ignorePolicy" $k }}
trivy.{{- $k }}: |
{{- $v | trim | nindent 4 }}
{{- $v | trim | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.operator.builtInTrivyServer }}
trivy.serverURL: {{ printf "http://%s.%s:%s" .Values.trivy.serverServiceName (include "trivy-operator.namespace" .) "4954" | quote }}
trivy.mode: "ClientServer"
Expand All @@ -170,29 +166,23 @@ data:
trivy.serverURL: {{ required ".Values.trivy.serverURL is required" .Values.trivy.serverURL | quote }}
{{- end }}
{{- end }}
{{- with .Values.trivy.resources }}
{{- with .requests }}
{{- if .cpu }}
trivy.resources.requests.cpu: {{ .cpu | quote }}
{{- end }}
{{- if hasKey . "memory" }}
trivy.resources.requests.memory: {{ .memory | quote }}
{{- end }}
{{- if hasKey . "ephemeralStorage" }}
trivy.resources.requests.ephemeral-storage: {{ .ephemeralStorage | quote }}
{{- end }}
{{- end }}
{{- with .limits }}
{{- if .cpu }}
trivy.resources.limits.cpu: {{ .cpu | quote }}
{{- end }}
{{- if .memory }}
trivy.resources.limits.memory: {{ .memory | quote }}
{{- end }}
{{- if hasKey . "ephemeralStorage" }}
trivy.resources.limits.ephemeral-storage: {{ .ephemeralStorage | quote }}
{{- end }}
{{- end }}
{{- with dig "resources" "requests" "cpu" "" .Values.trivy }}
trivy.resources.requests.cpu: {{ . | quote }}
{{- end }}
{{- with dig "resources" "requests" "memory" "" .Values.trivy }}
trivy.resources.requests.memory: {{ . | quote }}
{{- end }}
{{- with dig "resources" "requests" "ephemeralStorage" "" .Values.trivy }}
trivy.resources.requests.ephemeral-storage: {{ . | quote }}
{{- end }}
{{- with dig "resources" "limits" "cpu" "" .Values.trivy }}
trivy.resources.limits.cpu: {{ . | quote }}
{{- end }}
{{- with dig "resources" "limits" "memory" "" .Values.trivy }}
trivy.resources.limits.memory: {{ . | quote }}
{{- end }}
{{- with dig "resources" "limits" "ephemeralStorage" "" .Values.trivy }}
trivy.resources.limits.ephemeral-storage: {{ . | quote }}
{{- end }}
{{- if .Values.operator.builtInTrivyServer }}
TRIVY_LISTEN: "0.0.0.0:4954"
Expand All @@ -203,35 +193,34 @@ data:
{{- end }}
{{- end }}
{{- end }}
---
{{- if not .Values.trivy.existingSecret }}
---
apiVersion: v1
kind: Secret
metadata:
name: trivy-operator-trivy-config
namespace: {{ include "trivy-operator.namespace" $ }}
labels:
{{- include "trivy-operator.labels" $ | nindent 4 }}
labels: {{- include "trivy-operator.labels" $ | nindent 4 }}
data:
{{- if .Values.trivy.githubToken }}
trivy.githubToken: {{ .Values.trivy.githubToken | b64enc | quote }}
{{- with .Values.trivy.githubToken }}
trivy.githubToken: {{ . | b64enc | quote }}
{{- end }}
{{- if or (eq .Values.trivy.mode "ClientServer") .Values.operator.builtInTrivyServer }}
{{- if .Values.trivy.serverToken }}
trivy.serverToken: {{ .Values.trivy.serverToken | b64enc | quote }}
{{- with .Values.trivy.serverToken }}
trivy.serverToken: {{ . | b64enc | quote }}
{{- end }}
{{- if .Values.trivy.serverCustomHeaders }}
trivy.serverCustomHeaders: {{ .Values.trivy.serverCustomHeaders | b64enc | quote }}
{{- with .Values.trivy.serverCustomHeaders }}
trivy.serverCustomHeaders: {{ . | b64enc | quote }}
{{- end }}
{{- end }}
{{- if .Values.operator.builtInTrivyServer }}
{{- if .Values.trivy.githubToken }}
GITHUB_TOKEN: {{ .Values.trivy.githubToken | b64enc | quote }}
{{- if .Values.operator.builtInTrivyServer }}
{{- with .Values.trivy.githubToken }}
GITHUB_TOKEN: {{ . | b64enc | quote }}
{{- end }}
{{- if .Values.trivy.serverToken }}
TRIVY_TOKEN: {{ .Values.trivy.serverToken | b64enc | quote }}
{{- with .Values.trivy.serverToken }}
TRIVY_TOKEN: {{ . | b64enc | quote }}
{{- end }}
TRIVY_USERNAME: {{ .Values.trivy.serverUser | b64enc | quote }}
TRIVY_PASSWORD: {{ .Values.trivy.serverPassword | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
Loading
Loading