Skip to content

Commit

Permalink
fix: match file names in helm registry index and release assets (#1373)
Browse files Browse the repository at this point in the history
Adding a separate Helm chart for CRDs.

:exclamation: The charts are not strictly dependent to one another and
need to be separately managed and installed. Meaning we need to document
that both of those need to be updated and installed.

Fair questions that might arise:

**Why isn't CRD chart a declared dependency for `odigos`?**

Helm merges dependent resources together with the ones from
dependencies. We'd be exactly where we are right now if we did that.

**Why not use the official `crd` support?**

Helm really doesn't "support" CRDs. It's an opt-out feature of "we don't
know how we want to do it so we don't for now". Resources declared as
CRDs(different from declaring them under `templates`) are not updated.

**How do other charts do it then?**

All charts I've encountered(cert-manager, jaeger, contour) have CRDs
under a flag and include them in the same chart as the rest of the
resources **but then** do not depend on them in in the install. CRs are
created either only by the user or later in the applications life-cycle.
This doesn't work for us since we declare Odigos Config among resources
in the application chart. That begs the question whether Odigos Config
must be a CR at all or could it be a config map instead - we wouldn't
get "type-checking" by k8s API but would gain some flexibility and could
release our charts as one.
  • Loading branch information
rauno56 authored Jul 22, 2024
1 parent 1d2a929 commit 0df64e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Odigos CLI
name: Release Odigos

on:
workflow_dispatch:
Expand Down Expand Up @@ -137,6 +137,7 @@ jobs:
echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV
else
echo "Unknown event type"
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
exit 1
fi
Expand All @@ -156,4 +157,6 @@ jobs:
version: v3.15.2

- name: Release Helm charts
run: sh ./scripts/release-charts.sh
env:
GH_TOKEN: ${{ github.token }}
run: bash ./scripts/release-charts.sh
8 changes: 4 additions & 4 deletions helm/odigos/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
name: odigos
description: Odigos Helm Chart for Kubernetes
description: Odigos distribution for Kubernetes
type: application
# v0.0.0 will be replaced by the git tag version on release
version: "v0.0.0"
appVersion: "v0.0.0"
# 0.0.0 will be replaced by the git tag version on release
version: "0.0.0"
appVersion: "0.0.0"
icon: https://d2q89wckrml3k4.cloudfront.net/logo.png
30 changes: 22 additions & 8 deletions scripts/release-charts.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

# Setup
TMPDIR="$(mktemp -d)"
CHARTDIR="helm/odigos"
CHARTDIRS=("helm/odigos")

prefix () {
echo "${@:1}"
echo "${@:2}"
for i in "${@:2}"; do
echo "Renaming $i to $1$i"
mv "$i" "$1$i"
done
}

if [ -z "$TAG" ]; then
echo "TAG required"
Expand All @@ -14,7 +23,7 @@ if [ -z "$GITHUB_REPOSITORY" ]; then
exit 1
fi

if [[ $(git diff -- $CHARTDIR | wc -c) -ne 0 ]]; then
if [[ $(git diff -- ${CHARTDIRS[*]} | wc -c) -ne 0 ]]; then
echo "Helm chart dirty. Aborting."
exit 1
fi
Expand All @@ -24,16 +33,21 @@ helm repo add odigos https://odigos-io.github.io/odigos-charts 2> /dev/null || t
git worktree add $TMPDIR gh-pages -f

# Update index with new packages
sed -i -E 's/v0.0.0/'"${TAG}"'/' $CHARTDIR/Chart.yaml
helm package helm/* -d $TMPDIR
for chart in "${CHARTDIRS[@]}"
do
echo "Updating $chart/Chart.yaml with version ${TAG#v}"
sed -i -E 's/0.0.0/'"${TAG#v}"'/' $chart/Chart.yaml
done
helm package ${CHARTDIRS[*]} -d $TMPDIR
pushd $TMPDIR
prefix 'test-helm-assets-' *.tgz
helm repo index . --merge index.yaml --url https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/
git diff -G apiVersion

# The check avoids pushing the same tag twice and only pushes if there's a new entry in the index
if [[ $(git diff -G apiVersion | wc -c) -ne 0 ]]; then
# Upload new packages
rename 'odigos' 'test-helm-assets-odigos' *.tgz
gh release upload -R $GITHUB_REPOSITORY $TAG $TMPDIR/*.tgz
gh release upload -R $GITHUB_REPOSITORY $TAG $TMPDIR/*.tgz || exit 1

git add index.yaml
git commit -m "update index with $TAG" && git push
Expand All @@ -45,5 +59,5 @@ else
fi

# Roll back chart version changes
git checkout $CHARTDIR
git checkout ${CHARTDIRS[*]}
git worktree remove $TMPDIR -f || echo " -> Failed to clean up temp worktree"

0 comments on commit 0df64e9

Please sign in to comment.