Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed Mar 1, 2023
1 parent 1c6cdec commit 9df311f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/sync/kubernetes/kubernetes_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kubernetes

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -60,7 +59,7 @@ func (k *Sync) Init(ctx context.Context) error {
return err
}

clusterClient, err := dynamic.NewForConfig(clusterConfig)
dynamicClient, err := dynamic.NewForConfig(clusterConfig)
if err != nil {
return err
}
Expand All @@ -69,7 +68,7 @@ func (k *Sync) Init(ctx context.Context) error {

// The created informer will not do resyncs if the given defaultEventHandlerResyncPeriod is zero.
// For more details on resync implications refer to tools/cache/shared_informer.go
factory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(clusterClient, resyncPeriod, k.namespace, nil)
factory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicClient, resyncPeriod, k.namespace, nil)

k.informer = factory.ForResource(resource).Informer()

Expand Down Expand Up @@ -207,7 +206,7 @@ func commonHandler(obj interface{}, object client.ObjectKey, emitEvent DefaultEv
}

if ffObj.APIVersion != apiVersion {
return errors.New("invalid api version")
return fmt.Errorf("invalid api version %s, expected %s", ffObj.APIVersion, apiVersion)
}

if ffObj.Name == object.Name {
Expand All @@ -229,7 +228,7 @@ func updateFuncHandler(oldObj interface{}, newObj interface{}, object client.Obj
}

if ffOldObj.APIVersion != apiVersion {
return errors.New("invalid api version")
return fmt.Errorf("invalid api version %s, expected %s", ffOldObj.APIVersion, apiVersion)
}

ffNewObj, err := toFFCfg(newObj)
Expand All @@ -238,7 +237,7 @@ func updateFuncHandler(oldObj interface{}, newObj interface{}, object client.Obj
}

if ffNewObj.APIVersion != apiVersion {
return errors.New("invalid api version")
return fmt.Errorf("invalid api version %s, expected %s", ffNewObj.APIVersion, apiVersion)
}

if object.Name == ffNewObj.Name && ffOldObj.ResourceVersion != ffNewObj.ResourceVersion {
Expand Down Expand Up @@ -273,7 +272,7 @@ func toFFCfg(object interface{}) (*v1alpha1.FeatureFlagConfiguration, error) {
func parseURI(uri string) (string, string, error) {
s := strings.Split(uri, "/")
if len(s) != 2 || len(s[0]) == 0 || len(s[1]) == 0 {
return "", "", fmt.Errorf("invalid resource uri: %s", uri)
return "", "", fmt.Errorf("invalid resource uri format, expected <namespace>/<crdName> but got: %s", uri)
}
return s[0], s[1], nil
}
Expand Down

0 comments on commit 9df311f

Please sign in to comment.