mirror of
https://github.com/rancher/types.git
synced 2025-04-27 18:25:05 +00:00
The namespace package contains constants that need to be used globally so moving to types to other go modules can depend on it.
19 lines
345 B
Go
19 lines
345 B
Go
package namespace
|
|
|
|
import v1 "k8s.io/api/core/v1"
|
|
|
|
var projectIDAnnotation = "field.cattle.io/projectId"
|
|
|
|
func NsByProjectID(obj interface{}) ([]string, error) {
|
|
ns, ok := obj.(*v1.Namespace)
|
|
if !ok {
|
|
return []string{}, nil
|
|
}
|
|
|
|
if id, ok := ns.Annotations[projectIDAnnotation]; ok {
|
|
return []string{id}, nil
|
|
}
|
|
|
|
return []string{}, nil
|
|
}
|