Skip to content

Commit 788a34e

Browse files
committed
OLM installer bundle generation updates
This commit fixes the filenames of the ClusterServiceVersion files, removes the 'org.opencontainers' annotations for both the 'redhat' and 'marketplace' OLM installers and adds the required 'relatedImages' for the 'marketplace' installer. Issue: [sc-13923]
1 parent a710277 commit 788a34e

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
lines changed

installers/olm/bundle.annotations.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,4 @@ annotations:
3535
com.redhat.delivery.operator.bundle: true
3636
com.redhat.openshift.versions: 'v4.6-v4.9'
3737

38-
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
39-
org.opencontainers.image.authors: info@crunchydata.com
40-
org.opencontainers.image.url: https://crunchydata.com
41-
org.opencontainers.image.vendor: Crunchy Data
4238
...
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
relatedImages:
2+
- name: PGBACKREST
3+
image: registry.connect.redhat.com/crunchydata/crunchy-pgbackrest@sha256:<update_SHA_value>
4+
- name: PGBOUNCER
5+
image: registry.connect.redhat.com/crunchydata/crunchy-pgbouncer@sha256:<update_SHA_value>
6+
- name: PGEXPORTER
7+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres-exporter@sha256:<update_SHA_value>
8+
- name: POSTGRES_12
9+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres@sha256:<update_SHA_value>
10+
- name: POSTGRES_13
11+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres@sha256:<update_SHA_value>
12+
- name: POSTGRES_14
13+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres@sha256:<update_SHA_value>
14+
- name: POSTGRES_12_GIS_2.5
15+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres-gis@sha256:<update_SHA_value>
16+
- name: POSTGRES_12_GIS_3.0
17+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres-gis@sha256:<update_SHA_value>
18+
- name: POSTGRES_13_GIS_3.0
19+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres-gis@sha256:<update_SHA_value>
20+
- name: POSTGRES_13_GIS_3.1
21+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres-gis@sha256:<update_SHA_value>
22+
- name: POSTGRES_14_GIS_3.1
23+
image: registry.connect.redhat.com/crunchydata/crunchy-postgres-gis@sha256:<update_SHA_value>
24+
- name: postgres-operator
25+
image: registry.connect.redhat.com/crunchydata/postgres-operator@sha256:<update_SHA_value>

installers/olm/generate.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ bundle_directory="bundles/${DISTRIBUTION}"
1111
project_directory="projects/${DISTRIBUTION}"
1212
go_api_directory=$(cd ../../pkg/apis && pwd)
1313

14+
# TODO(tjmoore4): package_name and project_name are kept separate to maintain
15+
# expected names in all projects. This could be consolidated in the future.
1416
package_name='postgresql'
17+
# Per OLM guidance, the filename for the clusterserviceversion.yaml must be prefixed
18+
# with the Operator's package name for the 'redhat' and 'marketplace' bundles.
19+
# https://github.com/redhat-openshift-ecosystem/certification-releases/blob/main/4.9/ga/troubleshooting.md#get-supported-versions
20+
project_name='postgresoperator'
1521
case "${DISTRIBUTION}" in
1622
# https://redhat-connect.gitbook.io/certified-operator-guide/appendix/what-if-ive-already-published-a-community-operator
1723
'redhat') package_name='crunchy-postgres-operator' ;;
@@ -30,7 +36,7 @@ operator_roles=$(yq <<< "${operator_yamls}" --slurp --yaml-roundtrip 'map(select
3036
install -d "${project_directory}"
3137
(
3238
cd "${project_directory}"
33-
operator-sdk init --fetch-deps='false' --project-name='postgresoperator'
39+
operator-sdk init --fetch-deps='false' --project-name=${project_name}
3440
rm ./*.go go.*
3541

3642
# Generate CRD descriptions from Go markers.
@@ -61,11 +67,25 @@ kubectl kustomize "${project_directory}/config/scorecard" \
6167
> "${bundle_directory}/tests/scorecard/config.yaml"
6268

6369
# Render bundle annotations and strip comments.
70+
# Per Red Hat we should not include the org.opencontainers annotations in the
71+
# 'redhat' & 'marketplace' annotations.yaml file, so only add them for 'community'.
72+
# - https://coreos.slack.com/team/UP1LZCC1Y
73+
if [ ${DISTRIBUTION} == 'community' ]; then
6474
yq --yaml-roundtrip < bundle.annotations.yaml > "${bundle_directory}/metadata/annotations.yaml" \
6575
--arg package "${package_name}" \
6676
'
6777
.annotations["operators.operatorframework.io.bundle.package.v1"] = $package |
78+
.annotations["org.opencontainers.image.authors"] = "info@crunchydata.com" |
79+
.annotations["org.opencontainers.image.url"] = "https://crunchydata.com" |
80+
.annotations["org.opencontainers.image.vendor"] = "Crunchy Data" |
6881
.'
82+
else
83+
yq --yaml-roundtrip < bundle.annotations.yaml > "${bundle_directory}/metadata/annotations.yaml" \
84+
--arg package "${package_name}" \
85+
'
86+
.annotations["operators.operatorframework.io.bundle.package.v1"] = $package |
87+
.'
88+
fi
6989

7090
# Copy annotations into Dockerfile LABELs.
7191
labels=$(yq --raw-output < "${bundle_directory}/metadata/annotations.yaml" \
@@ -94,8 +114,17 @@ yq > /dev/null <<< "${operator_roles}" --exit-status 'length == 1' ||
94114
# Render bundle CSV and strip comments.
95115

96116
csv_stem=$(yq --raw-output '.projectName' "${project_directory}/PROJECT")
117+
118+
# marketplace and redhat require different naming patters than community
119+
if [ ${DISTRIBUTION} == 'marketplace' ] || [ ${DISTRIBUTION} == 'redhat' ]; then
120+
mv "${project_directory}/config/manifests/bases/${project_name}.clusterserviceversion.yaml" \
121+
"${project_directory}/config/manifests/bases/${package_name}.clusterserviceversion.yaml"
122+
123+
csv_stem=${package_name}
124+
fi
125+
97126
crd_descriptions=$(yq '.spec.customresourcedefinitions.owned' \
98-
"${project_directory}/config/manifests/bases/${csv_stem}.clusterserviceversion.yaml")
127+
"${project_directory}/config/manifests/bases/${csv_stem}.clusterserviceversion.yaml")
99128

100129
crd_gvks=$(yq <<< "${operator_crds}" 'map({
101130
group: .spec.group, kind: .spec.names.kind, version: .spec.versions[].name
@@ -141,6 +170,10 @@ case "${DISTRIBUTION}" in
141170
.metadata.annotations.certified = "true" |
142171
.' \
143172
"${bundle_directory}/manifests/${csv_stem}.clusterserviceversion.yaml"
173+
174+
# Finally, add related images. NOTE: SHA values will need to be updated
175+
# -https://github.com/redhat-openshift-ecosystem/certification-releases/blob/main/4.9/ga/troubleshooting.md#digest-pinning
176+
cat bundle.relatedImages.yaml >> "${bundle_directory}/manifests/${csv_stem}.clusterserviceversion.yaml"
144177
;;
145178
'marketplace')
146179
# Annotations needed when targeting Red Hat Marketplace
@@ -154,6 +187,10 @@ case "${DISTRIBUTION}" in
154187
"\($package_url)/support?utm_source=openshift_console" |
155188
.' \
156189
"${bundle_directory}/manifests/${csv_stem}.clusterserviceversion.yaml"
190+
191+
# Finally, add related images. NOTE: SHA values will need to be updated
192+
# -https://github.com/redhat-openshift-ecosystem/certification-releases/blob/main/4.9/ga/troubleshooting.md#digest-pinning
193+
cat bundle.relatedImages.yaml >> "${bundle_directory}/manifests/${csv_stem}.clusterserviceversion.yaml"
157194
;;
158195
esac
159196

0 commit comments

Comments
 (0)