Skip to content

Commit 37c23b2

Browse files
committed
validate_helm_chart: add support for oci repositories
Signed-off-by: André Martins <andre@cilium.io>
1 parent 2db7df2 commit 37c23b2

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

validate_helm_chart.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ yq () {
1717
}
1818

1919
usage() {
20-
>&2 echo "usage: $0 <chart-tgz-file>"
20+
>&2 echo "usage: $0 <chart-tgz-file|oci-chart-reference>"
2121
>&2 echo
2222
>&2 echo "example: $0 cilium-1.15.5.tgz"
2323
>&2 echo "example: $0 tetragon-1.1.0.tgz"
24+
>&2 echo "example: $0 oci://registry.example.com/cilium/cilium:1.15.5"
25+
>&2 echo "example: $0 oci://registry.example.com/cilium/tetragon:1.1.0"
2426
}
2527

2628
CILIUM_IMAGE_PATHS=(
@@ -36,17 +38,25 @@ TETRAGON_IMAGE_PATHS=(
3638
'{$.tetragonOperator.image.tag}'
3739
)
3840

39-
# $1 - Helm chart tgz file
41+
# $1 - Helm chart tgz file or OCI chart reference
4042
main() {
41-
TGZ="$1"
43+
CHART="$1"
4244

43-
if [ ! -f "$TGZ" ]; then
44-
echo "ERROR: Chart tgz file not found: $TGZ"
45+
if [ -z "$CHART" ]; then
46+
echo "ERROR: Chart argument is required"
4547
usage
4648
exit 1
4749
fi
48-
APP=$(helm show chart "$TGZ" | yq e '.name' -)
49-
CHART_VERSION=$(helm show chart "$TGZ" | yq e '.version' -)
50+
51+
# Check if it's an OCI chart (starts with oci://) or a file
52+
if [[ ! "$CHART" =~ ^oci:// ]] && [ ! -f "$CHART" ]; then
53+
echo "ERROR: Chart file not found: $CHART"
54+
usage
55+
exit 1
56+
fi
57+
58+
APP=$(helm show chart "$CHART" | yq e '.name' -)
59+
CHART_VERSION=$(helm show chart "$CHART" | yq e '.version' -)
5060
if [ "$APP" == "cilium" ]; then
5161
IMAGE_PATHS=("${CILIUM_IMAGE_PATHS[@]}")
5262
elif [ "$APP" == "tetragon" ]; then
@@ -57,7 +67,7 @@ main() {
5767
fi
5868

5969
for path in "${IMAGE_PATHS[@]}"; do
60-
tag=$(helm show values --jsonpath "$path" "$TGZ")
70+
tag=$(helm show values --jsonpath "$path" "$CHART")
6171
if [ "$tag" == "v$CHART_VERSION" ]; then
6272
echo "SUCCESS: $APP $path=$tag matches chart version $CHART_VERSION"
6373
else

0 commit comments

Comments
 (0)