Skip to content

Commit

Permalink
fix: Rename Catalog to ClusterCatalog object
Browse files Browse the repository at this point in the history
Rename Catalog to ClusterCatalog to conform with the changes in catalogd. See [issue operator-framework#268](operator-framework/catalogd/pull/268)

Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
  • Loading branch information
OchiengEd committed Jun 13, 2024
1 parent bd6866f commit 5479625
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion config/samples/catalogd_operatorcatalog.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
kind: ClusterCatalog
metadata:
name: operatorhubio
spec:
Expand Down
4 changes: 2 additions & 2 deletions docs/Tasks/adding-a-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This catalog is distributed as an image [quay.io/operatorhubio/catalog](https://

``` yaml title="catalog_cr.yaml"
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
kind: ClusterCatalog
metadata:
name: operatorhubio
spec:
Expand All @@ -44,7 +44,7 @@ This catalog is distributed as an image [quay.io/operatorhubio/catalog](https://

``` yaml title="Example `operatorhubio.yaml` CR"
apiVersion: catalogd.operatorframework.io/v1alpha1
kind: Catalog
kind: ClusterCatalog
metadata:
name: operatorhub
spec:
Expand Down
2 changes: 1 addition & 1 deletion internal/catalogmetadata/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type filesystemCache struct {
// resources that have been successfully reconciled, unpacked, and are being served.
// These requirements help ensure that we can rely on status conditions to determine
// when to issue a request to update the cached Catalog contents.
func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error) {
func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error) {
if catalog == nil {
return nil, fmt.Errorf("error: provided catalog must be non-nil")
}
Expand Down
30 changes: 15 additions & 15 deletions internal/catalogmetadata/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestCache(t *testing.T) {
t.Run("FetchCatalogContents", func(t *testing.T) {
type test struct {
name string
catalog *catalogd.Catalog
catalog *catalogd.ClusterCatalog
contents []byte
wantErr bool
tripper *MockTripper
Expand All @@ -64,11 +64,11 @@ func TestCache(t *testing.T) {
for _, tt := range []test{
{
name: "valid non-cached fetch",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Expand All @@ -82,11 +82,11 @@ func TestCache(t *testing.T) {
},
{
name: "valid cached fetch",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Expand All @@ -102,11 +102,11 @@ func TestCache(t *testing.T) {
},
{
name: "cached update fetch with changes",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Expand All @@ -122,11 +122,11 @@ func TestCache(t *testing.T) {
},
{
name: "fetch error",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Expand All @@ -141,11 +141,11 @@ func TestCache(t *testing.T) {
},
{
name: "fetch internal server error response",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Expand All @@ -167,11 +167,11 @@ func TestCache(t *testing.T) {
},
{
name: "nil catalog.status.resolvedSource",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: nil,
},
},
Expand All @@ -181,11 +181,11 @@ func TestCache(t *testing.T) {
},
{
name: "nil catalog.status.resolvedSource.image",
catalog: &catalogd.Catalog{
catalog: &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "test-catalog",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
ResolvedSource: &catalogd.ResolvedCatalogSource{
Image: nil,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/catalogmetadata/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Fetcher interface {
// server for the catalog provided. It returns an io.ReadCloser
// containing the FBC contents that the caller is expected to close.
// returns an error if any occur.
FetchCatalogContents(ctx context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error)
FetchCatalogContents(ctx context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error)
}

func New(cl client.Client, fetcher Fetcher) *Client {
Expand All @@ -46,7 +46,7 @@ type Client struct {
func (c *Client) Bundles(ctx context.Context) ([]*catalogmetadata.Bundle, error) {
var allBundles []*catalogmetadata.Bundle

var catalogList catalogd.CatalogList
var catalogList catalogd.ClusterCatalogList
if err := c.cl.List(ctx, &catalogList); err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/catalogmetadata/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestClient(t *testing.T) {
name: "skip catalog missing Unpacked status condition",
fakeCatalog: func() ([]client.Object, []*catalogmetadata.Bundle, map[string][]byte) {
objs, bundles, catalogContentMap := defaultFakeCatalog()
objs = append(objs, &catalogd.Catalog{
objs = append(objs, &catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "foobar",
},
Expand Down Expand Up @@ -220,11 +220,11 @@ func defaultFakeCatalog() ([]client.Object, []*catalogmetadata.Bundle, map[strin
}`

objs := []client.Object{
&catalogd.Catalog{
&catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "catalog-1",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
Conditions: []metav1.Condition{
{
Type: catalogd.TypeUnpacked,
Expand All @@ -234,11 +234,11 @@ func defaultFakeCatalog() ([]client.Object, []*catalogmetadata.Bundle, map[strin
},
},
},
&catalogd.Catalog{
&catalogd.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "catalog-2",
},
Status: catalogd.CatalogStatus{
Status: catalogd.ClusterCatalogStatus{
Conditions: []metav1.Condition{
{
Type: catalogd.TypeUnpacked,
Expand Down Expand Up @@ -338,7 +338,7 @@ type MockFetcher struct {
shouldError bool
}

func (mc *MockFetcher) FetchCatalogContents(_ context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error) {
func (mc *MockFetcher) FetchCatalogContents(_ context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error) {
if mc.shouldError {
return nil, errors.New("mock cache error")
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,12 @@ func isInsecureSkipTLSVerifySet(ce *ocv1alpha1.ClusterExtension) bool {
func (r *ClusterExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error {
controller, err := ctrl.NewControllerManagedBy(mgr).
For(&ocv1alpha1.ClusterExtension{}).
Watches(&catalogd.Catalog{},
Watches(&catalogd.ClusterCatalog{},
crhandler.EnqueueRequestsFromMapFunc(clusterExtensionRequestsForCatalog(mgr.GetClient(), mgr.GetLogger()))).
WithEventFilter(predicate.Funcs{
UpdateFunc: func(ue event.UpdateEvent) bool {
oldObject, isOldCatalog := ue.ObjectOld.(*catalogd.Catalog)
newObject, isNewCatalog := ue.ObjectNew.(*catalogd.Catalog)
oldObject, isOldCatalog := ue.ObjectOld.(*catalogd.ClusterCatalog)
newObject, isNewCatalog := ue.ObjectNew.(*catalogd.ClusterCatalog)

if !isOldCatalog || !isNewCatalog {
return true
Expand Down

0 comments on commit 5479625

Please sign in to comment.