diff --git a/common/scripts/manage-secret-app.sh b/common/scripts/manage-secret-app.sh index 1ea0d0bb4..18a986e5a 100755 --- a/common/scripts/manage-secret-app.sh +++ b/common/scripts/manage-secret-app.sh @@ -11,13 +11,17 @@ case "$APP" in APP_NAME="vault" NAMESPACE="vault" PROJECT="$MAIN_CLUSTERGROUP_PROJECT" - CHART_LOCATION="common/hashicorp-vault" + CHART_NAME="hashicorp-vault" + CHART_VERSION=0.1.* + ;; "golang-external-secrets") APP_NAME="golang-external-secrets" NAMESPACE="golang-external-secrets" PROJECT="$MAIN_CLUSTERGROUP_PROJECT" - CHART_LOCATION="common/golang-external-secrets" + CHART_NAME="golang-external-secrets" + CHART_VERSION=0.1.* + ;; *) echo "Error - cannot manage $APP can only manage vault and golang-external-secrets" @@ -32,13 +36,13 @@ case "$STATE" in RES=$(yq ".clusterGroup.applications[] | select(.path == \"$CHART_LOCATION\")" "$MAIN_CLUSTERGROUP_FILE" 2>/dev/null) if [ -z "$RES" ]; then echo "Application with chart location $CHART_LOCATION not found, adding" - yq -i ".clusterGroup.applications.$APP_NAME = { \"name\": \"$APP_NAME\", \"namespace\": \"$NAMESPACE\", \"project\": \"$PROJECT\", \"path\": \"$CHART_LOCATION\" }" "$MAIN_CLUSTERGROUP_FILE" + yq -i ".clusterGroup.applications.$APP_NAME = { \"name\": \"$APP_NAME\", \"namespace\": \"$NAMESPACE\", \"project\": \"$PROJECT\", \"chart\": \"$CHART_NAME\", \"chartVersion\": \"$CHART_VERSION\"}" "$MAIN_CLUSTERGROUP_FILE" fi ;; "absent") common/scripts/manage-secret-namespace.sh "$NAMESPACE" "$STATE" echo "Removing application wth chart location $CHART_LOCATION" - yq -i "del(.clusterGroup.applications[] | select(.path == \"$CHART_LOCATION\"))" "$MAIN_CLUSTERGROUP_FILE" + yq -i "del(.clusterGroup.applications[] | select(.chart == \"$CHART_NAME\"))" "$MAIN_CLUSTERGROUP_FILE" ;; *) echo "$STATE not supported" diff --git a/common/scripts/pattern-util.sh b/common/scripts/pattern-util.sh index 675cc1173..1fcaee76a 100755 --- a/common/scripts/pattern-util.sh +++ b/common/scripts/pattern-util.sh @@ -11,6 +11,16 @@ function version { if [ -z "$PATTERN_UTILITY_CONTAINER" ]; then PATTERN_UTILITY_CONTAINER="quay.io/hybridcloudpatterns/utility-container" fi +# If PATTERN_DISCONNECTED_HOME is set it will be used to populate both PATTERN_UTILITY_CONTAINER +# and PATTERN_INSTALL_CHART automatically +if [ -n "${PATTERN_DISCONNECTED_HOME}" ]; then + PATTERN_UTILITY_CONTAINER="${PATTERN_DISCONNECTED_HOME}/utility-container" + PATTERN_INSTALL_CHART="oci://${PATTERN_DISCONNECTED_HOME}/pattern-install" + echo "PATTERN_DISCONNECTED_HOME is set to ${PATTERN_DISCONNECTED_HOME}" + echo "Setting the following variables:" + echo " PATTERN_UTILITY_CONTAINER: ${PATTERN_UTILITY_CONTAINER}" + echo " PATTERN_INSTALL_CHART: ${PATTERN_INSTALL_CHART}" +fi readonly commands=(podman) for cmd in ${commands[@]}; do is_available "$cmd"; done @@ -81,6 +91,7 @@ podman run -it --rm --pull=newer \ -e VALUES_SECRET \ -e KUBECONFIG \ -e PATTERN_INSTALL_CHART \ + -e PATTERN_DISCONNECTED_HOME \ -e K8S_AUTH_HOST \ -e K8S_AUTH_VERIFY_SSL \ -e K8S_AUTH_SSL_CA_CERT \ diff --git a/common/scripts/preview.sh b/common/scripts/preview.sh index b9839c513..6da45785a 100755 --- a/common/scripts/preview.sh +++ b/common/scripts/preview.sh @@ -2,8 +2,7 @@ # DISCLAIMER # -# - Parsing of applications needs to be more clever. Currently the code assumes that all -# targets will be local charts. This is not true, for example, in industrial-edge. +# - Parsing of applications needs to be more clever. # - There is currently not a mechanism to actually preview against multiple clusters # (i.e. a hub and a remote). All previews will be done against the current. # - Make output can be included in the YAML. @@ -22,11 +21,22 @@ if [ "${APPNAME}" != "clustergroup" ]; then # path: charts/all/foo # So we retrieve the actual index ("foobar") given the name attribute of the application APP=$(yq ".clusterGroup.applications | with_entries(select(.value.name == \"$APPNAME\")) | keys | .[0]" values-$SITE.yaml) - chart=$(yq ".clusterGroup.applications.$APP.path" values-$SITE.yaml) + isLocalHelmChart=$(yq ".clusterGroup.applications.$APP.path" values-$SITE.yaml) + if [ $isLocalHelmChart != "null" ]; then + chart=$(yq ".clusterGroup.applications.$APP.path" values-$SITE.yaml) + else + helmrepo=$(yq ".clusterGroup.applications.$APP.repoURL" values-$SITE.yaml) + helmrepo="${helmrepo:+oci://quay.io/hybridcloudpatterns}" + chartversion=$(yq ".clusterGroup.applications.$APP.chartVersion" values-$SITE.yaml) + chartname=$(yq ".clusterGroup.applications.$APP.chart" values-$SITE.yaml) + chart="${helmrepo}/${chartname} --version ${chartversion}" + fi namespace=$(yq ".clusterGroup.applications.$APP.namespace" values-$SITE.yaml) else APP=$APPNAME - chart="common/clustergroup" + clusterGroupChartVersion=$(yq ".main.multiSourceConfig.clusterGroupChartVersion" values-global.yaml) + helmrepo="oci://quay.io/hybridcloudpatterns" + chart="${helmrepo}/clustergroup --version ${clusterGroupChartVersion}" namespace="openshift-operators" fi pattern=$(yq ".global.pattern" values-global.yaml)