-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually ensuring nothing was missed gamma to main
- Loading branch information
1 parent
c5b5c96
commit 3d4dc9f
Showing
6 changed files
with
270 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# STEPS: | ||
# Caveat: Run these commands from a FBC overlay (ex: v4.14) | ||
# 1. run the container: FBC_VERSION="v4.14" && CONTAINER_ID=$(docker run -u root -d registry.redhat.io/redhat/redhat-operator-index:$FBC_VERSION) | ||
# 2. copy the catalog file in: docker cp $(pwd)/catalog/rhtas-operator/catalog.json $CONTAINER_ID:/configs/rhtas-operator/catalog.json | ||
# 3. re-serve: docker exec -u root -it $CONTAINER_ID opm serve --pprof-addr="" --cache-only /configs | ||
# 4. commit the image: docker commit $CONTAINER_ID quay.io/grpereir/redhat-operator-index:$FBC_VERSION | ||
# 5 push the image: docker push quay.io/grpereir/redhat-operator-index:$FBC_VERSION | ||
# NOTE: if you are using your own repo, you will have to switch this to public so it is pullable by testing cluster | ||
# 6. create catalog source (see below): | ||
: ' | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: CatalogSource | ||
metadata: | ||
name: rhtas-operator | ||
namespace: openshift-marketplace | ||
spec: | ||
sourceType: grpc | ||
grpcPodConfig: | ||
securityContextConfig: legacy | ||
publisher: Red Hat | ||
image: quay.io/grpereir/redhat-operator-index:$FBC_VERSION | ||
displayName: TAS Operator | ||
' | ||
# 7. apply the CS: oc apply -f ./catalogSource.yaml | ||
# 8. delete the catalog-operator pod: CATALOG_OPERATOR_POD=$oc get pods -n openshift-operator-lifecycle-manager | grep catalog-operator | awk '{print $1}') && oc delete pod $CATALOG_OPERATOR_POD -n openshift-operator-lifecycle-manage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SKOPEO_CMD=${SKOPEO_CMD:-skopeo} | ||
OPM_CMD=${OPM_CMD:-opm} | ||
AUTH_FILE=${AUTH_FILE:-} | ||
|
||
package_name="rhtas-operator" | ||
|
||
helpFunction() | ||
{ | ||
echo -e "Usage: $0\n" | ||
echo -e "\t--help: see all commands of this script\n" | ||
echo -e "\t--init-basic <OCP_minor> <yq|jq>: initialize a new composite fragment\n\t example: $0 --init-basic v4.13 yq\n" | ||
echo -e "\t--init-basic-all: initialize all the fragments from production\n\t example: $0 --init-basic-all\n" | ||
echo -e "\t--comment-graph <OCP_minor>: add human readable bundle tags as comments to graph generated by --init-basic\n\t example: $0 --comment-graph v4.13\n" | ||
echo -e "\t--render <OCP_minor> <brew>: render one FBC fragment\n\t\"brew\" optional parameter will made it consuming bundle images from the brew registry\n\t example: $0 --render v4.13 brew\n" | ||
echo -e "\t--render-all <brew>: render all the FBC fragments\n\t\"brew\" optional parameter will made it consuming bundle images from the brew registry\n\t example: $0 --render-all brew\n" | ||
exit 1 | ||
} | ||
|
||
devfile() | ||
{ | ||
cat <<EOT > "$1"/devfile.yaml | ||
schemaVersion: 2.2.0 | ||
metadata: | ||
name: fbc-$1 | ||
displayName: FBC $1 | ||
description: 'File based catalog' | ||
language: fbc | ||
provider: Red Hat | ||
components: | ||
- name: image-build | ||
image: | ||
imageName: "" | ||
dockerfile: | ||
uri: catalog.Dockerfile | ||
buildContext: "" | ||
- name: kubernetes | ||
kubernetes: | ||
inlined: placeholder | ||
attributes: | ||
deployment/container-port: 50051 | ||
deployment/cpuRequest: "100m" | ||
deployment/memoryRequest: 512Mi | ||
deployment/replicas: 1 | ||
deployment/storageRequest: "0" | ||
commands: | ||
- id: build-image | ||
apply: | ||
component: image-build | ||
EOT | ||
} | ||
|
||
dockerfile() | ||
{ | ||
cat <<EOT > "$1"/catalog.Dockerfile | ||
# The base image is expected to contain | ||
# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe | ||
FROM registry.redhat.io/openshift4/ose-operator-registry:$1 | ||
ENTRYPOINT ["/bin/opm"] | ||
CMD ["serve", "/configs", "--cache-dir=/tmp/cache"] | ||
add catalog /configs | ||
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"] | ||
# 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=rhtas-operator | ||
LABEL operators.operatorframework.io.bundle.channels.v1=alpha | ||
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.32.0 | ||
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1 | ||
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 | ||
LABEL operators.operatorframework.io.index.configs.v1=/configs | ||
EOT | ||
} | ||
|
||
setBrew() | ||
{ | ||
if [[ "$2" == "brew" ]]; then | ||
sed -i 's|image: registry.redhat.ioregistry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator|image: brew.registry.redhat.ioregistry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator|g' "${frag}"/graph.yaml | ||
fi | ||
} | ||
|
||
unsetBrew() | ||
{ | ||
if [[ "$2" == "brew" ]]; then | ||
sed -i 's|image: brew.registry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator|image: registry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator|g' "${frag}"/graph.yaml | ||
sed -i 's|brew.registry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator|registry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator|g' "${frag}"/catalog/rhtas-operator/catalog.json | ||
fi | ||
} | ||
|
||
|
||
cmd="$1" | ||
case $cmd in | ||
"--help") | ||
helpFunction | ||
;; | ||
"--init-basic") | ||
frag=$2 | ||
if [ -z "$frag" ] | ||
then | ||
echo "Please specify OCP minor, eg: v4.12" | ||
exit 1 | ||
fi | ||
FROMV=$(grep FROM "${frag}"/catalog.Dockerfile) | ||
OCPV=${FROMV##*:} | ||
from=registry.redhat.io/redhat/redhat-operator-index:${OCPV} | ||
yqOrjq=$3 | ||
mkdir -p "${frag}/catalog/rhtas-operator/" "${frag}/${frag}" | ||
touch "${frag}/${frag}/.empty" | ||
case $yqOrjq in | ||
"yq") | ||
touch "${frag}"/graph.yaml | ||
echo opm render $from -o yaml | ||
"${OPM_CMD}" render "$from" -o yaml | yq "select( .package == \"$package_name\" or .name == \"$package_name\")" | yq 'select(.schema == "olm.bundle") = {"schema": .schema, "image": .image}' | yq 'select(.schema == "olm.package") = {"schema": .schema, "name": .name, "defaultChannel": .defaultChannel}' > "${frag}"/graph.yaml | ||
;; | ||
"jq") | ||
"${OPM_CMD}" render "$from" | jq "select( .package == \"$package_name\" or .name == \"$package_name\")" | jq 'if (.schema == "olm.bundle") then {schema: .schema, image: .image} else (if (.schema == "olm.package") then {schema: .schema, name: .name, defaultChannel: .defaultChannel} else . end) end' > "${frag}"/graph.json | ||
;; | ||
*) | ||
echo "please specify if yq or jq" | ||
exit 1 | ||
;; | ||
esac | ||
devfile "$frag" | ||
dockerfile "$frag" | ||
;; | ||
"--init-basic-all") | ||
for f in ./"v4."*; do | ||
frag=${f#./} | ||
$0 --init-basic "${frag}" yq | ||
$0 --comment-graph "${frag}" | ||
done | ||
;; | ||
"--render") | ||
frag=$2 | ||
if [ -z "$frag" ] | ||
then | ||
echo "Please specify OCP minor, eg: v4.12" | ||
exit 1 | ||
fi | ||
setBrew "${frag}" "$3" | ||
"${OPM_CMD}" alpha render-template basic "${frag}"/graph.yaml > "${frag}"/catalog/rhtas-operator/catalog.json | ||
unsetBrew "${frag}" "$3" | ||
;; | ||
"--render-all") | ||
for f in ./"v4."*; do | ||
frag=${f#./} | ||
setBrew "${frag}" "$2" | ||
"${OPM_CMD}" alpha render-template basic "${frag}"/graph.yaml > "${frag}"/catalog/rhtas-operator/catalog.json | ||
unsetBrew "${frag}" "$2" | ||
done | ||
;; | ||
"--comment-graph") | ||
frag=$2 | ||
if [ -z "$frag" ] | ||
then | ||
echo "Please specify OCP minor, eg: v4.12" | ||
exit 1 | ||
fi | ||
setBrew "${frag}" "$3" | ||
sed -i "/# hco-bundle-registry v4\./d" "$frag"/graph.yaml | ||
grep -E "^image: [brew\.]*registry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator[-rhel9]*@sha256" "$frag"/graph.yaml | while read -r line ; do | ||
image=${line/image: /} | ||
echo "Processing $image" | ||
# shellcheck disable=SC2086 | ||
url=$(${SKOPEO_CMD} inspect --no-tags ${AUTH_FILE} docker://"$image" | grep "\"url\": ") | ||
tag1=${url/*\/images\/} | ||
tag=${tag1/\",/} | ||
sed -i "s|$image|$image\n# hco-bundle-registry $tag|g" "$frag"/graph.yaml | ||
done | ||
unsetBrew "${frag}" "$3" | ||
;; | ||
"--comment-graph-all") | ||
for f in ./"v4."*; do | ||
frag=${f#./} | ||
setBrew "${frag}" "$2" | ||
sed -i "/# hco-bundle-registry v4\./d" "$frag"/graph.yaml | ||
grep -E "^image: [brew\.]*registry.redhat.io/rhtas-tech-preview/sigstore-rhel9-operator[-rhel9]*@sha256" "$frag"/graph.yaml | while read -r line ; do | ||
image=${line/image: /} | ||
echo "Processing $image" | ||
# shellcheck disable=SC2086 | ||
url=$(${SKOPEO_CMD} inspect --no-tags ${AUTH_FILE} docker://"$image" | grep "\"url\": ") | ||
tag1=${url/*\/images\/} | ||
tag=${tag1/\",/} | ||
sed -i "s|$image|$image\n# hco-bundle-registry $tag|g" "$frag"/graph.yaml | ||
done | ||
unsetBrew "${frag}" "$2" | ||
done | ||
;; | ||
*) | ||
echo "$cmd not one of the allowed flags" | ||
helpFunction | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters