-
Notifications
You must be signed in to change notification settings - Fork 718
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
Deprecate providesGVR flag and update validate script #620
Deprecate providesGVR flag and update validate script #620
Conversation
scripts/validate
Outdated
providesGVR="$(cat ${f}/package.yaml | yq r - providesGVR)" | ||
if [[ -n ${providesGVR} && -f ${f}/charts/Chart.yaml ]]; then | ||
if [[ "$(yq r ${f}/charts/Chart.yaml 'annotations[catalog.cattle.io/provides-gvr]')" == "${providesGVR}" ]]; then | ||
yq d -i ${f}/charts/Chart.yaml "annotations[catalog.cattle.io/provides-gvr]" |
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.
@mrajashree I pulled out your local changes into my fork and tested this out and it seems to be passing validate on your script as expected... with one exception. I had to make a tiny change to your chart in this commit: aiyengar2@e152e52.
The technical reason why this change is required is because yq
doesn't support preserving the formatting with in place writing (based on mikefarah/yq#465), so changes like yq d -i
or yq w -i
sprinkled throughout our codebase essentially reformat your Chart.yaml
's formatting to a standard YAML format.
Specifically, this causes an issue in the validate
script since it checks to see if your Git is dirty when performing the validate (i.e. you have changes that have not been committed to your patch or directly to your chart). Since you saved your Chart.yaml
with a different format than what the output of yq [d/w] -i ${f}/charts/Chart.yaml
would have generated, the validate will always fail since it will always assume your git is dirty.
TLDR, if you see an issue with the make validate, just make sure the Chart.yaml
's output matches the output provided by yq r ${f}/charts/Chart.yaml
, where f=packages/backup-restore-operator
or something similar, and run make validate
once more.
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.
yup I'd noticed that too, tested my commit with this PR and the ci works fine 👍
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.
@aiyengar2 If yq is going to be changing formatting of files then failing a build this needs to be more obvious, and we need to include formatting as part of the make steps a dev will run locally similar to go-fmt so anyone will be compliant.
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.
Easy solution is just to remove these from package.yaml altogether and just manually put in the patch file. The dual way was too confusing. Since its disconnected from the CRD generation and pushed onto parent it doesn't make sense in package.yaml anymore and will greatly simplify scripts.
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.
@dramich the new last commit on the PR bf9a622 ensures that yq won't break the build. @mrajashree with the last commit, you should no longer need to make the Chart.yaml
change to get your chart to pass CI.
I tried adding formatting as part of the make validate instead, but it seems like there are discrepancies between the style yq r
gives on the machine that runs our tests vs. the local dev environment (i.e. make validate
with some Chart.yaml
s that I changed to correctly format on my machine failed on the test machine since it expected a slightly different style, such as no spaces on list entries, breaks between big lines, etc.), so unless we somehow standardize the yq style across both environment, a make validate-fmt
-type script will be difficult to create. Imo we should avoid making those types of changes in this PR though since this is blocking CIS / backup-restore-operator CI. We can address this when we switch to using Go scripts after 2.5.
re: @cbron's comments, I agree that providesGVR
should be removed from the package.yaml to simplify the scripts, but I think we still need to modify the Chart.yaml for auto-install
annotations for CRD charts.
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 talked about this offline and to simplify things we are just removing all the providesGVR and git update-index
stuff. Scripts has to stay small and simple until we rewrite. The downside is that validate might fail for original charts on chart.yaml formatting, we can make a separate make command for that later, but right now its a nice-to-have.
4b11820
to
9f0383a
Compare
8e79ff4
to
49eda64
Compare
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
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.
Even if approved don't merge this until after 10am PST.
scripts/validate
Outdated
providesGVR="$(cat ${f}/package.yaml | yq r - providesGVR)" | ||
if [[ -n ${providesGVR} && -f ${f}/charts/Chart.yaml ]]; then | ||
if [[ "$(yq r ${f}/charts/Chart.yaml 'annotations[catalog.cattle.io/provides-gvr]')" == "${providesGVR}" ]]; then | ||
yq d -i ${f}/charts/Chart.yaml "annotations[catalog.cattle.io/provides-gvr]" |
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.
Easy solution is just to remove these from package.yaml altogether and just manually put in the patch file. The dual way was too confusing. Since its disconnected from the CRD generation and pushed onto parent it doesn't make sense in package.yaml anymore and will greatly simplify scripts.
34f65c7
to
cb5e5f1
Compare
94cfbe5
to
bf9a622
Compare
bf9a622
to
e9d6a4c
Compare
Before, the logic for reverting a CRD chart was located in `generate-patch` since it was the only script that required these changes. Now that the same logic is required on a `make clean` in order to support reverting just the generateCRDChart changes from local charts, this commit moves that logic out to its own script `clean-crds`. Based on discussion in rancher#607 (comment).
ecf8e46
to
df0cbe7
Compare
This commit deprecates the providesGVR flag used by charts in favor of charts adding this annotation directly to the patch of their chart (or their Chart.yaml).
By utilizing the `clean-crds` script, both `validate` and `clean` can cleanly deal with issues related to annotations added and files overlaid as part of the CRD chart process.
df0cbe7
to
b3f18ae
Compare
Chart changes for deprecated |
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, merging this will break the provides->requires dependency but then 624 will fix them again, so we will merge in succession.
The formatting issue will be a known issue with original charts, both current chart owners know and we'll have fix in next edition.
This PR deprecates the provideGVR flag and updates the validate script to unblock CI issues for local charts that use the generateCRDChart flag.
Related to build failures in #594