Skip to content

Commit

Permalink
feat: Prepare community operators to add new bundles format
Browse files Browse the repository at this point in the history
Signed-off-by: Flavius Lacatusu <flacatus@redhat.com>
  • Loading branch information
flacatus committed Aug 31, 2021
1 parent 86d748b commit d35ae07
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions olm/prepare-community-operators-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ BASE_DIR=$(dirname "$(dirname "$SCRIPT")")
PLATFORMS="kubernetes,openshift"
STABLE_CHANNELS=("stable-all-namespaces" "stable")
source "${BASE_DIR}/olm/check-yq.sh"

base_branch="main"
GITHUB_USER="che-bot"
fork_org="che-incubator"
Expand Down Expand Up @@ -54,6 +53,7 @@ Options:
}

. ${BASE_DIR}/olm/olm.sh

installOPM

for platform in $(echo $PLATFORMS | tr "," " ")
Expand Down Expand Up @@ -111,6 +111,9 @@ do

for channel in "${STABLE_CHANNELS[@]}"
do
# $BASE_DIR is set to {OPERATOR_DIR}/olm
OPERATOR_REPO=$(dirname "$BASE_DIR")

if [[ $channel == "stable-all-namespaces" && $platform == "kubernetes" ]];then
continue
fi
Expand All @@ -132,38 +135,30 @@ do
echo $platform
echo " => will create release '${lastPackagePreReleaseVersion}' in the following package folder :'${folderToUpdate}'"

mkdir -p "${folderToUpdate}/${lastPackagePreReleaseVersion}"
mkdir -p "${folderToUpdate}/${lastPackagePreReleaseVersion}/manifests"
mkdir -p "${folderToUpdate}/${lastPackagePreReleaseVersion}/metadata"
sed \
-e "/^ replaces: ${packageName}.v.*/d" \
-e "/^ version: ${lastPackagePreReleaseVersion}/i\ \ replaces: eclipse-che.v${lastPublishedPackageVersion}" \
-e "s/${packageName}/eclipse-che/" \
"${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/che-operator.clusterserviceversion.yaml" \
> "${folderToUpdate}/${lastPackagePreReleaseVersion}/eclipse-che.v${lastPackagePreReleaseVersion}.clusterserviceversion.yaml"
> "${folderToUpdate}/${lastPackagePreReleaseVersion}/manifests/eclipse-che.v${lastPackagePreReleaseVersion}.clusterserviceversion.yaml"

echo

echo " - Update the CRD files"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org_v1_che_crd.yaml" \
"${folderToUpdate}/${lastPackagePreReleaseVersion}/checlusters.org.eclipse.che.crd.yaml"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml"
"${folderToUpdate}/${lastPackagePreReleaseVersion}/manifests/checlusters.org.eclipse.che.crd.yaml"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_chebackupserverconfigurations_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/manifests/org.eclipse.che_chebackupserverconfigurations_crd.yaml"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterbackups_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/manifests/org.eclipse.che_checlusterbackups_crd.yaml"
cp "${packageBaseFolderPath}/${lastPackagePreReleaseVersion}/org.eclipse.che_checlusterrestores_crd.yaml" "${folderToUpdate}/${lastPackagePreReleaseVersion}/manifests/org.eclipse.che_checlusterrestores_crd.yaml"
echo
echo " - Update 'stable' channel with new release in the package descriptor: ${destinationPackageFilePath}"
sed -e "s/${lastPublishedPackageVersion}/${lastPackagePreReleaseVersion}/" "${destinationPackageFilePath}" > "${destinationPackageFilePath}.new"
echo

# Append to community operators the stable channel csv version: https://github.com/operator-framework/community-operators/blob/master/community-operators/eclipse-che/eclipse-che.package.yaml
if [[ $channel == "stable" ]]; then
mv "${destinationPackageFilePath}.new" "${destinationPackageFilePath}"
fi

# Append to community operators the stable-all-namespaces channel csv version: https://github.com/operator-framework/community-operators/blob/master/community-operators/eclipse-che/eclipse-che.package.yaml
if [[ $channel == "stable-all-namespaces" ]]; then
yq -riY ".channels[1] = { \"currentCSV\": \"eclipse-che.v${lastPackagePreReleaseVersion}\", \"name\": \"$channel\"}" $destinationPackageFilePath
fi
cp "${OPERATOR_REPO}"/bundle/"$channel"/eclipse-che-preview-$platform/metadata/* "${folderToUpdate}/${lastPackagePreReleaseVersion}/metadata"
# Remove tests configs
sed -i '/operators.operatorframework.io.test.config.v1/d' "${folderToUpdate}/${lastPackagePreReleaseVersion}/metadata/annotations.yaml"
sed -i '/operators.operatorframework.io.test.mediatype.v1: scorecard+v1/d' "${folderToUpdate}/${lastPackagePreReleaseVersion}/metadata/annotations.yaml"
done
# Make by default stable channel in the community operators eclipse-che.package.yaml
yq -Yi '.defaultChannel |= "stable"' ${destinationPackageFilePath}

# NOTE: if you update this file, you need to submit a PR against these two files:
# https://github.com/redhat-openshift-ecosystem/community-operators-prod/blob/main/operators/eclipse-che/ci.yaml
Expand Down

0 comments on commit d35ae07

Please sign in to comment.