|
| 1 | +{{/* |
| 2 | +Expand the name of the chart. |
| 3 | +*/}} |
| 4 | +{{- define "falcon-image-analyzer.name" -}} |
| 5 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 6 | +{{- end }} |
| 7 | + |
| 8 | +{{/* |
| 9 | +Create a default fully qualified app name. |
| 10 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 11 | +If release name contains chart name it will be used as a full name. |
| 12 | +*/}} |
| 13 | +{{- define "falcon-image-analyzer.fullname" -}} |
| 14 | +{{- if .Values.fullnameOverride }} |
| 15 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 16 | +{{- else }} |
| 17 | +{{- $name := default .Chart.Name .Values.nameOverride }} |
| 18 | +{{- if contains $name .Release.Name }} |
| 19 | +{{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 20 | +{{- else }} |
| 21 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 22 | +{{- end }} |
| 23 | +{{- end }} |
| 24 | +{{- end }} |
| 25 | + |
| 26 | +{{/* |
| 27 | +Create chart name and version as used by the chart label. |
| 28 | +*/}} |
| 29 | +{{- define "falcon-image-analyzer.chart" -}} |
| 30 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 31 | +{{- end }} |
| 32 | + |
| 33 | +{{/* |
| 34 | +Common labels |
| 35 | +*/}} |
| 36 | +{{- define "falcon-image-analyzer.labels" -}} |
| 37 | +helm.sh/chart: {{ include "falcon-image-analyzer.chart" . }} |
| 38 | +{{ include "falcon-image-analyzer.selectorLabels" . }} |
| 39 | +{{- if .Chart.AppVersion }} |
| 40 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 41 | +{{- end }} |
| 42 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 43 | +{{- end }} |
| 44 | + |
| 45 | +{{/* |
| 46 | +Selector labels |
| 47 | +*/}} |
| 48 | +{{- define "falcon-image-analyzer.selectorLabels" -}} |
| 49 | +app.kubernetes.io/name: {{ include "falcon-image-analyzer.name" . }} |
| 50 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 51 | +{{- end }} |
| 52 | + |
| 53 | +{{/* |
| 54 | +Create the name of the service account to use |
| 55 | +*/}} |
| 56 | +{{- define "falcon-image-analyzer.serviceAccountName" -}} |
| 57 | +{{- if .Values.serviceAccount.create }} |
| 58 | +{{- default (include "falcon-image-analyzer.fullname" .) .Values.serviceAccount.name }} |
| 59 | +{{- else }} |
| 60 | +{{- default "default" .Values.serviceAccount.name }} |
| 61 | +{{- end }} |
| 62 | +{{- end }} |
| 63 | + |
| 64 | +{{- define "falcon-image-analyzer.securityContext" -}} |
| 65 | +{{- if eq .Values.crowdstrikeConfig.agentRunmode "socket" -}} |
| 66 | +privileged: {{ .Values.securityContext.privileged | default true }} |
| 67 | +allowPrivilegeEscalation: {{ .Values.securityContext.allowPrivilegeEscalation | default true }} |
| 68 | +runAsUser: {{ .Values.securityContext.runAsUser | default 0 }} |
| 69 | +runAsGroup: {{ .Values.securityContext.runAsGroup | default 0 }} |
| 70 | +{{- end }} |
| 71 | +{{- end }} |
| 72 | + |
| 73 | +{{- define "falcon-image-analyzer.volumeMounts" -}} |
| 74 | +{{- if lt (len .Values.volumeMounts) 2 -}} |
| 75 | +{{- .Values.volumeMounts | toYaml }} |
| 76 | +{{- if eq .Values.crowdstrikeConfig.agentRunmode "socket" }} |
| 77 | +- name: var-run |
| 78 | + mountPath: {{ trimPrefix "unix://" (include "falcon-image-analyzer.agentRuntimeSocket" . ) }} |
| 79 | +{{- if eq .Values.crowdstrikeConfig.agentRuntime "crio" }} |
| 80 | +- name: storage |
| 81 | + mountPath: /run/containers/storage |
| 82 | +- name: containers |
| 83 | + mountPath: /var/lib/containers |
| 84 | +- name: fuse-overlay |
| 85 | + mountPath: /usr/bin/fuse-overlayfs |
| 86 | +- name: crio-conf |
| 87 | + mountPath: /etc/containers |
| 88 | +{{- end }} |
| 89 | +{{- end }} |
| 90 | +{{- else -}} |
| 91 | +{{- .Values.volumeMounts | toYaml }} |
| 92 | +{{- end }} |
| 93 | +{{- end }} |
| 94 | + |
| 95 | +{{- define "falcon-image-analyzer.volumes" -}} |
| 96 | +{{- if lt (len .Values.volumes) 2 -}} |
| 97 | +{{- .Values.volumes | toYaml }} |
| 98 | +{{- if eq .Values.crowdstrikeConfig.agentRunmode "socket" }} |
| 99 | +- name: var-run |
| 100 | + hostPath: |
| 101 | + path: {{ trimPrefix "unix://" (include "falcon-image-analyzer.agentRuntimeSocket" . ) }} |
| 102 | + type: Socket |
| 103 | +{{- if eq .Values.crowdstrikeConfig.agentRuntime "crio" }} |
| 104 | +- name: storage |
| 105 | + hostPath: |
| 106 | + path: /run/containers/storage |
| 107 | + type: Directory |
| 108 | +- name: containers |
| 109 | + hostPath: |
| 110 | + path: /var/lib/containers |
| 111 | + type: Directory |
| 112 | +- name: crio-conf |
| 113 | + hostPath: |
| 114 | + path: /etc/containers |
| 115 | + type: Directory |
| 116 | +- name: fuse-overlay |
| 117 | + hostPath: |
| 118 | + path: /usr/bin/fuse-overlayfs |
| 119 | + type: File |
| 120 | +{{- end }} |
| 121 | +{{- end }} |
| 122 | +{{- else -}} |
| 123 | +{{- .Values.volumes | toYaml }} |
| 124 | +{{- end }} |
| 125 | +{{- end }} |
| 126 | + |
| 127 | +{{- define "falcon-image-analyzer.agentRuntimeSocket" -}} |
| 128 | +{{- if eq .Values.crowdstrikeConfig.agentRunmode "socket" }} |
| 129 | +{{- if not .Values.crowdstrikeConfig.agentRuntimeSocket }} |
| 130 | +{{- if eq .Values.crowdstrikeConfig.agentRuntime "docker" }} |
| 131 | +{{- printf "%s" "unix:///run/docker.sock" }} |
| 132 | +{{- else if eq .Values.crowdstrikeConfig.agentRuntime "containerd" -}} |
| 133 | +{{- printf "%s" "unix:///run/containerd/containerd.sock" }} |
| 134 | +{{- else if eq .Values.crowdstrikeConfig.agentRuntime "crio" -}} |
| 135 | +{{- printf "%s" "unix:///run/crio/crio.sock" }} |
| 136 | +{{- else if eq .Values.crowdstrikeConfig.agentRuntime "podman" -}} |
| 137 | +{{- printf "%s" "unix:///run/podman/podman.sock" }} |
| 138 | +{{- end }} |
| 139 | +{{- else -}} |
| 140 | +{{- .Values.crowdstrikeConfig.agentRuntimeSocket }} |
| 141 | +{{- end }} |
| 142 | +{{- end }} |
| 143 | +{{- end }} |
| 144 | + |
| 145 | +{{- define "falcon-image-analyzer.imagePullSecret" }} |
| 146 | +{{- with .Values.crowdstrikeConfig }} |
| 147 | +{{- if eq .agentRegion "us-gov-1" }} |
| 148 | +{{- printf "{\"auths\":{\"registry.laggar.gcw.crowdstrike.com\":{\"username\":\"fc-%s\",\"password\":\"%s\",\"email\":\"image-assessment@crowdstrike.com\",\"auth\":\"%s\"}}}" (first (regexSplit "-" (lower .cid) -1)) .dockerAPIToken (printf "fc-%s:%s" (first (regexSplit "-" (lower .cid) -1)) .dockerAPIToken | b64enc) | b64enc }} |
| 149 | +{{- else if eq .agentRegion "us-gov-2" }} |
| 150 | +{{- printf "{\"auths\":{\"registry.us-gov-2.crowdstrike.mil\":{\"username\":\"fc-%s\",\"password\":\"%s\",\"email\":\"image-assessment@crowdstrike.com\",\"auth\":\"%s\"}}}" (first (regexSplit "-" (lower .cid) -1)) .dockerAPIToken (printf "fc-%s:%s" (first (regexSplit "-" (lower .cid) -1)) .dockerAPIToken | b64enc) | b64enc }} |
| 151 | +{{- else }} |
| 152 | +{{- printf "{\"auths\":{\"registry.crowdstrike.com\":{\"username\":\"fc-%s\",\"password\":\"%s\",\"email\":\"image-assessment@crowdstrike.com\",\"auth\":\"%s\"}}}" (first (regexSplit "-" (lower .cid) -1)) .dockerAPIToken (printf "fc-%s:%s" (first (regexSplit "-" (lower .cid) -1)) .dockerAPIToken | b64enc) | b64enc }} |
| 153 | +{{- end }} |
| 154 | +{{- end }} |
| 155 | +{{- end }} |
| 156 | + |
| 157 | +{{- define "falcon-image-analyzer.image" -}} |
| 158 | +{{- if .Values.image.digest -}} |
| 159 | +{{- if contains "sha256:" .Values.image.digest -}} |
| 160 | +{{- printf "%s@%s" .Values.image.repository .Values.image.digest -}} |
| 161 | +{{- else -}} |
| 162 | +{{- printf "%s@%s:%s" .Values.image.repository "sha256" .Values.image.digest -}} |
| 163 | +{{- end -}} |
| 164 | +{{- else -}} |
| 165 | +{{- printf "%s:%s" .Values.image.repository .Values.image.tag -}} |
| 166 | +{{- end -}} |
| 167 | +{{- end -}} |
0 commit comments