-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDCICD-1358: custom task to get OLM bundle version #1255
Conversation
328bc5e
to
b01072e
Compare
/ok-to-test |
| sed -n '/"type": "olm.package"/,/}/p' \ | ||
| sed -n 's/.*"version": "\(.*\)".*/\1/p' \ | ||
| tr -d '\n' \ | ||
> "$(results.bundle-version.path)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems rather fragile, e.g. it wouldn't work if the JSON was printed compactly or if the order of the keys was different
{
"value": {
"packageName": "osd-example-operator",
"version": "4.16.0-28f1940"
},
"type": "olm.package"
}
Is there reason to believe that opm
would always format the output in a way that will work with this sed command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We control the way opm is ran (with json output), and we aren't receiving arbitrarily formatted JSON, I would assume this to be pretty stable. I don't think there is a way to print the json compactly through opm render, the only other output option being YAML through the --output=yaml
flag. I would have preferred to use JQ but I can't find an image with both opm and jq in it. Your suggestion below for using JQ is a great improvement I can follow up with.
The order of the keys shouldn't matter, we search for the olm.package
object, then the value inside of that.
This also shouldn't really be used outside of our specific use case which is stringing together the custom tasks/pipelines so far which we control the inputs to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order of the keys shouldn't matter
Would only matter if value
came before type
as in my example. That does seem unlikely though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use your two step recommendation! PTAL when you have a minute, thank you!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if the potential shortcomings work for you. Alternatively, could save the output of opm render
in a shared directory and extract the version in the next step with jq
(using an image that has jq
installed, e.g. quay.io/konflux-ci/appstudio-utils:ab6b0b8e40e440158e7288c73aff1cf83a2cc8a9@sha256:24179f0efd06c65d16868c2d7eb82573cce8e43533de6cea14fec3b7446e0b14
)
this is needed to string together the dynamic bundle generation task to the catalog generation task. The bundle ref is stored as a param in the catalog pipeline (nudged), we need to fetch the version that was put in the bundle to add an entry into the catalog with it. ``` ❯ opm render ${BUNDLE_IMAGE} { "schema": "olm.bundle", "name": "osd-example-operator.v4.16.0-28f1940", "package": "osd-example-operator", "image": "quay.io/redhat-user-workloads/oeo-cicada-tenant/osd-example-operator/bundle@sha256:5485652c17ab8ac5cf44452f67e15ed06dc9d2d7d67a7f079e76248878d5370e", "properties": [ { "type": "olm.gvk", "value": { "group": "managed.openshift.io", "kind": "Example", "version": "v1alpha1" } }, { "type": "olm.package", "value": { "packageName": "osd-example-operator", "version": "4.16.0-28f1940" } }, ... ❯ opm render ${BUNDLE_IMAGE} \ | sed -n '/"type": "olm.package"/,/}/p' \ | sed -n 's/.*"version": "\(.*\)".*/\1/p' | tr -d '\n' 4.16.0-28f1940 ``` https://github.com/openshift/osd-example-operator/blob/971083313e7eb4c7383c04a2067ac80ae535946c/.tekton/catalog-push.yaml#L176-L211 https://issues.redhat.com/browse/SDCICD-1358 Signed-off-by: Brady Pratt <[email protected]>
I think the |
/retest |
/retest @MartinBasti 👀 do you understand the CI failure? I'm not able to see the pipeline logs |
/retest |
Hey @MartinBasti, are you able to add this to the merge queue? |
this is needed to string together the dynamic bundle generation task to
the catalog generation task. The bundle ref is stored as a param in the
catalog pipeline (nudged), we need to fetch the version that was put in
the bundle to add an entry into the catalog with it.
https://github.com/openshift/osd-example-operator/blob/971083313e7eb4c7383c04a2067ac80ae535946c/.tekton/catalog-push.yaml#L176-L211
https://issues.redhat.com/browse/SDCICD-1358
Example pipeline
Pipeline output
Signed-off-by: Brady Pratt [email protected]