Skip to content

Latest commit

 

History

History
12 lines (11 loc) · 388 Bytes

File metadata and controls

12 lines (11 loc) · 388 Bytes
// 来源于 k8s.io/client-go/tools/cache/index.go
// MetaNamespaceIndexFunc is a default index function that indexes based on an object's namespace
func MetaNamespaceIndexFunc(obj interface{}) ([]string, error) {
	meta, err := meta.Accessor(obj)
	if err != nil {
		return []string{""}, fmt.Errorf("object has no meta: %v", err)
	}
	return []string{meta.GetNamespace()}, nil
}