Skip to content

internal/pkg/scaffold/olm-catalog/csv_updaters.go: fix applying owned CRDs #2017

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- In the Helm operator, skip owner reference injection for cluster-scoped resources in release manifests. The Helm operator only supports namespace-scoped CRs, and namespaced resources cannot own cluster-scoped resources. ([#1817](https://github.com/operator-framework/operator-sdk/pull/1817))
- Package manifests generated with [`gen-csv`](https://github.com/operator-framework/operator-sdk/blob/master/doc/sdk-cli-reference.md#gen-csv) respect the `--operator-name` flag, channel names are checked for duplicates before (re-)generation. ([#1693](https://github.com/operator-framework/operator-sdk/pull/1693))
- Generated inventory for Ansible-based Operators now sets the localhost's `ansible_python_interpreter` to `{{ ansible_playbook_python }}`, to properly match the [implicit localhost](https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html). ([#1952](https://github.com/operator-framework/operator-sdk/pull/1952))
- Fixed an issue in `operator-sdk olm-catalog gen-csv` where the generated CSV is missing the expected set of owned CRDs. ([#2017](https://github.com/operator-framework/operator-sdk/pull/2017))

## v0.10.0

Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/scaffold/olm-catalog/csv_updaters.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ func getGVKID(g, v, k string) string {
// the CRD key is not in spec.customresourcedefinitions.owned already.
func (u *CustomResourceDefinitionsUpdate) Apply(csv *olmapiv1alpha1.ClusterServiceVersion) error {
set := make(map[string]olmapiv1alpha1.CRDDescription)
for _, uDesc := range u.Owned {
set[crdDescID(uDesc)] = uDesc
for _, csvDesc := range csv.Spec.CustomResourceDefinitions.Owned {
set[crdDescID(csvDesc)] = csvDesc
}
newDescs := []olmapiv1alpha1.CRDDescription{}
for _, csvDesc := range csv.Spec.CustomResourceDefinitions.Owned {
if uDesc, ok := set[crdDescID(csvDesc)]; !ok {
for _, uDesc := range u.Owned {
if csvDesc, ok := set[crdDescID(uDesc)]; !ok {
newDescs = append(newDescs, uDesc)
} else {
newDescs = append(newDescs, csvDesc)
Expand Down