ObjectPath returns the full path of an object. This uses the format " /namespaces/ / / "
(obj KubeObject)
| 23 | // ObjectPath returns the full path of an object. |
| 24 | // This uses the format "<apiVersion>/namespaces/<namespace>/<kind>/<name>" |
| 25 | func ObjectPath(obj KubeObject) (string, error) { |
| 26 | // attempt to determine ObjectKind |
| 27 | gkv, err := objectKind(obj) |
| 28 | if err != nil { |
| 29 | return "", fmt.Errorf("could not get object path: %v", err) |
| 30 | } |
| 31 | |
| 32 | meta := obj.GetObjectMeta() |
| 33 | path := fmt.Sprintf("namespaces/%s/%s/%s", meta.GetNamespace(), gkv.Kind, meta.GetName()) |
| 34 | return strings.ToLower(path), nil |
| 35 | } |
| 36 | |
| 37 | // objectKind is a helper function which determines type information from given KubeObject. |
| 38 | // An error is returned if the GroupVersionKind is empty or cannot be determined. |