Skip to content

Commit a68002e

Browse files
authored
Use image sha for sample image (#465)
The RedHat certification requires that images are referenced by sha. Add a sha for the sample image, and also add a script to update the sha when 'make bundle' is run
1 parent 85a7fdb commit a68002e

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
177177

178178
.PHONY: bundle
179179
bundle: manifests setup kustomize ## Generate bundle manifests and metadata, then validate generated files.
180+
scripts/update-sample.sh
180181
sed -i.bak "s,IMAGE,${IMG},g;s,CREATEDAT,${CREATEDAT},g" config/manifests/patches/csvAnnotations.yaml
181182
operator-sdk generate kustomize manifests -q
182183
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
@@ -336,4 +337,4 @@ catalog-push: ## Push a catalog image.
336337
$(MAKE) docker-push IMG=$(CATALOG_IMG)
337338

338339
dev:
339-
./scripts/dev.sh all
340+
./scripts/dev.sh all

bundle/manifests/runtime-component.clusterserviceversion.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
"name": "runtimecomponent-sample"
1212
},
1313
"spec": {
14-
"applicationImage": "icr.io/appcafe/open-liberty/samples/getting-started",
14+
"applicationImage": "icr.io/appcafe/open-liberty/samples/getting-started@sha256:60ca13dd15d5dd583a594436d3568fc69fc7a58081dc40885dc4d2b16a6e4c69",
1515
"expose": true,
1616
"replicas": 1,
1717
"service": {
@@ -67,7 +67,7 @@ metadata:
6767
categories: Application Runtime
6868
certified: "true"
6969
containerImage: applicationstacks/operator:daily
70-
createdAt: "2023-03-01T12:55:30Z"
70+
createdAt: "2023-03-09T10:51:34Z"
7171
description: Deploys any runtime component with dynamic and auto-tuning configuration
7272
operators.operatorframework.io/builder: operator-sdk-v1.24.0
7373
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

config/samples/rc.app.stacks_v1_runtimecomponent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: runtimecomponent-sample
55
spec:
66
# Add fields here
7-
applicationImage: icr.io/appcafe/open-liberty/samples/getting-started
7+
applicationImage: icr.io/appcafe/open-liberty/samples/getting-started@sha256:60ca13dd15d5dd583a594436d3568fc69fc7a58081dc40885dc4d2b16a6e4c69
88
expose: true
99
replicas: 1
1010
service:

scripts/update-sample.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# This script fetches the sha256 for the latest version of the open liberty getting started container
4+
# image, and then edits the sample deployment and the csv for the operator, and inserts the tag
5+
6+
if ! skopeo -v ; then
7+
echo "Skopeo is not installed. Sample sha will not be updated"
8+
exit
9+
fi
10+
11+
echo "Editing sample tag"
12+
SHA=$(skopeo inspect docker://icr.io/appcafe/open-liberty/samples/getting-started:latest | jq '.Digest'| sed -e 's/"//g')
13+
if [ -z $SHA ]
14+
then
15+
echo "Couldn't find latest SHA for sample image"
16+
exit
17+
fi
18+
19+
echo "sha is $SHA"
20+
21+
files="
22+
config/samples/rc.app.stacks_v1_runtimecomponent.yaml
23+
"
24+
25+
for file in $files
26+
do
27+
sed -i.bak "s,getting-started@sha256:[a-zA-Z0-9]*,getting-started@$SHA," $file
28+
rm $file.bak
29+
done
30+

0 commit comments

Comments
 (0)