Documentation
¶
Index ¶
- func Extract(ctx context.Context, input string) []string
- func Process(ctx context.Context, input string, varCtx VariableContext) (string, error)
- func ProcessMap(ctx context.Context, input map[string]string, varCtx VariableContext) (map[string]string, error)
- func RegisterVariable(ctx context.Context, name string, processor VariableFunc)
- func WithProcessor(ctx context.Context, processor VariableProcessor) context.Context
- type DefaultVariableContext
- func (c *DefaultVariableContext) AddPod(name, dnsName string)
- func (c *DefaultVariableContext) GetPodName(name string) string
- func (c *DefaultVariableContext) GetRegistry() string
- func (c *DefaultVariableContext) GetURL() string
- func (c *DefaultVariableContext) GetValue(name string) (string, bool)
- func (c *DefaultVariableContext) SetRegistry(registry string)
- func (c *DefaultVariableContext) SetURL(url string)
- func (c *DefaultVariableContext) SetValue(name, value string)
- func (c *DefaultVariableContext) WithPod(name, dnsName string) *DefaultVariableContext
- func (c *DefaultVariableContext) WithRegistry(registry string) *DefaultVariableContext
- func (c *DefaultVariableContext) WithURL(url string) *DefaultVariableContext
- func (c *DefaultVariableContext) WithValue(name, value string) *DefaultVariableContext
- type DefaultVariableProcessor
- func (p *DefaultVariableProcessor) Extract(input string) []string
- func (p *DefaultVariableProcessor) ExtractPodReferences(input string) []string
- func (p *DefaultVariableProcessor) Process(input string, context VariableContext) (string, error)
- func (p *DefaultVariableProcessor) ProcessMap(input map[string]string, context VariableContext) (map[string]string, error)
- func (p *DefaultVariableProcessor) RegisterVariable(name string, processor VariableFunc)
- type VariableContext
- type VariableFunc
- type VariableProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessMap ¶
func ProcessMap(ctx context.Context, input map[string]string, varCtx VariableContext) (map[string]string, error)
ProcessMap is a convenience function to process a map of template strings
func RegisterVariable ¶
func RegisterVariable(ctx context.Context, name string, processor VariableFunc)
RegisterVariable is a convenience function to register a custom variable processor
func WithProcessor ¶
func WithProcessor(ctx context.Context, processor VariableProcessor) context.Context
WithProcessor returns a new context with the template processor
Types ¶
type DefaultVariableContext ¶
type DefaultVariableContext struct {
// contains filtered or unexported fields
}
DefaultVariableContext is the default implementation of VariableContext
func NewContext ¶
func NewContext() *DefaultVariableContext
NewContext is a convenience function to create a new variable context
func NewVariableContext ¶
func NewVariableContext() *DefaultVariableContext
NewVariableContext creates a new DefaultVariableContext
func (*DefaultVariableContext) AddPod ¶
func (c *DefaultVariableContext) AddPod(name, dnsName string)
AddPod adds a pod to the context
func (*DefaultVariableContext) GetPodName ¶
func (c *DefaultVariableContext) GetPodName(name string) string
GetPodName returns the internal DNS name for a pod
func (*DefaultVariableContext) GetRegistry ¶
func (c *DefaultVariableContext) GetRegistry() string
GetRegistry returns the registry URL
func (*DefaultVariableContext) GetURL ¶
func (c *DefaultVariableContext) GetURL() string
GetURL returns the application URL
func (*DefaultVariableContext) GetValue ¶
func (c *DefaultVariableContext) GetValue(name string) (string, bool)
GetValue returns a custom variable value
func (*DefaultVariableContext) SetRegistry ¶
func (c *DefaultVariableContext) SetRegistry(registry string)
SetRegistry sets the registry URL
func (*DefaultVariableContext) SetURL ¶
func (c *DefaultVariableContext) SetURL(url string)
SetURL sets the application URL
func (*DefaultVariableContext) SetValue ¶
func (c *DefaultVariableContext) SetValue(name, value string)
SetValue sets a custom variable value
func (*DefaultVariableContext) WithPod ¶
func (c *DefaultVariableContext) WithPod(name, dnsName string) *DefaultVariableContext
WithPod returns a new context with a pod added
func (*DefaultVariableContext) WithRegistry ¶
func (c *DefaultVariableContext) WithRegistry(registry string) *DefaultVariableContext
WithRegistry returns a new context with the registry set
func (*DefaultVariableContext) WithURL ¶
func (c *DefaultVariableContext) WithURL(url string) *DefaultVariableContext
WithURL returns a new context with the URL set
func (*DefaultVariableContext) WithValue ¶
func (c *DefaultVariableContext) WithValue(name, value string) *DefaultVariableContext
WithValue returns a new context with a custom value set
type DefaultVariableProcessor ¶
type DefaultVariableProcessor struct {
// contains filtered or unexported fields
}
DefaultVariableProcessor is the default implementation of VariableProcessor
func NewVariableProcessor ¶
func NewVariableProcessor() *DefaultVariableProcessor
NewVariableProcessor creates a new DefaultVariableProcessor
func (*DefaultVariableProcessor) Extract ¶
func (p *DefaultVariableProcessor) Extract(input string) []string
Extract extracts template variables from the given string
func (*DefaultVariableProcessor) ExtractPodReferences ¶
func (p *DefaultVariableProcessor) ExtractPodReferences(input string) []string
ExtractPodReferences extracts pod references from the given string
func (*DefaultVariableProcessor) Process ¶
func (p *DefaultVariableProcessor) Process(input string, context VariableContext) (string, error)
Process replaces template variables in the given string with their values
func (*DefaultVariableProcessor) ProcessMap ¶
func (p *DefaultVariableProcessor) ProcessMap(input map[string]string, context VariableContext) (map[string]string, error)
ProcessMap replaces template variables in all values of the given map
func (*DefaultVariableProcessor) RegisterVariable ¶
func (p *DefaultVariableProcessor) RegisterVariable(name string, processor VariableFunc)
RegisterVariable registers a custom variable processor
type VariableContext ¶
type VariableContext interface {
// GetRegistry returns the registry URL
GetRegistry() string
// GetURL returns the application URL
GetURL() string
// GetPodName returns the internal DNS name for a pod
GetPodName(name string) string
// GetValue returns a custom variable value
GetValue(name string) (string, bool)
}
VariableContext provides context for variable processing
type VariableFunc ¶
type VariableFunc func(context VariableContext, args ...string) (string, error)
VariableFunc is a function that processes a template variable
type VariableProcessor ¶
type VariableProcessor interface {
// Process replaces template variables in the given string with their values
Process(input string, context VariableContext) (string, error)
// ProcessMap replaces template variables in all values of the given map
ProcessMap(input map[string]string, context VariableContext) (map[string]string, error)
// Extract extracts template variables from the given string
Extract(input string) []string
// RegisterVariable registers a custom variable processor
RegisterVariable(name string, processor VariableFunc)
}
VariableProcessor defines the interface for processing template variables
func GetProcessor ¶
func GetProcessor(ctx context.Context) VariableProcessor
GetProcessor returns the template processor from the context or the default processor