url

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package url handles expansion of the download URL for the config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllVariables

func AllVariables() map[string]*Variable

AllVariables is a map of all supported variables.

func MapValues

func MapValues(ctx context.Context, st state.State, variableNames []string) (map[string]string, error)

MapValues maps variable names to values.

func Populate

func Populate(ctx context.Context, downloadURL string, st state.State) (string, error)

Populate populates the config download URL with values replacing variables.

func PopulateVariables

func PopulateVariables(ctx context.Context, downloadURL string, st state.State, variables []*Variable) (string, error)

PopulateVariables populates the config download URL with values replacing variables.

Types

type Value

type Value interface {
	// Get the value.
	Get() string
	// RegisterWatch handles registering a watch for the variable.
	RegisterWatch(ctx context.Context, st state.State, ch chan<- state.Event) error
	// EventHandler is called for each watch event, returns when the variable value is ready.
	EventHandler(event state.Event) (bool, error)
}

Value of a variable.

func CodeValue

func CodeValue() Value

CodeValue is a value for Code variable.

func HostnameValue

func HostnameValue() Value

HostnameValue is a value for Hostname variable.

func MACValue

func MACValue() Value

MACValue is a value for MAC variable.

func SerialNumberValue

func SerialNumberValue() Value

SerialNumberValue is a value for SerialNumber variable.

func UUIDValue

func UUIDValue() Value

UUIDValue is a value for UUID variable.

type Variable

type Variable struct {
	// Key is the variable name.
	Key string
	// MatchOnArg is set for variables which are match on the arg name with empty value.
	//
	// Required to support legacy `?uuid=` style of the download URL.
	MatchOnArg bool
	// Value is the variable value.
	Value Value
	// contains filtered or unexported fields
}

Variable represents a variable substitution in the download URL.

func (*Variable) Matches

func (v *Variable) Matches(query url.Values) bool

Matches checks if the variable is present in the URL.

func (*Variable) Replace

func (v *Variable) Replace(query url.Values)

Replace modifies the URL query replacing the variable with the value.

Jump to

Keyboard shortcuts

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