Skip to content

Instantly share code, notes, and snippets.

@monotek
Created June 8, 2023 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monotek/0cb1ac777a13ed3c38be450349c34839 to your computer and use it in GitHub Desktop.
Save monotek/0cb1ac777a13ed3c38be450349c34839 to your computer and use it in GitHub Desktop.
convert helm repo to oci repo
#!/bin/bash
#
# convert helm repo to oci registry
#
set -e
HELM_REPO="prometheus-community"
HELM_REPO_URL="https://prometheus-community.github.io/helm-charts"
HELM_REPO_OCI_URL="oci://ghcr.io/prometheus-community/charts"
CHART_DIR="charts"
mkdir -p $CHART_DIR
helm repo add $HELM_REPO $HELM_REPO_URL
# pull
for CHART in $(helm search repo $HELM_REPO --max-col-width 1000 | awk '{print $1}' | grep -v 'NAME'); do
for VERSION in $(helm search repo $CHART -l | awk '{print $2}' | grep -v 'CHART' ); do
echo "$CHART $VERSION"
helm pull $CHART --version $VERSION -d $CHART_DIR
done
done
# push
for CHART in $(ls $CHART_DIR | sort -V); do
echo "$CHART"
helm push "$CHART_DIR/$CHART" "$HELM_REPO_OCI_URL"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment