@@ -11,7 +11,13 @@ bundle_directory="bundles/${DISTRIBUTION}"
11
11
project_directory=" projects/${DISTRIBUTION} "
12
12
go_api_directory=$( cd ../../pkg/apis && pwd)
13
13
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.
14
16
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'
15
21
case " ${DISTRIBUTION} " in
16
22
# https://redhat-connect.gitbook.io/certified-operator-guide/appendix/what-if-ive-already-published-a-community-operator
17
23
' redhat' ) package_name=' crunchy-postgres-operator' ;;
@@ -30,7 +36,7 @@ operator_roles=$(yq <<< "${operator_yamls}" --slurp --yaml-roundtrip 'map(select
30
36
install -d " ${project_directory} "
31
37
(
32
38
cd " ${project_directory} "
33
- operator-sdk init --fetch-deps=' false' --project-name=' postgresoperator '
39
+ operator-sdk init --fetch-deps=' false' --project-name=${project_name}
34
40
rm ./* .go go.*
35
41
36
42
# Generate CRD descriptions from Go markers.
@@ -61,11 +67,25 @@ kubectl kustomize "${project_directory}/config/scorecard" \
61
67
> " ${bundle_directory} /tests/scorecard/config.yaml"
62
68
63
69
# 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
64
74
yq --yaml-roundtrip < bundle.annotations.yaml > " ${bundle_directory} /metadata/annotations.yaml" \
65
75
--arg package " ${package_name} " \
66
76
'
67
77
.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" |
68
81
.'
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
69
89
70
90
# Copy annotations into Dockerfile LABELs.
71
91
labels=$( yq --raw-output < " ${bundle_directory} /metadata/annotations.yaml" \
@@ -94,8 +114,17 @@ yq > /dev/null <<< "${operator_roles}" --exit-status 'length == 1' ||
94
114
# Render bundle CSV and strip comments.
95
115
96
116
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
+
97
126
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" )
99
128
100
129
crd_gvks=$( yq <<< " ${operator_crds}" ' map({
101
130
group: .spec.group, kind: .spec.names.kind, version: .spec.versions[].name
@@ -141,6 +170,10 @@ case "${DISTRIBUTION}" in
141
170
.metadata.annotations.certified = "true" |
142
171
.' \
143
172
" ${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"
144
177
;;
145
178
' marketplace' )
146
179
# Annotations needed when targeting Red Hat Marketplace
@@ -154,6 +187,10 @@ case "${DISTRIBUTION}" in
154
187
"\($package_url)/support?utm_source=openshift_console" |
155
188
.' \
156
189
" ${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"
157
194
;;
158
195
esac
159
196
0 commit comments