github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/config/scripts/process_upgrade_yaml.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright (c) 2021, 2022, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  
     6  function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
     7  
     8  # This script is used to add the version: field to the verrazzano custom resource .yaml file
     9  # It is needed to test upgrade
    10  VERSION=$1
    11  CR_FILE=$2
    12  VERSION_TO_USE=$VERSION
    13  
    14  # remove leading v if it exists
    15  if [[ "$VERSION_TO_USE" =~ ^v ]]; then
    16    VERSION_TO_USE=$(echo $VERSION_TO_USE | cut -c2-)
    17  fi
    18  echo Version without leading v is $VERSION_TO_USE
    19  
    20  yq -i eval ".spec.version = \"v${VERSION_TO_USE}\"" ${CR_FILE}
    21  
    22  if version_ge $VERSION_TO_USE "1.3.0"; then
    23    if [ "$CRD_API_VERSION" == "v1alpha1" ]; then
    24      echo "$VERSION_TO_USE supports updates, testing update on upgrade scenario"
    25      # Add some simple additional updates to validate update during an upgrade
    26      yq -i eval '.spec.components.istio.ingress.kubernetes.replicas = 3' ${CR_FILE}
    27      yq -i eval '.spec.components.istio.egress.kubernetes.replicas = 3' ${CR_FILE}
    28    elif [ "$CRD_API_VERSION" == "v1beta1" ]; then
    29      yq -i eval '.spec.components.istio.overrides.[0].values.apiVersion = "install.istio.io/v1alpha1"' ${CR_FILE}
    30      yq -i eval '.spec.components.istio.overrides.[0].values.kind = "IstioOperator"' ${CR_FILE}
    31      yq -i eval '.spec.components.istio.overrides.[0].values.spec.components.ingressGateways.[0].enabled = true' ${CR_FILE}
    32      yq -i eval '.spec.components.istio.overrides.[0].values.spec.components.ingressGateways.[0].k8s.replicaCount = 3' ${CR_FILE}
    33      yq -i eval '.spec.components.istio.overrides.[0].values.spec.components.ingressGateways.[0].name = "istio-ingressgateway"' ${CR_FILE}
    34      yq -i eval '.spec.components.istio.overrides.[0].values.spec.components.egressGateways.[0].enabled = true' ${CR_FILE}
    35      yq -i eval '.spec.components.istio.overrides.[0].values.spec.components.egressGateways.[0].k8s.replicaCount = 3' ${CR_FILE}
    36      yq -i eval '.spec.components.istio.overrides.[0].values.spec.components.egressGateways.[0].name = "istio-egressgateway"' ${CR_FILE}
    37    fi
    38  fi