Skip to content

Commit

Permalink
Added Calico update chart with updatecli
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
  • Loading branch information
rbrtbnfgl committed Mar 27, 2024
1 parent 893bce4 commit dcb5170
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
21 changes: 21 additions & 0 deletions updatecli/scripts/update-calico.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
if [ -n "$CALICO_VERSION" ]; then
current_calico_version=$(yq '.version' packages/rke2-calico/templates/crd-template/Chart.yaml)
if [ "$current_calico_version" != "$CALICO_VERSION" ]; then
echo "Updating Calico chart to $CALICO_VERSION"
mkdir workdir
wget -P workdir/ https://github.com/projectcalico/calico/releases/download/$CALICO_VERSION/tigera-operator-$CALICO_VERSION.tgz
tar --directory=workdir -xf workdir/tigera-operator-$CALICO_VERSION.tgz tigera-operator/values.yaml
current_tigera_operator_version=$(yq '.tigeraOperator.version' workdir/tigera-operator/values.yaml)
rm -fr workdir
sed -i "s/ version: .*/ version: $CALICO_VERSION/g" packages/rke2-calico/generated-changes/patch/Chart.yaml.patch
sed -i "s/ version: .*/ version: $current_tigera_operator_version/g" packages/rke2-calico/generated-changes/patch/values.yaml.patch
sed -i "s/ tag: .*/ tag: $CALICO_VERSION/g" packages/rke2-calico/generated-changes/patch/values.yaml.patch
yq -i ".version = \"$CALICO_VERSION\"" packages/rke2-calico/templates/crd-template/Chart.yaml
yq -i ".url = \"https://github.com/projectcalico/calico/releases/download/$CALICO_VERSION/tigera-operator-$CALICO_VERSION.tgz\" |
.packageVersion = 00" packages/rke2-calico/package.yaml
GOCACHE='/home/runner/.cache/go-build' GOPATH='/home/runner/go' PACKAGE='rke2-calico' make prepare
GOCACHE='/home/runner/.cache/go-build' GOPATH='/home/runner/go' PACKAGE='rke2-calico' make patch
make clean
fi
fi
54 changes: 54 additions & 0 deletions updatecli/updatecli.d/updatecalico.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: "Update Calico version"

sources:
calico:
name: Get calico version
kind: githubrelease
spec:
owner: projectcalico
repository: calico
token: '{{ requiredEnv .github.token }}'
typefilter:
release: true
draft: false
prerelease: false
versionfilter:
kind: latest

targets:
calicoImage:
name: "Bump to latest calico version on the chart"
kind: shell
scmid: default
sourceid: calico
spec:
command: 'updatecli/scripts/update-calico.sh'
environments:
- name: CALICO_VERSION
value: '{{ source "calico" }}'


scms:
default:
kind: github
spec:
token: '{{ requiredEnv .github.token }}'
username: '{{ requiredEnv .github.username }}'
user: '{{ .github.username }}'
email: '{{ .github.email }}'
owner: '{{ .github.owner }}'
repository: '{{ .github.repository }}'
branch: '{{ .github.branch }}'

actions:
default:
title: 'Update Calico version to {{ source "calico" }}'
kind: github/pullrequest
spec:
automerge: false
labels:
- chore
- skip-changelog
- status/auto-created
scmid: default

0 comments on commit dcb5170

Please sign in to comment.