@@ -218,28 +218,38 @@ reportportal_slack_alert() {
218
218
219
219
# Merge the base YAML value file with the differences file for Kubernetes
220
220
yq_merge_value_files () {
221
- local base_file=$1
222
- local diff_file=$2
221
+ local plugin_operation=$1 # Chose whether you want to merge or overwrite the plugins key (the second file will overwrite the first)
222
+ local base_file=$2
223
+ local diff_file=$3
223
224
local step_1_file=" /tmp/step-without-plugins.yaml"
224
225
local step_2_file=" /tmp/step-only-plugins.yaml"
225
- local final_file=$3
226
- # Step 1: Merge files, excluding the .global.dynamic.plugins key
227
- # Values from `diff_file` override those in `base_file`
228
- yq eval-all '
229
- select(fileIndex == 0) * select(fileIndex == 1) |
230
- del(.global.dynamic.plugins)
231
- ' " ${base_file} " " ${diff_file} " > " ${step_1_file} "
232
- # Step 2: Merge files, combining the .global.dynamic.plugins key
233
- # Values from `diff_file` take precedence; plugins are merged and deduplicated by the .package field
234
- yq eval-all '
235
- select(fileIndex == 0) *+ select(fileIndex == 1) |
236
- .global.dynamic.plugins |= (reverse | unique_by(.package) | reverse)
237
- ' " ${base_file} " " ${diff_file} " > " ${step_2_file} "
238
- # Step 3: Combine results from the previous steps and remove null values
239
- # Values from `step_2_file` override those in `step_1_file`
240
- yq eval-all '
241
- select(fileIndex == 0) * select(fileIndex == 1) | del(.. | select(. == null))
242
- ' " ${step_2_file} " " ${step_1_file} " > " ${final_file} "
226
+ local final_file=$4
227
+ if [ " $plugin_operation " = " merge" ]; then
228
+ # Step 1: Merge files, excluding the .global.dynamic.plugins key
229
+ # Values from `diff_file` override those in `base_file`
230
+ yq eval-all '
231
+ select(fileIndex == 0) * select(fileIndex == 1) |
232
+ del(.global.dynamic.plugins)
233
+ ' " ${base_file} " " ${diff_file} " > " ${step_1_file} "
234
+ # Step 2: Merge files, combining the .global.dynamic.plugins key
235
+ # Values from `diff_file` take precedence; plugins are merged and deduplicated by the .package field
236
+ yq eval-all '
237
+ select(fileIndex == 0) *+ select(fileIndex == 1) |
238
+ .global.dynamic.plugins |= (reverse | unique_by(.package) | reverse)
239
+ ' " ${base_file} " " ${diff_file} " > " ${step_2_file} "
240
+ # Step 3: Combine results from the previous steps and remove null values
241
+ # Values from `step_2_file` override those in `step_1_file`
242
+ yq eval-all '
243
+ select(fileIndex == 0) * select(fileIndex == 1) | del(.. | select(. == null))
244
+ ' " ${step_2_file} " " ${step_1_file} " > " ${final_file} "
245
+ elif [ " $plugin_operation " = " overwrite" ]; then
246
+ yq eval-all '
247
+ select(fileIndex == 0) * select(fileIndex == 1)
248
+ ' " ${base_file} " " ${diff_file} " > " ${final_file} "
249
+ else
250
+ echo " Invalid operation with plugins key: $plugin_operation "
251
+ exit 1
252
+ fi
243
253
}
244
254
245
255
# Waits for a Kubernetes/OpenShift deployment to become ready within a specified timeout period
@@ -833,14 +843,16 @@ initiate_sanity_plugin_checks_deployment() {
833
843
uninstall_helmchart " ${NAME_SPACE_SANITY_PLUGINS_CHECK} " " ${RELEASE_NAME} "
834
844
oc apply -f " $DIR /resources/redis-cache/redis-deployment.yaml" --namespace=" ${NAME_SPACE_SANITY_PLUGINS_CHECK} "
835
845
apply_yaml_files " ${DIR} " " ${NAME_SPACE_SANITY_PLUGINS_CHECK} " " ${sanity_plugins_url} "
846
+ yq_merge_value_files " overwrite" " ${DIR} /value_files/${HELM_CHART_VALUE_FILE_NAME} " " ${DIR} /value_files/${HELM_CHART_SANITY_PLUGINS_DIFF_VALUE_FILE_NAME} " " /tmp/${HELM_CHART_SANITY_PLUGINS_MERGED_VALUE_FILE_NAME} "
847
+ mkdir -p " ${ARTIFACT_DIR} /${NAME_SPACE_SANITY_PLUGINS_CHECK} "
848
+ cp -a " /tmp/${HELM_CHART_SANITY_PLUGINS_MERGED_VALUE_FILE_NAME} " " ${ARTIFACT_DIR} /${NAME_SPACE_SANITY_PLUGINS_CHECK} /" # Save the final value-file into the artifacts directory.
836
849
helm upgrade -i " ${RELEASE_NAME} " \
837
- -n " ${NAME_SPACE_SANITY_PLUGINS_CHECK} " " ${HELM_REPO_NAME} /${HELM_IMAGE_NAME} " \
838
- --version " ${CHART_VERSION} " \
839
- -f " ${DIR} /value_files/${HELM_CHART_VALUE_FILE_NAME} " \
840
- -f " ${DIR} /value_files/sanity-check-plugins.yaml" \
841
- --set global.clusterRouterBase=" ${K8S_CLUSTER_ROUTER_BASE} " \
842
- --set upstream.backstage.image.repository=" ${QUAY_REPO} " \
843
- --set upstream.backstage.image.tag=" ${TAG_NAME} "
850
+ -n " ${NAME_SPACE_SANITY_PLUGINS_CHECK} " " ${HELM_REPO_NAME} /${HELM_IMAGE_NAME} " \
851
+ --version " ${CHART_VERSION} " \
852
+ -f " /tmp/${HELM_CHART_SANITY_PLUGINS_MERGED_VALUE_FILE_NAME} " \
853
+ --set global.clusterRouterBase=" ${K8S_CLUSTER_ROUTER_BASE} " \
854
+ --set upstream.backstage.image.repository=" ${QUAY_REPO} " \
855
+ --set upstream.backstage.image.tag=" ${TAG_NAME} "
844
856
}
845
857
846
858
check_and_test () {
0 commit comments