Skip to content

Commit dfd1a57

Browse files
authored
Merge pull request #414 from mbaldessari/common-automatic-update
common automatic update
2 parents f12c138 + 1ed6e2a commit dfd1a57

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

common/scripts/manage-secret-app.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ case "$APP" in
1111
APP_NAME="vault"
1212
NAMESPACE="vault"
1313
PROJECT="$MAIN_CLUSTERGROUP_PROJECT"
14-
CHART_LOCATION="common/hashicorp-vault"
14+
CHART_NAME="hashicorp-vault"
15+
CHART_VERSION=0.1.*
16+
1517
;;
1618
"golang-external-secrets")
1719
APP_NAME="golang-external-secrets"
1820
NAMESPACE="golang-external-secrets"
1921
PROJECT="$MAIN_CLUSTERGROUP_PROJECT"
20-
CHART_LOCATION="common/golang-external-secrets"
22+
CHART_NAME="golang-external-secrets"
23+
CHART_VERSION=0.1.*
24+
2125
;;
2226
*)
2327
echo "Error - cannot manage $APP can only manage vault and golang-external-secrets"
@@ -32,13 +36,13 @@ case "$STATE" in
3236
RES=$(yq ".clusterGroup.applications[] | select(.path == \"$CHART_LOCATION\")" "$MAIN_CLUSTERGROUP_FILE" 2>/dev/null)
3337
if [ -z "$RES" ]; then
3438
echo "Application with chart location $CHART_LOCATION not found, adding"
35-
yq -i ".clusterGroup.applications.$APP_NAME = { \"name\": \"$APP_NAME\", \"namespace\": \"$NAMESPACE\", \"project\": \"$PROJECT\", \"path\": \"$CHART_LOCATION\" }" "$MAIN_CLUSTERGROUP_FILE"
39+
yq -i ".clusterGroup.applications.$APP_NAME = { \"name\": \"$APP_NAME\", \"namespace\": \"$NAMESPACE\", \"project\": \"$PROJECT\", \"chart\": \"$CHART_NAME\", \"chartVersion\": \"$CHART_VERSION\"}" "$MAIN_CLUSTERGROUP_FILE"
3640
fi
3741
;;
3842
"absent")
3943
common/scripts/manage-secret-namespace.sh "$NAMESPACE" "$STATE"
4044
echo "Removing application wth chart location $CHART_LOCATION"
41-
yq -i "del(.clusterGroup.applications[] | select(.path == \"$CHART_LOCATION\"))" "$MAIN_CLUSTERGROUP_FILE"
45+
yq -i "del(.clusterGroup.applications[] | select(.chart == \"$CHART_NAME\"))" "$MAIN_CLUSTERGROUP_FILE"
4246
;;
4347
*)
4448
echo "$STATE not supported"

common/scripts/pattern-util.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ function version {
1111
if [ -z "$PATTERN_UTILITY_CONTAINER" ]; then
1212
PATTERN_UTILITY_CONTAINER="quay.io/hybridcloudpatterns/utility-container"
1313
fi
14+
# If PATTERN_DISCONNECTED_HOME is set it will be used to populate both PATTERN_UTILITY_CONTAINER
15+
# and PATTERN_INSTALL_CHART automatically
16+
if [ -n "${PATTERN_DISCONNECTED_HOME}" ]; then
17+
PATTERN_UTILITY_CONTAINER="${PATTERN_DISCONNECTED_HOME}/utility-container"
18+
PATTERN_INSTALL_CHART="oci://${PATTERN_DISCONNECTED_HOME}/pattern-install"
19+
echo "PATTERN_DISCONNECTED_HOME is set to ${PATTERN_DISCONNECTED_HOME}"
20+
echo "Setting the following variables:"
21+
echo " PATTERN_UTILITY_CONTAINER: ${PATTERN_UTILITY_CONTAINER}"
22+
echo " PATTERN_INSTALL_CHART: ${PATTERN_INSTALL_CHART}"
23+
fi
1424

1525
readonly commands=(podman)
1626
for cmd in ${commands[@]}; do is_available "$cmd"; done
@@ -81,6 +91,7 @@ podman run -it --rm --pull=newer \
8191
-e VALUES_SECRET \
8292
-e KUBECONFIG \
8393
-e PATTERN_INSTALL_CHART \
94+
-e PATTERN_DISCONNECTED_HOME \
8495
-e K8S_AUTH_HOST \
8596
-e K8S_AUTH_VERIFY_SSL \
8697
-e K8S_AUTH_SSL_CA_CERT \

common/scripts/preview.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
# DISCLAIMER
44
#
5-
# - Parsing of applications needs to be more clever. Currently the code assumes that all
6-
# targets will be local charts. This is not true, for example, in industrial-edge.
5+
# - Parsing of applications needs to be more clever.
76
# - There is currently not a mechanism to actually preview against multiple clusters
87
# (i.e. a hub and a remote). All previews will be done against the current.
98
# - Make output can be included in the YAML.
@@ -22,11 +21,22 @@ if [ "${APPNAME}" != "clustergroup" ]; then
2221
# path: charts/all/foo
2322
# So we retrieve the actual index ("foobar") given the name attribute of the application
2423
APP=$(yq ".clusterGroup.applications | with_entries(select(.value.name == \"$APPNAME\")) | keys | .[0]" values-$SITE.yaml)
25-
chart=$(yq ".clusterGroup.applications.$APP.path" values-$SITE.yaml)
24+
isLocalHelmChart=$(yq ".clusterGroup.applications.$APP.path" values-$SITE.yaml)
25+
if [ $isLocalHelmChart != "null" ]; then
26+
chart=$(yq ".clusterGroup.applications.$APP.path" values-$SITE.yaml)
27+
else
28+
helmrepo=$(yq ".clusterGroup.applications.$APP.repoURL" values-$SITE.yaml)
29+
helmrepo="${helmrepo:+oci://quay.io/hybridcloudpatterns}"
30+
chartversion=$(yq ".clusterGroup.applications.$APP.chartVersion" values-$SITE.yaml)
31+
chartname=$(yq ".clusterGroup.applications.$APP.chart" values-$SITE.yaml)
32+
chart="${helmrepo}/${chartname} --version ${chartversion}"
33+
fi
2634
namespace=$(yq ".clusterGroup.applications.$APP.namespace" values-$SITE.yaml)
2735
else
2836
APP=$APPNAME
29-
chart="common/clustergroup"
37+
clusterGroupChartVersion=$(yq ".main.multiSourceConfig.clusterGroupChartVersion" values-global.yaml)
38+
helmrepo="oci://quay.io/hybridcloudpatterns"
39+
chart="${helmrepo}/clustergroup --version ${clusterGroupChartVersion}"
3040
namespace="openshift-operators"
3141
fi
3242
pattern=$(yq ".global.pattern" values-global.yaml)

0 commit comments

Comments
 (0)