88 "time"
99
1010 "k8s.io/apimachinery/pkg/api/meta"
11+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1113 "k8s.io/apimachinery/pkg/runtime"
1214 "k8s.io/apimachinery/pkg/util/wait"
1315 toolscache "k8s.io/client-go/tools/cache"
@@ -116,10 +118,17 @@ func (ks *Kind[object, request]) Start(ctx context.Context, queue workqueue.Type
116118}
117119
118120func (ks * Kind [object , request ]) String () string {
119- if ! isNil (ks .Type ) {
121+ if isNil (ks .Type ) {
122+ return "kind source: unknown type"
123+ }
124+
125+ switch v := any (ks .Type ).(type ) {
126+ case * unstructured.Unstructured , * metav1.PartialObjectMetadata :
127+ gvk := v .(client.Object ).GetObjectKind ().GroupVersionKind ()
128+ return fmt .Sprintf ("kind source: %T[%s]" , v , gvk .Kind )
129+ default :
120130 return fmt .Sprintf ("kind source: %T" , ks .Type )
121131 }
122- return "kind source: unknown type"
123132}
124133
125134// WaitForSync implements SyncingSource to allow controllers to wait with starting
@@ -133,7 +142,7 @@ func (ks *Kind[object, request]) WaitForSync(ctx context.Context) error {
133142 if errors .Is (ctx .Err (), context .Canceled ) {
134143 return nil
135144 }
136- return fmt .Errorf ("timed out waiting for cache to be synced for Kind %T " , ks .Type )
145+ return fmt .Errorf ("timed out waiting for cache to be synced for %s " , ks .String () )
137146 }
138147}
139148
0 commit comments