Skip to content

fix: olm script updates for 25.3 #102

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

Merged
merged 3 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
64 changes: 34 additions & 30 deletions olm/build-bundles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,44 +62,52 @@ bundle-clean() {
}

bundle-build() {
local BUNDLE_NAME="$1"
local INPUT_DIR="$2"
local OUTPUT_DIR="$3"
local OPERATOR="$1"
local VERSION="$2"
local INPUT_DIR="$3"
local OUTPUT_DIR="$4"

mkdir -p "$OUTPUT_DIR"
local BUNDLE_NAME="stackable-${OPERATOR}-operator"

# Generate manifests
"${OPERATOR_SDK}" generate bundle \
--deploy-dir "$INPUT_DIR" \
--output-dir "$OUTPUT_DIR" \
--package "$BUNDLE_NAME"
local CHANNEL="$(echo "$VERSION" | sed 's/\.[^.]*$//')"

mkdir -p "$OUTPUT_DIR"
cp -r "${INPUT_DIR}/manifests/" "$OUTPUT_DIR/manifests"
cp -r "${INPUT_DIR}/metadata/" "$OUTPUT_DIR/metadata"

# For whatever reason the generated CSV drops the spec.relatedImages and spec.install properties
cp "${INPUT_DIR}"/manifests/*.clusterserviceversion.yaml "$OUTPUT_DIR/manifests"
cat > "${OUTPUT_DIR}/bundle.Dockerfile" <<BUNDLE_DOCKERFILE
FROM scratch

# Generate metadata
"${OPERATOR_SDK}" generate bundle \
--metadata \
--output-dir "$OUTPUT_DIR" \
--package "$BUNDLE_NAME" \
--channels "stable,$CHANNEL" \
--default-channel "$CHANNEL"
# Core bundle labels.
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=stackable-${OPERATOR}-operator
LABEL operators.operatorframework.io.bundle.channels.v1=stable,${CHANNEL}
LABEL operators.operatorframework.io.bundle.channel.default.v1=${CHANNEL}

# The annotations generated by the operator sdk do not include the openshift versions.
grep com.redhat.openshift "$INPUT_DIR"/metadata/annotations.yaml >> "$OUTPUT_DIR"/metadata/annotations.yaml
# Copy files to locations specified by labels.
COPY manifests /manifests/
COPY metadata /metadata/
BUNDLE_DOCKERFILE

"${OPERATOR_SDK}" bundle validate "$OUTPUT_DIR"

echo "Bundle built successfully!"
}

bundle-deploy() {
local BUNDLE_IMAGE="$1"
local NAMESPACE="${2:-stackable-operators}"
local OPERATOR="$1"
local VERSION="$2"
local OUTPUT_DIR="$3"

local BUNDLE_IMAGE="oci.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"

local NAMESPACE="stackable-operators"

if $DEPLOY; then

docker build -t "$BUNDLE_IMAGE" -f bundle.Dockerfile .
docker build -t "$BUNDLE_IMAGE" -f "${OUTPUT_DIR}/bundle.Dockerfile" "${OUTPUT_DIR}"
docker push "$BUNDLE_IMAGE"

kubectl describe namespace "$NAMESPACE" || kubectl create namespace "$NAMESPACE"
Expand Down Expand Up @@ -139,21 +147,17 @@ main() {
exit 1
fi

CHANNEL="$(echo "$VERSION" | sed 's/\.[^.]*$//')"

if [ "$OPERATOR" == "spark-k8s" ]; then
echo "Renaming operator from spark-k8s to spark"
OPERATOR="spark"
fi

BUNDLE_NAME="${OPERATOR}-operator"
BUNDLE_IMAGE="oci.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"
INPUT_DIR="${OPENSHIFT_ROOT}/operators/stackable-${OPERATOR}-operator/${VERSION}"
OUTPUT_DIR="bundle/stackable-${OPERATOR}-operator/${VERSION}"
OUTPUT_DIR="/tmp/bundle/stackable-${OPERATOR}-operator/${VERSION}"

bundle-clean "$OUTPUT_DIR"
bundle-build "$BUNDLE_NAME" "$INPUT_DIR" "$OUTPUT_DIR"
bundle-deploy "$BUNDLE_IMAGE"
bundle-build "$OPERATOR" "$VERSION" "$INPUT_DIR" "$OUTPUT_DIR"
bundle-deploy "$OPERATOR" "$VERSION" "$OUTPUT_DIR"
}

main "$@"
2 changes: 1 addition & 1 deletion olm/build-manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def write_manifests(args: argparse.Namespace, manifests: list[dict]) -> None:
dest_file = (
args.dest_dir
/ "manifests"
/ f"{args.op_name}.clusterserviceversion.yaml"
/ f"stackable-{args.op_name}.v{args.release}.clusterserviceversion.yaml"
)
elif m["kind"] == "CustomResourceDefinition":
dest_file = (
Expand Down