Skip to content

Commit

Permalink
chore: split helm chart template files (#1515)
Browse files Browse the repository at this point in the history
* chore: split helm chart template files

* chore: update trivy-operator static yaml

Signed-off-by: chenk <[email protected]>

* chore: update trivy-operator static yaml

Signed-off-by: chenk <[email protected]>

* chore: update trivy-operator static yaml

Signed-off-by: chenk <[email protected]>

* chore: update trivy-operator static yaml

Signed-off-by: chenk <[email protected]>

---------

Signed-off-by: chenk <[email protected]>
Co-authored-by: chenk <[email protected]>
  • Loading branch information
dnskr and chen-keinan authored Sep 18, 2023
1 parent 8eaef68 commit 4f3a75a
Show file tree
Hide file tree
Showing 23 changed files with 526 additions and 505 deletions.
76 changes: 76 additions & 0 deletions deploy/helm/templates/configmaps/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: trivy-operator
namespace: {{ include "trivy-operator.namespace" . }}
labels: {{- include "trivy-operator.labels" . | nindent 4 }}
data:
{{- with .Values.trivyOperator.scanJobTolerations }}
scanJob.tolerations: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.nodeCollector.volumes }}
nodeCollector.volumes: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.nodeCollector.volumeMounts }}
nodeCollector.volumeMounts: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobAnnotations }}
scanJob.annotations: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobAutomountServiceAccountToken }}
scanJob.automountServiceAccountToken: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.skipInitContainers }}
scanJob.skipInitContainers: {{ . | quote }}
{{- end }}
{{- with .Values.nodeCollector.excludeNodes }}
nodeCollector.excludeNodes: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodTemplateLabels }}
scanJob.podTemplateLabels: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.additionalReportLabels }}
report.additionalLabels: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobNodeSelector }}
scanJob.nodeSelector: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodTemplatePodSecurityContext }}
scanJob.podTemplatePodSecurityContext: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodTemplateContainerSecurityContext }}
scanJob.podTemplateContainerSecurityContext: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodPriorityClassName }}
scanJob.podPriorityClassName: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobCompressLogs }}
scanJob.compressLogs: {{ . | toJson | quote }}
{{- end }}
{{- if or .Values.operator.vulnerabilityScannerEnabled .Values.operator.exposedSecretScannerEnabled .Values.operator.scannerReportTTL }}
vulnerabilityReports.scanner: {{ .Values.trivyOperator.vulnerabilityReportsPlugin | quote }}
{{- end }}
{{- if .Values.operator.configAuditScannerEnabled }}
configAuditReports.scanner: {{ .Values.trivyOperator.configAuditReportsPlugin | quote }}
{{- end }}
{{- if .Values.operator.clusterComplianceEnabled }}
compliance.failEntriesLimit: {{ required ".Values.compliance.failEntriesLimit is required" .Values.compliance.failEntriesLimit | quote }}
{{- end }}
{{- with .Values.trivyOperator.reportResourceLabels }}
report.resourceLabels: {{ . | quote }}
metrics.resourceLabelsPrefix: {{ $.Values.trivyOperator.metricsResourceLabelsPrefix | quote }}
{{- end }}
{{- with .Values.trivyOperator.reportRecordFailedChecksOnly }}
report.recordFailedChecksOnly: {{ . | quote }}
{{- end }}
{{- 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 }}"
{{- with .Values.nodeCollector.imagePullSecret }}
node.collector.imagePullSecret: "{{ . }}"
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,87 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: trivy-operator
namespace: {{ include "trivy-operator.namespace" . }}
labels: {{- include "trivy-operator.labels" . | nindent 4 }}
data:
{{- with .Values.trivyOperator.scanJobTolerations }}
scanJob.tolerations: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.nodeCollector.volumes }}
nodeCollector.volumes: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.nodeCollector.volumeMounts }}
nodeCollector.volumeMounts: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobAnnotations }}
scanJob.annotations: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobAutomountServiceAccountToken }}
scanJob.automountServiceAccountToken: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.skipInitContainers }}
scanJob.skipInitContainers: {{ . | quote }}
{{- end }}
{{- with .Values.nodeCollector.excludeNodes }}
nodeCollector.excludeNodes: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodTemplateLabels }}
scanJob.podTemplateLabels: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.additionalReportLabels }}
report.additionalLabels: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobNodeSelector }}
scanJob.nodeSelector: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodTemplatePodSecurityContext }}
scanJob.podTemplatePodSecurityContext: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodTemplateContainerSecurityContext }}
scanJob.podTemplateContainerSecurityContext: {{ . | toJson | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobPodPriorityClassName }}
scanJob.podPriorityClassName: {{ . | quote }}
{{- end }}
{{- with .Values.trivyOperator.scanJobCompressLogs }}
scanJob.compressLogs: {{ . | toJson | quote }}
{{- end }}
{{- if or .Values.operator.vulnerabilityScannerEnabled .Values.operator.exposedSecretScannerEnabled .Values.operator.scannerReportTTL }}
vulnerabilityReports.scanner: {{ .Values.trivyOperator.vulnerabilityReportsPlugin | quote }}
{{- end }}
{{- if .Values.operator.configAuditScannerEnabled }}
configAuditReports.scanner: {{ .Values.trivyOperator.configAuditReportsPlugin | quote }}
{{- end }}
{{- if .Values.operator.clusterComplianceEnabled }}
compliance.failEntriesLimit: {{ required ".Values.compliance.failEntriesLimit is required" .Values.compliance.failEntriesLimit | quote }}
{{- end }}
{{- with .Values.trivyOperator.reportResourceLabels }}
report.resourceLabels: {{ . | quote }}
metrics.resourceLabelsPrefix: {{ $.Values.trivyOperator.metricsResourceLabelsPrefix | quote }}
{{- end }}
{{- with .Values.trivyOperator.reportRecordFailedChecksOnly }}
report.recordFailedChecksOnly: {{ . | quote }}
{{- end }}
{{- 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 }}"
{{- 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 }}
{{- if eq .Values.trivyOperator.vulnerabilityReportsPlugin "Trivy" }}
{{- if .Values.trivy.createConfig }}

---
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -197,34 +116,3 @@ 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 }}
data:
{{- with .Values.trivy.githubToken }}
trivy.githubToken: {{ . | b64enc | quote }}
{{- end }}
{{- if or (eq .Values.trivy.mode "ClientServer") .Values.operator.builtInTrivyServer }}
{{- with .Values.trivy.serverToken }}
trivy.serverToken: {{ . | b64enc | quote }}
{{- end }}
{{- with .Values.trivy.serverCustomHeaders }}
trivy.serverCustomHeaders: {{ . | b64enc | quote }}
{{- end }}
{{- end }}
{{- if .Values.operator.builtInTrivyServer }}
{{- with .Values.trivy.githubToken }}
GITHUB_TOKEN: {{ . | b64enc | quote }}
{{- end }}
{{- 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 }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
149 changes: 0 additions & 149 deletions deploy/helm/templates/rbac.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions deploy/helm/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.rbac.create }}
{{ .Files.Get "generated/role.yaml" }}

{{- if .Values.operator.accessGlobalSecretsAndServiceAccount -}}
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- get
- update
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions deploy/helm/templates/rbac/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "trivy-operator.fullname" . }}
labels: {{- include "trivy-operator.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: trivy-operator
subjects:
- kind: ServiceAccount
name: {{ include "trivy-operator.serviceAccountName" . }}
namespace: {{ include "trivy-operator.namespace" . }}
{{- end }}
Loading

0 comments on commit 4f3a75a

Please sign in to comment.