Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
Use Scheme to get GVK of typed objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed Feb 11, 2018
1 parent ef5e15a commit 863c448
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/controller/controller_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ func (c *BundleController) loggerForObj(obj interface{}) *zap.Logger {
}
runtimeObj, ok := metaObj.(runtime.Object)
if ok {
gvk := runtimeObj.GetObjectKind().GroupVersionKind() // TODO does this work for typed objects?
gvk := runtimeObj.GetObjectKind().GroupVersionKind()
if gvk.Kind == "" || gvk.Version == "" {
gvks, _, err := c.Scheme.ObjectKinds(runtimeObj)
if err != nil {
if !runtime.IsNotRegisteredError(err) {
logger.With(zap.Error(err)).Sugar().Warnf("Cannot get object's GVK. Type %T", runtimeObj)
}
return logger
}
gvk = gvks[0]
}
logger = logger.With(logz.Gvk(gvk))
}
return logger
Expand Down

0 comments on commit 863c448

Please sign in to comment.