query

package
v0.0.0-...-5b31af0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Breadcrumbs struct {
	Parts  []Crumb
	Length int
}

Breadcrumbs represents the dot.style.query that the user passes in.

func ParseBreadcrumbs

func ParseBreadcrumbs(queryString string) (*Breadcrumbs, error)

ParseBreadcrumbs reads in a query string specified by the user and breaks it down into Crumb instances that can be matched against HCL keys with IsMatch.

type Crumb

type Crumb interface {
	IsMatch(key string, val ast.Node) (bool, error)
	Key() string
}

Crumb represents an individual portion of a user's query. For example, given the query 'data.*.bar.id', each of data, *, bar, and id are each crumbs. Crumbs implement IsMatch to determine whether or not it can be used to match a given HCL key.

type IndexedCrumb

type IndexedCrumb interface {
	IsMatch(key string, val ast.Node) (bool, error)
	Key() string
	Index() *int
}

IndexedCrumb is a type of Crumb used for indexable elements such as arrays or lists. Its index is optional and will be nil if no index was specified. For example, in the query 'foo.bar[1]', the bar[1] portion will be represented by an IndexedCrumb with an index of 1. If an index is not present, such as with 'bar[]', the index will be nil.

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a literal breadcrumb that matches based on its exact value.

func (*Key) IsMatch

func (k *Key) IsMatch(key string, val ast.Node) (bool, error)

func (*Key) Key

func (k *Key) Key() string

type List

type List struct {
	// contains filtered or unexported fields
}

List is a breadcrumb representing a list or array, either the entire list or just an individual item.

func (*List) Index

func (l *List) Index() *int

func (*List) IsMatch

func (l *List) IsMatch(key string, val ast.Node) (bool, error)

func (*List) Key

func (l *List) Key() string

type Regex

type Regex struct {
	// contains filtered or unexported fields
}

Regex is a breadcrumb that matches based on a regex. It can take an optioanl indexer.

func (*Regex) Index

func (r *Regex) Index() *int

func (*Regex) IsMatch

func (r *Regex) IsMatch(key string, val ast.Node) (bool, error)

func (*Regex) Key

func (r *Regex) Key() string

type Wildcard

type Wildcard struct {
}

Wildcard is the literal breadcrumb '*' that matches anything.

func (*Wildcard) IsMatch

func (w *Wildcard) IsMatch(key string, val ast.Node) (bool, error)

func (*Wildcard) Key

func (w *Wildcard) Key() string

Jump to

Keyboard shortcuts

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