template

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package template provides TemplateProcessor, capable of transforming Template objects into Config objects.

Index

Constants

View Source
const (
	OverwriteExistingDstKey = 1 << iota
	ErrorOnExistingDstKey
	ErrorOnDifferentDstKeyValue
)

MergeInto flags

Variables

This section is empty.

Functions

func AddConfigLabels added in v0.2.2

func AddConfigLabels(c *configapi.Config, labels labels.Set) errs.ValidationErrorList

AddConfigLabels adds new label(s) to all resources defined in the given Config.

func AddObjectLabels added in v0.2.2

func AddObjectLabels(obj runtime.Object, labels labels.Set) error

AddObjectLabels adds new label(s) to a single runtime.Object

func AddParameter added in v0.2.1

func AddParameter(t *api.Template, param api.Parameter)

AddParameter adds new custom parameter to the Template. It overrides the existing parameter, if already defined.

func GetParameterByName added in v0.2.1

func GetParameterByName(t *api.Template, name string) *api.Parameter

GetParameterByName searches for a Parameter in the Template based on it's name.

func MergeInto added in v0.2.2

func MergeInto(dst, src interface{}, flags int) error

MergeInto merges items from a src map into a dst map. Returns an error when the maps are not of the same type. Flags:

  • ErrorOnExistingDstKey When set: Return an error if any of the dst keys is already set.
  • ErrorOnDifferentDstKeyValue When set: Return an error if any of the dst keys is already set to a different value than src key.
  • OverwriteDstKey When set: Overwrite existing dst key value with src key value.

Types

type Processor added in v0.2.1

type Processor struct {
	Generators map[string]Generator
}

Processor process the Template into the List with substituted parameters

func NewProcessor added in v0.2.1

func NewProcessor(generators map[string]Generator) *Processor

NewProcessor creates new Processor and initializes its set of generators.

func (*Processor) GenerateParameterValues added in v0.2.1

func (p *Processor) GenerateParameterValues(t *api.Template) error

GenerateParameterValues generates Value for each Parameter of the given Template that has Generate field specified where Value is not already supplied.

Examples:

from | value ----------------------------- "test[0-9]{1}x" | "test7x" "[0-1]{8}" | "01001100" "0x[A-F0-9]{4}" | "0xB3AF" "[a-zA-Z0-9]{8}" | "hW4yQU5i"

func (*Processor) Process added in v0.2.1

func (p *Processor) Process(template *api.Template) (*configapi.Config, errs.ValidationErrorList)

Process transforms Template object into List object. It generates Parameter values using the defined set of generators first, and then it substitutes all Parameter expression occurrences with their corresponding values (currently in the containers' Environment variables only).

func (*Processor) SubstituteParameters added in v0.2.1

func (p *Processor) SubstituteParameters(params []api.Parameter, item runtime.Object) (runtime.Object, error)

SubstituteParameters loops over all Environment variables defined for all ReplicationController and Pod containers and substitutes all Parameter expression occurrences with their corresponding values.

Example of Parameter expression:

  • ${PARAMETER_NAME}

TODO: Implement substitution for more types and fields.

Directories

Path Synopsis
api
Package api defines and registers types for Template objects.
Package api defines and registers types for Template objects.
validation
Package validation has functions for validating the correctness of Template objects and explaining what is wrong with them when they aren't valid.
Package validation has functions for validating the correctness of Template objects and explaining what is wrong with them when they aren't valid.
Package generator defines GeneratorInterface interface and implements some random value generators.
Package generator defines GeneratorInterface interface and implements some random value generators.
examples
Package examples demonstrates possible implementation of some random value generators.
Package examples demonstrates possible implementation of some random value generators.

Jump to

Keyboard shortcuts

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