diff --git a/scripts/airgap-push.sh b/scripts/airgap-push.sh index 393833114..0f894c364 100755 --- a/scripts/airgap-push.sh +++ b/scripts/airgap-push.sh @@ -25,6 +25,29 @@ HELP="" EXTENSION_TARBALL_PREFIX="hmc-extension-images" WORK_DIR="$(pwd)/hmc-airgap" +# Print the help message +function print_help() { + echo "Usage:" + echo " airgap-push.sh [OPTIONS]" + echo "Ensure repositories are logged into via 'helm' and 'docker' before running this script." + echo "Options:" + echo " -h, --help" + echo " Print this help message" + echo " -r, --image-repo (required)" + echo " The image repo to push the images to" + echo " -c, --chart-repo (required)" + echo " The repository to push the Helm charts to, for OCI prefix use oci://" + echo " -i, --insecure-registry" + echo " Use insecure registry for pushing Helm charts" + echo " -a, --airgap-bundle (required)" + echo " The path to the airgap bundle" +} + +function ctrl_c() { + echo "Caught CTRL-C, exiting..." + exit 1 +} + trap ctrl_c INT # Parse the options @@ -45,6 +68,10 @@ while [[ $# -gt 0 ]]; do shift shift ;; + -i|--insecure-registry) + INSECURE_REGISTRY="true" + shift + ;; -a|--airgap-bundle) AIRGAP_BUNDLE="$2" shift @@ -52,31 +79,12 @@ while [[ $# -gt 0 ]]; do ;; *) echo "Unknown option: $1" + print_help exit 1 ;; esac done -# Print the help message -function print_help() { - echo "Usage:" - echo " airgap-push.sh [OPTIONS]" - echo "Ensure repositories are logged into via 'helm' and 'docker' before running this script." - echo "Options:" - echo " -h, --help" - echo " Print this help message" - echo " -r, --image-repo (required)" - echo " The image repo to push the images to" - echo " -c, --chart-repo (required)" - echo " The repository to push the Helm charts to, for OCI prefix use oci://" - echo " -a, --airgap-bundle (required)" - echo " The path to the airgap bundle" -} - -function ctrl_c() { - echo "Caught CTRL-C, exiting..." - exit 1 -} if [ ! -z "$HELP" ]; then print_help @@ -106,6 +114,11 @@ else fi fi +if [ ! $(command -v jq) ]; then + echo "'jq' could not be found, install 'jq' to continue" + exit 1 +fi + mkdir -p ${WORK_DIR} # Extract extension images from the airgap bundle. @@ -157,7 +170,7 @@ for image in $(cat ${WORK_DIR}/repositories | jq -r 'to_entries[] | .key'); do done # Extract all of the Helm charts from the airgap bundle. -echo "Extracting Helm charts from the airgap bundle..." +echo "Extracting Helm charts from airgap bundle: ${AIRGAP_BUNDLE}..." tar -C ${WORK_DIR} -xf ${AIRGAP_BUNDLE} "charts" if [ $? -ne 0 ]; then echo "Failed to extract Helm charts from the airgap bundle" @@ -166,8 +179,12 @@ fi # Next, use Helm to push the charts to the given chart repository. echo "Pushing Helm charts to ${CHART_REPO}..." +if [ ! -z "$INSECURE_REGISTRY" ]; then + insecure_registry_flag="--insecure-skip-tls-verify" +fi + for chart in $(find ${WORK_DIR}/charts -name "*.tgz"); do - helm push ${chart} ${CHART_REPO} + helm push ${insecure_registry_flag} ${chart} ${CHART_REPO} if [ $? -ne 0 ]; then echo "Failed to push Helm chart: ${chart}" exit 1 diff --git a/scripts/bundle-images.sh b/scripts/bundle-images.sh index 647d54f54..1eb7afaea 100755 --- a/scripts/bundle-images.sh +++ b/scripts/bundle-images.sh @@ -111,9 +111,9 @@ do wait_for_deploy_exist "$LABEL_KEY=$label_value" - ${KUBECTL} wait --for condition=available --timeout=2m deploy -l ${LABEL_KEY}=${label_value} -n ${NAMESPACE} + ${KUBECTL} wait --for condition=available --timeout=10m deploy -l ${LABEL_KEY}=${label_value} -n ${NAMESPACE} if [[ $? -ne 0 ]]; then - echo "Error: Cannot wait for Deployment: Deployment with ${LABEL_KEY}=${label_value} label not found" + echo "Error: Timed out waiting for available Deployment with ${LABEL_KEY}=${label_value} label" exit 1 fi done