Skip to content

Commit

Permalink
Merge pull request #217 from devtron-labs/clair-global-image-expose
Browse files Browse the repository at this point in the history
chore: added support for  global container registry in clair helm chart
  • Loading branch information
prakarsh-dt authored Apr 15, 2024
2 parents cc89ffa + c69a267 commit 4bf89fd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/clair/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ maintainers:
name: clair
sources:
- https://github.com/coreos/clair
version: 0.1.10
version: 0.1.11
32 changes: 26 additions & 6 deletions charts/clair/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,30 @@ If release name contains chart name it will be used as a full name.
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified postgresql name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "postgresql.fullname" -}}
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}}
{{- define "common.clair.image" -}}
{{- $registryName := .component.registry | default .global.containerRegistry -}}
{{- $imageName := .extraImage | default .component.repository -}}
{{- $imageTag := .extraImageTag | default .component.tag -}}
{{- $imageDigest := .extraImageDigest | default .component.digest -}}
{{- if $registryName }}
{{- if and $imageTag $imageDigest }}
{{- printf "%s/%s@%s" $registryName $imageName $imageDigest -}}
{{- else if $imageTag }}
{{- printf "%s/%s:%s" $registryName $imageName $imageTag -}}
{{- else if $imageDigest }}
{{- printf "%s/%s@%s" $registryName $imageName $imageDigest -}}
{{- else }}
{{- printf "%s/%s" $registryName $imageName -}}
{{- end }}
{{- else -}}
{{- if and $imageTag $imageDigest }}
{{- printf "%s@%s" $imageName $imageDigest -}}
{{- else if $imageTag }}
{{- printf "%s:%s" $imageName $imageTag -}}
{{- else if $imageDigest }}
{{- printf "%s@%s" $imageName $imageDigest -}}
{{- else }}
{{- printf "%s" $imageName -}}
{{- end }}
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/clair/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ spec:
{{- end }}
initContainers:
- name: pg-ready-wait
image: postgres:11.3
image: {{ include "common.clair.image" (dict "component" $.Values.image "global" $.Values.global "extraImage" $.Values.image.initContainer.image "extraImageTag" $.Values.image.initContainer.tag ) }}
command: [ "sh", "-c",
"until pg_isready -h {{ .Values.config.postgresHost }} -p {{ .Values.config.postgresPort }};
do echo waiting for database; sleep 1; done;"]
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
image: {{ include "common.clair.image" (dict "component" $.Values.image "global" $.Values.global ) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.extraEnv }}
env: {{ toYaml .Values.extraEnv | nindent 8 }}
Expand Down
8 changes: 7 additions & 1 deletion charts/clair/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
global:
containerRegistry: "quay.io/devtron"

config:
postgresHost: postgresql-postgresql.devtroncd
postgresPort: 5432
Expand Down Expand Up @@ -34,8 +37,11 @@ config:
extraConfig: {}
image:
pullPolicy: IfNotPresent
repository: quay.io/projectquay/clair
repository: clair
tag: 4.3.6
initContainer:
image: postgres
tag: "11.3"
ingress:
annotations: null
enabled: false
Expand Down

0 comments on commit 4bf89fd

Please sign in to comment.