Skip to content

Commit f4ffbb5

Browse files
authored
fix: olm script updates for 25.3 (#102)
* wip * fix typo * delete metrics bundle labels
1 parent 374f25d commit f4ffbb5

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

olm/build-bundles.sh

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,44 +62,52 @@ bundle-clean() {
6262
}
6363

6464
bundle-build() {
65-
local BUNDLE_NAME="$1"
66-
local INPUT_DIR="$2"
67-
local OUTPUT_DIR="$3"
65+
local OPERATOR="$1"
66+
local VERSION="$2"
67+
local INPUT_DIR="$3"
68+
local OUTPUT_DIR="$4"
6869

69-
mkdir -p "$OUTPUT_DIR"
70+
local BUNDLE_NAME="stackable-${OPERATOR}-operator"
7071

71-
# Generate manifests
72-
"${OPERATOR_SDK}" generate bundle \
73-
--deploy-dir "$INPUT_DIR" \
74-
--output-dir "$OUTPUT_DIR" \
75-
--package "$BUNDLE_NAME"
72+
local CHANNEL="$(echo "$VERSION" | sed 's/\.[^.]*$//')"
73+
74+
mkdir -p "$OUTPUT_DIR"
75+
cp -r "${INPUT_DIR}/manifests/" "$OUTPUT_DIR/manifests"
76+
cp -r "${INPUT_DIR}/metadata/" "$OUTPUT_DIR/metadata"
7677

77-
# For whatever reason the generated CSV drops the spec.relatedImages and spec.install properties
78-
cp "${INPUT_DIR}"/manifests/*.clusterserviceversion.yaml "$OUTPUT_DIR/manifests"
78+
cat > "${OUTPUT_DIR}/bundle.Dockerfile" <<BUNDLE_DOCKERFILE
79+
FROM scratch
7980
80-
# Generate metadata
81-
"${OPERATOR_SDK}" generate bundle \
82-
--metadata \
83-
--output-dir "$OUTPUT_DIR" \
84-
--package "$BUNDLE_NAME" \
85-
--channels "stable,$CHANNEL" \
86-
--default-channel "$CHANNEL"
81+
# Core bundle labels.
82+
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
83+
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
84+
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
85+
LABEL operators.operatorframework.io.bundle.package.v1=stackable-${OPERATOR}-operator
86+
LABEL operators.operatorframework.io.bundle.channels.v1=stable,${CHANNEL}
87+
LABEL operators.operatorframework.io.bundle.channel.default.v1=${CHANNEL}
8788
88-
# The annotations generated by the operator sdk do not include the openshift versions.
89-
grep com.redhat.openshift "$INPUT_DIR"/metadata/annotations.yaml >> "$OUTPUT_DIR"/metadata/annotations.yaml
89+
# Copy files to locations specified by labels.
90+
COPY manifests /manifests/
91+
COPY metadata /metadata/
92+
BUNDLE_DOCKERFILE
9093

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

9396
echo "Bundle built successfully!"
9497
}
9598

9699
bundle-deploy() {
97-
local BUNDLE_IMAGE="$1"
98-
local NAMESPACE="${2:-stackable-operators}"
100+
local OPERATOR="$1"
101+
local VERSION="$2"
102+
local OUTPUT_DIR="$3"
103+
104+
local BUNDLE_IMAGE="oci.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"
105+
106+
local NAMESPACE="stackable-operators"
99107

100108
if $DEPLOY; then
101109

102-
docker build -t "$BUNDLE_IMAGE" -f bundle.Dockerfile .
110+
docker build -t "$BUNDLE_IMAGE" -f "${OUTPUT_DIR}/bundle.Dockerfile" "${OUTPUT_DIR}"
103111
docker push "$BUNDLE_IMAGE"
104112

105113
kubectl describe namespace "$NAMESPACE" || kubectl create namespace "$NAMESPACE"
@@ -139,21 +147,17 @@ main() {
139147
exit 1
140148
fi
141149

142-
CHANNEL="$(echo "$VERSION" | sed 's/\.[^.]*$//')"
143-
144150
if [ "$OPERATOR" == "spark-k8s" ]; then
145151
echo "Renaming operator from spark-k8s to spark"
146152
OPERATOR="spark"
147153
fi
148154

149-
BUNDLE_NAME="${OPERATOR}-operator"
150-
BUNDLE_IMAGE="oci.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"
151155
INPUT_DIR="${OPENSHIFT_ROOT}/operators/stackable-${OPERATOR}-operator/${VERSION}"
152-
OUTPUT_DIR="bundle/stackable-${OPERATOR}-operator/${VERSION}"
156+
OUTPUT_DIR="/tmp/bundle/stackable-${OPERATOR}-operator/${VERSION}"
153157

154158
bundle-clean "$OUTPUT_DIR"
155-
bundle-build "$BUNDLE_NAME" "$INPUT_DIR" "$OUTPUT_DIR"
156-
bundle-deploy "$BUNDLE_IMAGE"
159+
bundle-build "$OPERATOR" "$VERSION" "$INPUT_DIR" "$OUTPUT_DIR"
160+
bundle-deploy "$OPERATOR" "$VERSION" "$OUTPUT_DIR"
157161
}
158162

159163
main "$@"

olm/build-manifests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def write_manifests(args: argparse.Namespace, manifests: list[dict]) -> None:
323323
dest_file = (
324324
args.dest_dir
325325
/ "manifests"
326-
/ f"{args.op_name}.clusterserviceversion.yaml"
326+
/ f"stackable-{args.op_name}.v{args.release}.clusterserviceversion.yaml"
327327
)
328328
elif m["kind"] == "CustomResourceDefinition":
329329
dest_file = (

0 commit comments

Comments
 (0)