Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts updates for Helm #605

Merged
merged 6 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021.
Copyright 2023.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
22 changes: 22 additions & 0 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

NEXT_VERSION=""

next_minor_version() {
local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'

local MINOR=$(echo $CURRENT_VERSION | sed -e "s#$RE#\2#")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This looks unused.


local NEXT_VERSION_PARTS=()
for i in {1..3}
do
local PART=$(echo $CURRENT_VERSION | sed -e "s#$RE#\\$i#")
if [ $i == 2 ]
then
let PART+=1
fi
NEXT_VERSION_PARTS+=($PART)
done

NEXT_VERSION=${NEXT_VERSION_PARTS[0]}.${NEXT_VERSION_PARTS[1]}.0
}
5 changes: 5 additions & 0 deletions scripts/post-release-process.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh
if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

IMG=k8ssandra/cass-operator:latest
KUSTOMIZE=$(pwd)/bin/kustomize

Expand Down
4 changes: 4 additions & 0 deletions scripts/postprocess-bundle.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

# These labels are required to be in the bundle.Dockerfile, but can't be added by the operator-sdk automatically
cat <<EOF >> bundle.Dockerfile
Expand Down
8 changes: 6 additions & 2 deletions scripts/pre-release-process.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

if [ "$#" -ne 1 ]; then
echo "Usage: scripts/pre-release-process.sh newTag"
Expand All @@ -16,10 +20,10 @@ make kustomize
KUSTOMIZE=$(pwd)/bin/kustomize

# Modify CHANGELOG automatically to match the tag
sed -i -e "s/## unreleased/## $TAG/" CHANGELOG.md
sed -i '' -e "s/## unreleased/## $TAG/" CHANGELOG.md

# Modify README to include proper installation refs
sed -i -e "s/$PREVTAG/$TAG/g" README.md
sed -i '' -e "s/$PREVTAG/$TAG/g" README.md

# Modify config/manager/kustomization.yaml to have proper newTag for cass-operator
cd config/manager && $KUSTOMIZE edit set image controller=$IMG && cd -
Expand Down
4 changes: 4 additions & 0 deletions scripts/release-certified-bundles.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

if [ "$#" -ne 4 ]; then
echo "Usage: scripts/release-certified-bundles.sh version sha256:<cass-operator-sha256> sha256:<system-logger-sha256> sha256:<k8ssandra-client-sha256>"
Expand Down
4 changes: 4 additions & 0 deletions scripts/release-community-bundles.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

if [ "$#" -ne 1 ]; then
echo "Usage: scripts/release-community-bundles.sh version"
Expand Down
49 changes: 47 additions & 2 deletions scripts/release-helm-chart.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh

if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

# This script assumes k8ssandra is checked out at ../k8ssandra and is checked out at main
if [ "$#" -ne 1 ]; then
echo "Usage: scripts/release-helm-chart.sh version"
Expand All @@ -8,9 +13,12 @@ if [ "$#" -ne 1 ]; then
exit
fi

# This should work with BSD/MacOS mktemp and GNU one
CRD_TMP_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'crd')

VERSION=$1
CHART_HOME=../k8ssandra/charts/cass-operator
CRD_TARGET_PATH=$CHART_HOME/crds
CRD_TARGET_PATH=$CRD_TMP_DIR
TEMPLATE_HOME=$CHART_HOME/templates

# Checkout tag
Expand All @@ -25,4 +33,41 @@ for f in $CRD_TARGET_PATH/*; do
mv $f $CRD_TARGET_PATH/$TARGET_FILENAME
done

# TODO Update all the necessary fields also (Chart.yaml, values.yaml, configmap.yaml)
# Add Helm conditionals to the end and beginnin of CRDs before applying them to the templates path
burmanm marked this conversation as resolved.
Show resolved Hide resolved
echo "Updating CRDs in" $TEMPLATE_HOME
CRD_FILE_NAME=$TEMPLATE_HOME/crds.yaml
echo '{{- if .Values.updateCRDs }}' > $CRD_FILE_NAME

declare -a files
files=($CRD_TARGET_PATH/*)
for i in ${!files[@]}; do
echo "Processing " ${files[$i]}
cat ${files[$i]} >> $CRD_FILE_NAME
if [[ $i -lt ${#files[@]}-1 ]]; then
echo "---" >> $CRD_FILE_NAME
fi
done
echo '{{- end }}' >> $CRD_FILE_NAME

rm -fr $CRD_TMP_DIR

# Update version of the Chart.yaml automatically (to next minor one)
CURRENT_VERSION=$(yq '.version' $CHART_HOME/Chart.yaml)
. scripts/lib.sh
next_minor_version
echo "Updating Chart.yaml version to next minor version" $NEXT_VERSION
yq -i '.version = "'"$NEXT_VERSION"'"' $CHART_HOME/Chart.yaml

# Update appVersion to the same as version
echo "Setting appVersion to" $VERSION
yq -i '.appVersion = "'"$VERSION"'"' $CHART_HOME/Chart.yaml

# Update imageConfig settings to the current one
echo "Updating .Values.imageConfig to match config/manager/image_config.yaml"
SYSTEM_LOGGER_IMAGE=$(yq '.images.system-logger' config/manager/image_config.yaml)
K8SSANDRA_CLIENT_IMAGE=$(yq '.images.k8ssandra-client' config/manager/image_config.yaml)
CONFIG_BUILDER_IMAGE=$(yq '.images.config-builder' config/manager/image_config.yaml)

yq -i '.imageConfig.systemLogger = "cr.k8ssandra.io" + "/" + "'"$SYSTEM_LOGGER_IMAGE"'"' $CHART_HOME/values.yaml
yq -i '.imageConfig.k8ssandraClient = "cr.k8ssandra.io" + "/" + "'"$K8SSANDRA_CLIENT_IMAGE"'"' $CHART_HOME/values.yaml
yq -i '.imageConfig.configBuilder = "cr.dtsx.io" + "/" + "'"$CONFIG_BUILDER_IMAGE"'"' $CHART_HOME/values.yaml
24 changes: 7 additions & 17 deletions scripts/update-makefile-version.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/bin/bash
if [[ ! $0 == scripts/* ]]; then
echo "This script must be run from the root directory"
exit 1
fi

RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
. scripts/lib.sh

CURRENT_VERSION=$(gawk 'match($0, /^VERSION \?= /) { print substr($0, RLENGTH+1)}' Makefile)
MINOR=$(echo $CURRENT_VERSION | sed -e "s#$RE#\2#")

NEXT_VERSION_PARTS=()
for i in {1..3}
do
PART=$(echo $CURRENT_VERSION | sed -e "s#$RE#\\$i#")
if [ $i == 2 ]
then
let PART+=1
fi
NEXT_VERSION_PARTS+=($PART)
done

NEXT_VERSION=${NEXT_VERSION_PARTS[0]}.${NEXT_VERSION_PARTS[1]}.${NEXT_VERSION_PARTS[2]}

sed -i -e "s/VERSION ?= $CURRENT_VERSION/VERSION ?= $NEXT_VERSION/" Makefile
next_minor_version
sed -i '' -e "s/VERSION ?= $CURRENT_VERSION/VERSION ?= $NEXT_VERSION/" Makefile
Loading