Skip to content

Commit

Permalink
Fix go vet errors
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>
  • Loading branch information
fabianvf committed Apr 27, 2021
1 parent 2f21571 commit e0a54cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions internal/ansible/handler/logging_enqueue_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
)

const (
nilString = "<nil>"
)

// LoggingEnqueueRequestForAnnotation wraps operator-lib handler for
// "InstrumentedEnqueueRequestForObject", and logs the events as they occur
// &handler.LoggingEnqueueRequestForAnnotation{}
Expand Down Expand Up @@ -64,12 +68,12 @@ func (h LoggingEnqueueRequestForAnnotation) logEvent(eventType string, object, n
typeString, name, namespace = extractTypedOwnerAnnotations(h.EnqueueRequestForAnnotation.Type, newObject)
}
if namespace == "" {
namespace = "<nil>"
namespace = nilString
}

objectNs := object.GetNamespace()
if objectNs == "" {
objectNs = "<nil>"
objectNs = nilString
}

if name != "" && typeString != "" {
Expand Down
8 changes: 6 additions & 2 deletions internal/ansible/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ func addWatchToController(owner kubeconfig.NamespacedOwnerReference, cMap *contr
log.Info("Watching child resource", "kind", resource.GroupVersionKind(),
"enqueue_kind", u.GroupVersionKind())
err := contents.Controller.Watch(&source.Kind{Type: resource},
&handler.LoggingEnqueueRequestForOwner{crHandler.EnqueueRequestForOwner{OwnerType: u}}, predicate.DependentPredicate{})
&handler.LoggingEnqueueRequestForOwner{
EnqueueRequestForOwner: crHandler.EnqueueRequestForOwner{OwnerType: u},
}, predicate.DependentPredicate{})
// Store watch in map
if err != nil {
log.Error(err, "Failed to watch child resource",
Expand All @@ -263,7 +265,9 @@ func addWatchToController(owner kubeconfig.NamespacedOwnerReference, cMap *contr
log.Info("Watching child resource", "kind", resource.GroupVersionKind(),
"enqueue_annotation_type", ownerGK.String())
err = contents.Controller.Watch(&source.Kind{Type: resource},
&handler.LoggingEnqueueRequestForAnnotation{libhandler.EnqueueRequestForAnnotation{Type: ownerGK}}, predicate.DependentPredicate{})
&handler.LoggingEnqueueRequestForAnnotation{
EnqueueRequestForAnnotation: libhandler.EnqueueRequestForAnnotation{Type: ownerGK},
}, predicate.DependentPredicate{})
if err != nil {
log.Error(err, "Failed to watch child resource",
"kind", resource.GroupVersionKind(), "enqueue_kind", u.GroupVersionKind())
Expand Down

0 comments on commit e0a54cf

Please sign in to comment.