Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: operator-framework/operator-registry
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 220ec6a67b53825711e187ade15eaafce6f6cc3f
Choose a base ref
..
head repository: operator-framework/operator-registry
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a98ec3c78808849cef63d6e068f77f423509a33c
Choose a head ref
Showing with 12 additions and 10 deletions.
  1. +12 −10 pkg/registry/bundle.go
22 changes: 12 additions & 10 deletions pkg/registry/bundle.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package registry

import (
"encoding/json"
"fmt"
"strings"

"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
@@ -35,7 +33,7 @@ type Bundle struct {
Package string
Channel string
csv *ClusterServiceVersion
crds []*apiextensions.CustomResourceDefinition
crds []*v1beta1.CustomResourceDefinition
cacheStale bool
}

@@ -76,7 +74,7 @@ func (b *Bundle) ClusterServiceVersion() (*ClusterServiceVersion, error) {
return b.csv, nil
}

func (b *Bundle) CustomResourceDefinitions() ([]*apiextensions.CustomResourceDefinition, error) {
func (b *Bundle) CustomResourceDefinitions() ([]*v1beta1.CustomResourceDefinition, error) {
if err := b.cache(); err != nil {
return nil, err
}
@@ -104,6 +102,9 @@ func (b *Bundle) ProvidedAPIs() (map[APIKey]struct{}, error) {
}

ownedAPIs, _, err := csv.GetApiServiceDefinitions()
if err != nil {
return nil, err
}
for _, api := range ownedAPIs {
provided[APIKey{Group: api.Group, Version: api.Version, Kind: api.Kind, Plural: api.Name}] = struct{}{}
}
@@ -210,19 +211,20 @@ func (b *Bundle) cache() error {
}

if b.crds == nil {
b.crds = []*apiextensions.CustomResourceDefinition{}
b.crds = []*v1beta1.CustomResourceDefinition{}
}
for _, o := range b.Objects {
if o.GetObjectKind().GroupVersionKind().Kind == "CustomResourceDefinition" {
crd := &apiextensions.CustomResourceDefinition{}
// Marshal Unstructured and Unmarshal as CustomResourceDefinition. FromUnstructured has issues
crd := &v1beta1.CustomResourceDefinition{}
// Marshal Unstructured and Decode as CustomResourceDefinition. FromUnstructured has issues
// converting JSON numbers to float64 for CRD minimum/maximum validation.
bytes, err := o.MarshalJSON()
cb, err := o.MarshalJSON()
if err != nil {
return err
}
if err := json.Unmarshal(bytes, &crd); err != nil {
return err
dec := serializer.NewCodecFactory(Scheme).UniversalDeserializer()
if _, _, err = dec.Decode(cb, nil, crd); err != nil {
return fmt.Errorf("error decoding CRD: %v", err)
}
b.crds = append(b.crds, crd)
}