Skip to content

Commit

Permalink
feat(cf-common): add image digest (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-klimko authored Oct 30, 2024
1 parent 448774f commit 7854b58
Show file tree
Hide file tree
Showing 47 changed files with 342 additions and 318 deletions.
14 changes: 13 additions & 1 deletion charts/cf-common-test/tests/deployment/container_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,16 @@ tests:
valueFrom:
secretKeyRef:
name: some-secret-one
key: some-key-one
key: some-key-one

- it: Test main container with image digest
values:
- values.yaml
set:
container:
image:
digest: sha256:1234567890
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: 839151377425.dkr.ecr.us-east-1.amazonaws.com/codefresh-inc/codefresh/cf-api:master@sha256:1234567890
2 changes: 1 addition & 1 deletion charts/cf-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: v0.0.0
description: Codefresh library chart
name: cf-common
version: 0.20.1
version: 0.21.0
type: library
keywords:
- codefresh
Expand Down
7 changes: 4 additions & 3 deletions charts/cf-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Codefresh library chart

![Version: 0.20.1](https://img.shields.io/badge/Version-0.20.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
![Version: 0.21.0](https://img.shields.io/badge/Version-0.21.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)

## Installing the Chart

Expand All @@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml
dependencies:
- name: cf-common
version: 0.20.1
version: 0.21.0
repository: https://chartmuseum.codefresh.io/cf-common
```
Expand All @@ -45,7 +45,8 @@ dependencies:
| container.containerSecurityContext | object | `{}` | Set security context for container |
| container.env | object | `{}` | Set environments variables. Helm template supported. |
| container.envFrom | list | `[]` | Set Secrets or ConfigMaps loaded as environment variables. |
| container.image | object | `{"pullPolicy":null,"registry":null,"repository":null,"tag":null}` | Image parameters |
| container.image | object | `{"digest":null,"pullPolicy":null,"registry":null,"repository":null,"tag":null}` | Image parameters |
| container.image.digest | string | `nil` | Set image digest |
| container.image.pullPolicy | string | `nil` | Set image pull policy (`Always`, `Never`, `IfNotPresent`) |
| container.image.registry | string | `nil` | Set image registry |
| container.image.repository | string | `nil` | Set image repository |
Expand Down
82 changes: 41 additions & 41 deletions charts/cf-common/templates/classic/_env_var_secret_ref.tpl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{{- /*
MONGODB_HOST env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.mongodb-host-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.mongodb-host-env-var-secret-name" }}
{{- if or .Values.mongodbHostSecretKeyRef .Values.global.mongodbHostSecretKeyRef }}
{{- printf (coalesce .Values.mongodbHostSecretKeyRef.name .Values.global.mongodbHostSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
MONGODB_HOST env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.mongodb-host-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.mongodb-host-env-var-secret-key" }}
{{- if or .Values.mongodbHostSecretKeyRef .Values.global.mongodbHostSecretKeyRef }}
{{- printf (coalesce .Values.mongodbHostSecretKeyRef.key .Values.global.mongodbHostSecretKeyRef.key) }}
{{- else }}
Expand All @@ -23,18 +23,18 @@ MONGODB_HOST env var secret key
{{- /*
MONGODB_USER env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.mongodb-user-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.mongodb-user-env-var-secret-name" }}
{{- if or .Values.mongodbUserSecretKeyRef .Values.global.mongodbUserSecretKeyRef }}
{{- printf (coalesce .Values.mongodbUserSecretKeyRef.name .Values.global.mongodbUserSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
MONGODB_USER env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.mongodb-user-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.mongodb-user-env-var-secret-key" }}
{{- if or .Values.mongodbUserSecretKeyRef .Values.global.mongodbUserSecretKeyRef }}
{{- printf (coalesce .Values.mongodbUserSecretKeyRef.key .Values.global.mongodbUserSecretKeyRef.key) }}
{{- else }}
Expand All @@ -45,18 +45,18 @@ MONGODB_USER env var secret key
{{- /*
MONGODB_PASSWORD env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.mongodb-password-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.mongodb-password-env-var-secret-name" }}
{{- if or .Values.mongodbPasswordSecretKeyRef .Values.global.mongodbPasswordSecretKeyRef }}
{{- printf (coalesce .Values.mongodbPasswordSecretKeyRef.name .Values.global.mongodbPasswordSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
MONGODB_PASSWORD env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.mongodb-password-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.mongodb-password-env-var-secret-key" }}
{{- if or .Values.mongodbPasswordSecretKeyRef .Values.global.mongodbPasswordSecretKeyRef }}
{{- printf (coalesce .Values.mongodbPasswordSecretKeyRef.key .Values.global.mongodbPasswordSecretKeyRef.key) }}
{{- else }}
Expand All @@ -67,7 +67,7 @@ MONGODB_PASSWORD env var secret key
{{- /*
MONGO_URI env var value
*/}}
{{- define "cf-common-0.20.1.classic.mongo-uri-env-var-value" }}
{{- define "cf-common-0.21.0.classic.mongo-uri-env-var-value" }}
{{- /*
Check for legacy global.mongoURI
*/}}
Expand All @@ -84,7 +84,7 @@ New secret implementation
{{- /*
MONGO_URI_ARCHIVE env var value
*/}}
{{- define "cf-common-0.20.1.classic.mongo-uri-archive-env-var-value" }}
{{- define "cf-common-0.21.0.classic.mongo-uri-archive-env-var-value" }}
{{- /*
Check for legacy global.mongoURIArchive or global.mongoURI
*/}}
Expand All @@ -102,18 +102,18 @@ New secret implementation
{{- /*
REDIS_URL env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.redis-url-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.redis-url-env-var-secret-name" }}
{{- if or .Values.redisUrlSecretKeyRef .Values.global.redisUrlSecretKeyRef }}
{{- printf (coalesce .Values.redisUrlSecretKeyRef.name .Values.global.redisUrlSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
REDIS_URL env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.redis-url-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.redis-url-env-var-secret-key" }}
{{- if or .Values.redisUrlSecretKeyRef .Values.global.redisUrlSecretKeyRef }}
{{- printf (coalesce .Values.redisUrlSecretKeyRef.key .Values.global.redisUrlSecretKeyRef.key) }}
{{- else }}
Expand All @@ -124,18 +124,18 @@ REDIS_URL env var secret key
{{- /*
REDIS_PASSWORD env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.redis-password-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.redis-password-env-var-secret-name" }}
{{- if or .Values.redisPasswordSecretKeyRef .Values.global.redisPasswordSecretKeyRef }}
{{- printf (coalesce .Values.redisPasswordSecretKeyRef.name .Values.global.redisPasswordSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
REDIS_PASSWORD env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.redis-password-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.redis-password-env-var-secret-key" }}
{{- if or .Values.redisPasswordSecretKeyRef .Values.global.redisPasswordSecretKeyRef }}
{{- printf (coalesce .Values.redisPasswordSecretKeyRef.key .Values.global.redisPasswordSecretKeyRef.key) }}
{{- else }}
Expand All @@ -146,18 +146,18 @@ REDIS_PASSWORD env var secret key
{{- /*
POSTGRES_HOSTNAME env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.postgres-hostname-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.postgres-hostname-env-var-secret-name" }}
{{- if or .Values.postgresHostnameSecretKeyRef .Values.global.postgresHostnameSecretKeyRef }}
{{- printf (coalesce .Values.postgresHostnameSecretKeyRef.name .Values.global.postgresHostnameSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
POSTGRES_HOSTNAME env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.postgres-hostname-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.postgres-hostname-env-var-secret-key" }}
{{- if or .Values.postgresHostnameSecretKeyRef .Values.global.postgresHostnameSecretKeyRef }}
{{- printf (coalesce .Values.postgresHostnameSecretKeyRef.key .Values.global.postgresHostnameSecretKeyRef.key) }}
{{- else }}
Expand All @@ -168,18 +168,18 @@ POSTGRES_HOSTNAME env var secret key
{{- /*
POSTGRES_PASSWORD env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.postgres-password-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.postgres-password-env-var-secret-name" }}
{{- if or .Values.postgresPasswordSecretKeyRef .Values.global.postgresPasswordSecretKeyRef }}
{{- printf (coalesce .Values.postgresPasswordSecretKeyRef.name .Values.global.postgresPasswordSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
POSTGRES_PASSWORD env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.postgres-password-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.postgres-password-env-var-secret-key" }}
{{- if or .Values.postgresPasswordSecretKeyRef .Values.global.postgresPasswordSecretKeyRef }}
{{- printf (coalesce .Values.postgresPasswordSecretKeyRef.key .Values.global.postgresPasswordSecretKeyRef.key) }}
{{- else }}
Expand All @@ -190,18 +190,18 @@ POSTGRES_PASSWORD env var secret key
{{- /*
POSTGRES_USER env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.postgres-user-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.postgres-user-env-var-secret-name" }}
{{- if or .Values.postgresUserSecretKeyRef .Values.global.postgresUserSecretKeyRef }}
{{- printf (coalesce .Values.postgresUserSecretKeyRef.name .Values.global.postgresUserSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
POSTGRES_USER env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.postgres-user-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.postgres-user-env-var-secret-key" }}
{{- if or .Values.postgresUserSecretKeyRef .Values.global.postgresUserSecretKeyRef }}
{{- printf (coalesce .Values.postgresUserSecretKeyRef.key .Values.global.postgresUserSecretKeyRef.key) }}
{{- else }}
Expand All @@ -212,18 +212,18 @@ POSTGRES_USER env var secret key
{{- /*
RABBITMQ_HOSTNAME env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.rabbitmq-hostname-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.rabbitmq-hostname-env-var-secret-name" }}
{{- if or .Values.rabbitmqHostnameSecretKeyRef .Values.global.rabbitmqHostnameSecretKeyRef }}
{{- printf (coalesce .Values.rabbitmqHostnameSecretKeyRef.name .Values.global.rabbitmqHostnameSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
RABBITMQ_HOSTNAME env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.rabbitmq-hostname-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.rabbitmq-hostname-env-var-secret-key" }}
{{- if or .Values.rabbitmqHostnameSecretKeyRef .Values.global.rabbitmqHostnameSecretKeyRef }}
{{- printf (coalesce .Values.rabbitmqHostnameSecretKeyRef.key .Values.global.rabbitmqHostnameSecretKeyRef.key) }}
{{- else }}
Expand All @@ -234,18 +234,18 @@ RABBITMQ_HOSTNAME env var secret key
{{- /*
RABBITMQ_PASSWORD env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.rabbitmq-password-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.rabbitmq-password-env-var-secret-name" }}
{{- if or .Values.rabbitmqPasswordSecretKeyRef .Values.global.rabbitmqPasswordSecretKeyRef }}
{{- printf (coalesce .Values.rabbitmqPasswordSecretKeyRef.name .Values.global.rabbitmqPasswordSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
RABBITMQ_PASSWORD env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.rabbitmq-password-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.rabbitmq-password-env-var-secret-key" }}
{{- if or .Values.rabbitmqPasswordSecretKeyRef .Values.global.rabbitmqPasswordSecretKeyRef }}
{{- printf (coalesce .Values.rabbitmqPasswordSecretKeyRef.key .Values.global.rabbitmqPasswordSecretKeyRef.key) }}
{{- else }}
Expand All @@ -256,18 +256,18 @@ RABBITMQ_PASSWORD env var secret key
{{- /*
RABBITMQ_USERNAME env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.rabbitmq-username-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.rabbitmq-username-env-var-secret-name" }}
{{- if or .Values.rabbitmqUsernameSecretKeyRef .Values.global.rabbitmqUsernameSecretKeyRef }}
{{- printf (coalesce .Values.rabbitmqUsernameSecretKeyRef.name .Values.global.rabbitmqUsernameSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
RABBITMQ_USERNAME env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.rabbitmq-username-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.rabbitmq-username-env-var-secret-key" }}
{{- if or .Values.rabbitmqUsernameSecretKeyRef .Values.global.rabbitmqUsernameSecretKeyRef }}
{{- printf (coalesce .Values.rabbitmqUsernameSecretKeyRef.key .Values.global.rabbitmqUsernameSecretKeyRef.key) }}
{{- else }}
Expand All @@ -278,18 +278,18 @@ RABBITMQ_USERNAME env var secret key
{{- /*
FIREBASE_SECRET env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.firebase-secret-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.firebase-secret-env-var-secret-name" }}
{{- if or .Values.firebaseSecretSecretKeyRef .Values.global.firebaseSecretSecretKeyRef }}
{{- printf (coalesce .Values.firebaseSecretSecretKeyRef.name .Values.global.firebaseSecretSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
FIREBASE_SECRET env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.firebase-secret-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.firebase-secret-env-var-secret-key" }}
{{- if or .Values.firebaseSecretSecretKeyRef .Values.global.firebaseSecretSecretKeyRef }}
{{- printf (coalesce .Values.firebaseSecretSecretKeyRef.key .Values.global.firebaseSecretSecretKeyRef.key) }}
{{- else }}
Expand All @@ -300,18 +300,18 @@ FIREBASE_SECRET env var secret key
{{- /*
FIREBASE_URL env var secret name
*/}}
{{- define "cf-common-0.20.1.classic.firebase-url-env-var-secret-name" }}
{{- define "cf-common-0.21.0.classic.firebase-url-env-var-secret-name" }}
{{- if or .Values.firebaseUrlSecretKeyRef .Values.global.firebaseUrlSecretKeyRef }}
{{- printf (coalesce .Values.firebaseUrlSecretKeyRef.name .Values.global.firebaseUrlSecretKeyRef.name) }}
{{- else }}
{{- printf "%s-%s" (include "cf-common-0.20.1.names.fullname" .) "secret" }}
{{- printf "%s-%s" (include "cf-common-0.21.0.names.fullname" .) "secret" }}
{{- end }}
{{- end }}

{{- /*
FIREBASE_URL env var secret key
*/}}
{{- define "cf-common-0.20.1.classic.firebase-url-env-var-secret-key" }}
{{- define "cf-common-0.21.0.classic.firebase-url-env-var-secret-key" }}
{{- if or .Values.firebaseUrlSecretKeyRef .Values.global.firebaseUrlSecretKeyRef }}
{{- printf (coalesce .Values.firebaseUrlSecretKeyRef.key .Values.global.firebaseUrlSecretKeyRef.key) }}
{{- else }}
Expand Down
10 changes: 5 additions & 5 deletions charts/cf-common/templates/classic/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Calculate RabbitMQ URI (for On-Prem)
Must me called from chart root context.
Usage:
{{ include "cf-common-0.20.1.classic.calculateRabbitMqUri" . }}
{{ include "cf-common-0.21.0.classic.calculateRabbitMqUri" . }}
*/}}

{{- define "cf-common-0.20.1.classic.calculateRabbitMqUri" }}
{{- define "cf-common-0.21.0.classic.calculateRabbitMqUri" }}

{{- $rabbitmqProtocol := .Values.global.rabbitmqProtocol | default "amqp" -}}
{{- $rabbitmqUsername := .Values.global.rabbitmqUsername -}}
Expand All @@ -23,9 +23,9 @@ coalesce here for backward compatibility
{{/*
Calculate Mongo Uri (for On-Prem)
Usage:
{{ include "cf.common-0.20.1.classic.calculateMongoUri" (dict "dbName" $.Values.global.pipelineManagerService "mongoURI" $.Values.global.mongoURI) }}
{{ include "cf.common-0.21.0.classic.calculateMongoUri" (dict "dbName" $.Values.global.pipelineManagerService "mongoURI" $.Values.global.mongoURI) }}
*/}}
{{- define "cf-common-0.20.1.classic.calculateMongoUri" -}}
{{- define "cf-common-0.21.0.classic.calculateMongoUri" -}}
{{- if contains "?" .mongoURI -}}
{{- $mongoURI := (splitList "?" .mongoURI) -}}
{{- printf "%s%s?%s" (first $mongoURI) .dbName (last $mongoURI) }}
Expand All @@ -39,7 +39,7 @@ Usage:
{{/*
Calculate Consul host Uri (for On-Prem)
*/}}
{{- define "cf-common-0.20.1.classic.calculateConsulUri" }}
{{- define "cf-common-0.21.0.classic.calculateConsulUri" }}
{{- if .Values.global.consulHost }}
{{- printf "http://%s:%v" .Values.global.consulHost .Values.global.consulHttpPort -}}
{{- else }}
Expand Down
Loading

0 comments on commit 7854b58

Please sign in to comment.