Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
  • Loading branch information
OchiengEd committed Jul 1, 2024
1 parent 1483b0b commit fc436c3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/contentmanager/contentmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/operator-framework/operator-controller/api/v1alpha1"
oclabels "github.com/operator-framework/operator-controller/internal/labels"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -48,7 +49,7 @@ func New(rcm RestConfigMapper, cfg *rest.Config, mapper meta.RESTMapper) Content
return &instance{
rcm: rcm,
baseCfg: cfg,
extensionCaches: make(map[string]extensionCacheData{}),
extensionCaches: make(map[string]extensionCacheData),
mapper: mapper,
}
}
Expand All @@ -67,8 +68,8 @@ func (i *instance) ManageContent(ctx context.Context, ctrl controller.Controller
// ApiVersion and Kind set. Failure to which the code will panic when adding the types to the scheme
scheme := runtime.NewScheme()
for _, obj := range objs {
gvk := obj.GetObjectKind().GetVersionKind()
listKind := obj.GetObjectKind().GetVersionKind().Kind + "List"
gvk := obj.GetObjectKind().GroupVersionKind()
listKind := obj.GetObjectKind().GroupVersionKind().Kind + "List"

if gvk.Kind == "" || gvk.Version == "" {
return errors.New("object Kind or Version is not defined")
Expand Down Expand Up @@ -106,7 +107,7 @@ func (i *instance) ManageContent(ctx context.Context, ctrl controller.Controller
c,
obj,
handler.TypedEnqueueRequestForOwner[client.Object](
i.scheme,
scheme,
i.mapper,
ce,
),
Expand All @@ -124,7 +125,7 @@ func (i *instance) ManageContent(ctx context.Context, ctrl controller.Controller

ctx, cancel := context.WithCancel(ctx)
go c.Start(ctx)
i.extensionCaches[ce.Name] = extensionsCacheData{
i.extensionCaches[ce.Name] = extensionCacheData{
Cache: c,
Cancel: cancel,
}
Expand All @@ -135,7 +136,7 @@ func (i *instance) ManageContent(ctx context.Context, ctrl controller.Controller
func (i *instance) RemoveManagedContent(ce *v1alpha1.ClusterExtension) error {
if data, ok := i.extensionCaches[ce.GetName()]; ok {
data.Cancel()
delete(i.extensionCaches, ce.GetName)
delete(i.extensionCaches, ce.GetName())
}

return nil
Expand Down

0 comments on commit fc436c3

Please sign in to comment.