template

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatVariables

func FormatVariables(fmt VariableFormat, input []string) string

func RegisterDefaults

func RegisterDefaults(scheme *runtime.Scheme) error

RegisterDefaults adds defaulters functions to the given scheme. Public to allow building arbitrary schemes. All generated defaulters are covering - they call all nested defaulters.

Types

type Position

type Position struct {
	// Start is the byte offset within TargetKey's property of the variable.
	// It is the start location for replacements).
	Start int64 `json:"start"` // TODO: byte, rune?

	// End is the byte offset of the end of the variable.
	End int64 `json:"end"`
}

Position is where to do replacement in the targets during render.

func (*Position) DeepCopy

func (in *Position) DeepCopy() *Position

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Position.

func (*Position) DeepCopyInto

func (in *Position) DeepCopyInto(out *Position)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type QueryTemplate

type QueryTemplate struct {
	// A display name
	Title string `json:"title,omitempty"`

	// Longer description for why it is interesting
	Description string `json:"description,omitempty"`

	// The variables that can be used to render
	// +listType=map
	// +listMapKey=key
	Variables []TemplateVariable `json:"vars,omitempty"`

	// Output variables
	// +listType=set
	Targets []Target `json:"targets"`
}

func (*QueryTemplate) DeepCopy

func (in *QueryTemplate) DeepCopy() *QueryTemplate

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QueryTemplate.

func (*QueryTemplate) DeepCopyInto

func (in *QueryTemplate) DeepCopyInto(out *QueryTemplate)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Target

type Target struct {
	// DataType is the returned Dataplane type from the query.
	DataType data.FrameType `json:"dataType,omitempty"`

	// Variables that will be replaced in the query
	Variables map[string][]VariableReplacement `json:"variables"`

	// Query target
	Properties apidata.DataQuery `json:"properties"`
}

func RenderTemplate

func RenderTemplate(qt QueryTemplate, selectedValues map[string][]string) ([]Target, error)

RenderTemplate applies selected values into a query template

func (*Target) DeepCopy

func (in *Target) DeepCopy() *Target

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Target.

func (*Target) DeepCopyInto

func (in *Target) DeepCopyInto(out *Target)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type TemplateVariable

type TemplateVariable struct {
	// Key is the name of the variable.
	Key string `json:"key"`

	// DefaultValue is the value to be used when there is no selected value
	// during render.
	// +listType=atomic
	DefaultValues []string `json:"defaultValues,omitempty"`

	// ValueListDefinition is the object definition used by the FE
	// to get a list of possible values to select for render.
	ValueListDefinition common.Unstructured `json:"valueListDefinition,omitempty"`
}

TemplateVariable is the definition of a variable that will be interpolated in targets.

func (*TemplateVariable) DeepCopy

func (in *TemplateVariable) DeepCopy() *TemplateVariable

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateVariable.

func (*TemplateVariable) DeepCopyInto

func (in *TemplateVariable) DeepCopyInto(out *TemplateVariable)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type VariableFormat

type VariableFormat string

Define how to format values in the template. See: https://grafana.com/docs/grafana/latest/dashboards/variables/variable-syntax/#advanced-variable-format-options +enum

const (
	// Formats variables with multiple values as a comma-separated string.
	FormatCSV VariableFormat = "csv"

	// Formats variables with multiple values as a comma-separated string.
	FormatJSON VariableFormat = "json"

	// Formats single- and multi-valued variables into a comma-separated string
	FormatDoubleQuote VariableFormat = "doublequote"

	// Formats single- and multi-valued variables into a comma-separated string
	FormatSingleQuote VariableFormat = "singlequote"

	// Formats variables with multiple values into a pipe-separated string.
	FormatPipe VariableFormat = "pipe"

	// Formats variables with multiple values into comma-separated string.
	// This is the default behavior when no format is specified
	FormatRaw VariableFormat = "raw"
)

Defines values for ItemType.

type VariableReplacement

type VariableReplacement struct {
	// Path is the location of the property within a target.
	// The format for this is not figured out yet (Maybe JSONPath?).
	// Idea: ["string", int, "string"] where int indicates array offset
	Path string `json:"path"`

	// Positions is a list of where to perform the interpolation
	// within targets during render.
	// The first string is the Idx of the target as a string, since openAPI
	// does not support ints as map keys
	Position *Position `json:"position,omitempty"`

	// How values should be interpolated
	Format VariableFormat `json:"format,omitempty"`
}

QueryVariable is the definition of a variable that will be interpolated in targets.

func (*VariableReplacement) DeepCopy

func (in *VariableReplacement) DeepCopy() *VariableReplacement

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VariableReplacement.

func (*VariableReplacement) DeepCopyInto

func (in *VariableReplacement) DeepCopyInto(out *VariableReplacement)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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