Skip to content

Commit

Permalink
Merge pull request #605 from darkdoc/fix_scripts
Browse files Browse the repository at this point in the history
Fix scripts after common slim
  • Loading branch information
mbaldessari authored Sep 30, 2024
2 parents 9e4bc56 + b8640e0 commit 07f6584
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
12 changes: 8 additions & 4 deletions scripts/manage-secret-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
18 changes: 14 additions & 4 deletions scripts/preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 07f6584

Please sign in to comment.