fieldpath

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(segments []Segment) string

Build constructs a field path string from a slice of segments.

Examples:

  • [{Field: "spec"}, {Field: "containers", ArrayIdx: 0}] -> spec.containers[0]
  • [{Field: "spec"}, {Field: "my.field"}] -> spec["my.field"]

Types

type Segment

type Segment struct {
	Name  string // Field name without quotes
	Index int    // -1 if not an array access
}

Segment represents a single part of a path

func NewIndexedSegment

func NewIndexedSegment(index int) Segment

NewIndexedSegment creates a new indexed segment.

func NewNamedSegment

func NewNamedSegment(name string) Segment

NewNamedSegment creates a new named segment.

func Parse

func Parse(path string) ([]Segment, error)

Parse parses a path string into segments. Assumes dictionary access is always quoted.

example paths: - spec["my.field.name"].items[0]["other.field"] - simple.path["quoted.field"][0]

Jump to

Keyboard shortcuts

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