package fieldpath
import "k8s.io/kubectl/pkg/util/fieldpath"
Index ¶
- func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error)
- func FormatMap(m map[string]string) (fmtStr string)
- func SplitMaybeSubscriptedPath(fieldPath string) (string, string, bool)
Functions ¶
func ExtractFieldPathAsString ¶
ExtractFieldPathAsString extracts the field from the given object and returns it as a string. The object must be a pointer to an API type.
func FormatMap ¶
FormatMap formats map[string]string to a string.
func SplitMaybeSubscriptedPath ¶
SplitMaybeSubscriptedPath checks whether the specified fieldPath is subscripted, and
- if yes, this function splits the fieldPath into path and subscript, and returns (path, subscript, true).
- if no, this function returns (fieldPath, "", false).
Example inputs and outputs:
"metadata.annotations['myKey']" --> ("metadata.annotations", "myKey", true) "metadata.annotations['a[b]c']" --> ("metadata.annotations", "a[b]c", true) "metadata.labels['']" --> ("metadata.labels", "", true) "metadata.labels" --> ("metadata.labels", "", false)
Source Files ¶
fieldpath.go
- Version
- v0.32.3 (latest)
- Published
- Mar 12, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 6 days ago –
Tools for package owners.