crddiff: Look up version by name, not array index #226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of your changes
When crddiff looked for a specific api version, it checked the new CRD
using array indexing. This fails for example when checking crossplane
1.16 to 1.17, where 1.16 has [v1beta1] and 1.17 has [v1, v1beta1]:
go run ./cmd/crddiff/ revision crossplane-1.16/cluster/crds/pkg.crossplane.io_functions.yaml crossplane-1.17/cluster/crds/pkg.crossplane.io_functions.yaml
crddiff: error: Failed to compute CRD breaking API changes: revision has no corresponding version to compare with the base for the version name: v1beta1
This does not fix a specific issue but makes itmore usable to compare
different versions of CRDs for provider and core crossplane releases.
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
Unit test and against 1.16 -> 1.17 crossplane CRD diff.