Skip to content

update argo-workflows and add tags to image values script #31

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

Merged
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
4 changes: 2 additions & 2 deletions charts/gitops-runtime/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: 0.1.27-helm-alpha
description: A Helm chart for Codefresh gitops runtime
name: gitops-runtime
version: 0.2.1-alpha.5
version: 0.2.1-alpha.6
home: https://github.com/codefresh-io/gitops-runtime-helm
keywords:
- codefresh
Expand All @@ -19,7 +19,7 @@ dependencies:
version: 2.0.5-1-cf-init
- name: argo-workflows
repository: https://codefresh-io.github.io/argo-helm
version: 0.22.8-1-cf-init
version: 0.22.9-1-CR-17426
condition: argo-workflows.enabled
- name: argo-rollouts
repository: https://codefresh-io.github.io/argo-helm
Expand Down
4 changes: 2 additions & 2 deletions charts/gitops-runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gitops-runtime

![Version: 0.2.1-alpha.5](https://img.shields.io/badge/Version-0.2.1--alpha.5-informational?style=flat-square) ![AppVersion: 0.1.27-helm-alpha](https://img.shields.io/badge/AppVersion-0.1.27--helm--alpha-informational?style=flat-square)
![Version: 0.2.1-alpha.6](https://img.shields.io/badge/Version-0.2.1--alpha.6-informational?style=flat-square) ![AppVersion: 0.1.27-helm-alpha](https://img.shields.io/badge/AppVersion-0.1.27--helm--alpha-informational?style=flat-square)

A Helm chart for Codefresh gitops runtime

Expand All @@ -21,7 +21,7 @@ A Helm chart for Codefresh gitops runtime
| https://codefresh-io.github.io/argo-helm | argo-cd | 5.28.1-1-cap-CR-17237 |
| https://codefresh-io.github.io/argo-helm | argo-events | 2.0.5-1-cf-init |
| https://codefresh-io.github.io/argo-helm | argo-rollouts | 2.22.1-1-cap-sw |
| https://codefresh-io.github.io/argo-helm | argo-workflows | 0.22.8-1-cf-init |
| https://codefresh-io.github.io/argo-helm | argo-workflows | 0.22.9-1-CR-17426 |

## Values

Expand Down
38 changes: 38 additions & 0 deletions charts/gitops-runtime/ci/values-all-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
global:
codefresh:
accountId: 628a80b693a15c0f9c13ab75 # Codefresh Account id for ilia-codefresh for now, needs to be some test account
gitIntegration:
provider:
name: 'GITHUB'
apiUrl: 'https://api.github.com'
userToken:
secretKeyRef:
name: mysecret
key: myvalue
optional: true

runtime:
name: default
cluster: test-cluster

ingress:
enabled: false

repoCredentialsTemplate:
url: 'https://github.com'
username: 'username'
password: 'dummy'

argo-rollouts:
dashboard:
enabled: true

argo-cd:
redis-ha:
enabled: true
server:
extensions:
enabled: true
redis:
exporter:
enabled: true
5 changes: 3 additions & 2 deletions scripts/list-images-for-mirrror.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MYDIR=$(dirname $0)
CHARTDIR="${MYDIR}/../charts/gitops-runtime"
VALUESFILE="${CHARTDIR}/ci/ingressless-values.yaml"
VALUESFILE="${CHARTDIR}/ci/values-all-images.yaml"
helm dependency update $CHARTDIR > /dev/null
helm template --values $VALUESFILE $CHARTDIR | grep -E -i ".*Image: " | awk -F ':' '{if ($2) printf "%s:%s\n", $2, $3}' | tr -d "\"|[:blank:]" | sort -u |uniq -i
helm template --values $VALUESFILE $CHARTDIR | grep -E -i ".*Image: " | awk -F ':' '{if ($2) printf "%s:%s\n", $2, $3}' | tr -d "\"|[:blank:]" | sort -u |uniq -i
# Current limitation - the image for argoexec is missing, since it's sent as a parameter in the command in the template, and it's hard to match it with a regex.
46 changes: 42 additions & 4 deletions scripts/output-calculated-values.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
#!/bin/bash
MYDIR=$(dirname $0)
CHARTDIR="${MYDIR}/../charts/gitops-runtime"
VALUESFILE="${CHARTDIR}/ci/ingressless-values.yaml"
VALUESFILE="${CHARTDIR}/ci/values-all-images.yaml"
OUTPUTFILE=$1
ALL_VALUES_TEMPLATE=$(cat <<-END
# This template prints all values and also sets tags for all images with non-empty repository value, where the tag is empty and should be derived from the appVersion of the subchart.
ALL_VALUES_TEMPLATE=$(cat <<END
{{- define "recurse-set-image-tags"}}
{{- \$map := .Values }}
{{- \$root := .root }}
{{- \$rootKey := .rootKey}}
{{- range \$key, \$val := \$map -}}
{{- if eq \$key "image" }}
{{/* If tag is not provided, check for subchart appVersion*/}}
{{ if kindOf \$val | eq "map" }}
{{- if hasKey \$val "tag" }}
{{/* If tag has no value*/}}
{{- if and (not \$val.tag) \$val.repository}}
{{- \$suspectedSubChart := \$rootKey }}
{{- if hasKey \$root.Subcharts \$suspectedSubChart }}
{{ \$subchart := get \$root.Subcharts \$suspectedSubChart }}
{{- \$_ := set \$val "tag" \$subchart.Chart.AppVersion }}
{{- else if eq \$rootKey "installer" }}
{{- \$_ := set \$val "tag" \$root.Chart.Version }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- else if kindOf \$val | eq "map" }}
{{- include "recurse-set-image-tags" (dict "rootKey" \$rootKey "root" \$root "Values" \$val) }}
{{- end }}
{{- end }}
{{- end }}

{{- if .Values.getImages }}
{{- \$mergedImagesDict := dict }}
{{- /* Iterate over all top level components (argocd, rollouts workflows, etc)*/}}
{{- range \$key, \$val := .Values -}}
{{- if kindOf \$val | eq "map" }}
{{- /* Recursively get all paths containing image value */}}
{{- \$imagesValsDict := include "recurse-set-image-tags" (dict "rootKey" \$key "root" $ "Values" \$val) | fromYaml }}
{{- end }}
{{- end }}
{{ .Values | toYaml }}
{{- end }}
END
)

echo $ALL_VALUES_TEMPLATE > $CHARTDIR/templates/all-values.yaml
echo -e "$ALL_VALUES_TEMPLATE" > $CHARTDIR/templates/all-values.yaml
helm dependency update $CHARTDIR
helm template --values $VALUESFILE --show-only templates/all-values.yaml $CHARTDIR > $OUTPUTFILE
helm template --values $VALUESFILE --set getImages=true --show-only templates/all-values.yaml $CHARTDIR > $OUTPUTFILE
rm $CHARTDIR/templates/all-values.yaml