Documentation ¶
Index ¶
- Variables
- func RegisterSubstitution(sub Handler)
- func ReplaceByState(identifier Identifier, globalState *GlobalState, target string) (string, error)
- type GlobalState
- func (gs GlobalState) Each(f func(Identifier, []State))
- func (gs GlobalState) Exists(identifier Identifier, key string) bool
- func (gs GlobalState) GetByIdentifier(identifier Identifier) []State
- func (gs GlobalState) Len() int
- func (gs GlobalState) Set(identifier Identifier, key string, value string)
- type Handler
- type Identifier
- type State
- type Substitution
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingCIDR is returned when the CIDR is missing ErrMissingCIDR = errors.New("missing CIDR") )
Functions ¶
func RegisterSubstitution ¶
func RegisterSubstitution(sub Handler)
RegisterSubstitution registers a new substitution
func ReplaceByState ¶
func ReplaceByState(identifier Identifier, globalState *GlobalState, target string) (string, error)
ReplaceByState replaces the placeholders in the target string with the values from the state
Types ¶
type GlobalState ¶
type GlobalState map[Identifier][]State
GlobalState defines the global state of the substitutions it's a map of index to a list of substitutions
func (GlobalState) Each ¶
func (gs GlobalState) Each(f func(Identifier, []State))
Each iterates over the global state and calls the provided function
func (GlobalState) Exists ¶
func (gs GlobalState) Exists(identifier Identifier, key string) bool
Exists checks if a key exists in the global state
func (GlobalState) GetByIdentifier ¶
func (gs GlobalState) GetByIdentifier(identifier Identifier) []State
GetByIdentifier returns the state by the provided identifier
func (GlobalState) Set ¶
func (gs GlobalState) Set(identifier Identifier, key string, value string)
Set adds a new state to the global state
type Handler ¶
type Handler interface { Type() string WriteGlobalState(identifier Identifier, state *GlobalState, sub Substitution) error }
Handler defines the interface for a substitution handler
func GetSubstitution ¶
GetSubstitution returns a substitution by its type
type Identifier ¶
type Identifier string
Identifier is used to identify the state of the current replica
type Substitution ¶
type Substitution struct { Type string `json:"type" yaml:"type"` // Type of the substitution, ipv4Address, ipv6Address, etc Key string `json:"key" yaml:"key"` // Name of the substitution to be replaced $ipv4Address for example Unique bool `json:"unique" yaml:"unique"` AdditionalProperties map[string]string `json:"additionalProperties" yaml:"additionalProperties"` }
Substitution defines a substitution that can be used to replace placeholders in the cloud-init configuration.