fieldpath

package
v2.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fieldpath supplies methods for extracting fields from objects given a path to a field.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFieldPath added in v2.6.0

func ExtractFieldPath(obj interface{}, fieldPath string) ([]string, []string, error)

ExtractFieldPath extracts the field(s) from the given object and returns the value as string, along with the expanded value of any wildcard values.

Multiple keys and values are guaranteed to be sorted in key order. If a wildcard path was given, keys is not nil.

func SplitMaybeSubscriptedPath

func SplitMaybeSubscriptedPath(fieldPath string) (string, string, bool)

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)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL