MCPcopy
hub / github.com/redspread/spread / ObjectPath

Function ObjectPath

pkg/deploy/object.go:25–35  ·  view source on GitHub ↗

ObjectPath returns the full path of an object. This uses the format " /namespaces/ / / "

(obj KubeObject)

Source from the content-addressed store, hash-verified

23// ObjectPath returns the full path of an object.
24// This uses the format "<apiVersion>/namespaces/<namespace>/<kind>/<name>"
25func 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.

Callers 3

AddMethod · 0.85
TestObjectPathFunction · 0.85

Calls 1

objectKindFunction · 0.85

Tested by 2

TestObjectPathFunction · 0.68