processor

package
v0.0.0-...-c2786f3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PathDoc = `` /* 1395-byte string literal not displayed */
View Source
var PathParameter = ProcessorParameter{
	Name:        "path",
	Description: "A string array to define the path of the transformation in the kubernetes yaml.",
}
View Source
var TriggerDoc = `` /* 509-byte string literal not displayed */
View Source
var TriggerParameter = ProcessorParameter{
	Name:        "trigger",
	Description: "A yaml struct to define the condition when the rule, should be applied.",
}

Functions

func CreateOutputFileName

func CreateOutputFileName(name string, kind string) string

func DeepCopy

func DeepCopy(src *data.MapNode) *data.MapNode

func LocateImportedDir

func LocateImportedDir(basedir string, dir string, sources []data.Source, cacheManager *data.SourceCacheManager, excludedDirs []string) (data.Source, error)

try to find the first Source which contains the dir

func ToSimpleYaml

func ToSimpleYaml(resource *data.Resource) interface{}

Types

type Add

type Add struct {
	DefaultProcessor
	Path    data.Path
	Trigger Trigger
	Value   interface{}
	Yamlize bool
}

func (*Add) BeforeResource

func (processor *Add) BeforeResource(resource *data.Resource) error

func (*Add) ToString

func (add *Add) ToString() string

type Change

type Change struct {
	DefaultProcessor
	Trigger     Trigger
	Path        data.Path
	Pattern     string
	Replacement string
}

func (*Change) BeforeResource

func (processor *Change) BeforeResource(resource *data.Resource) error

type Cleanup

type Cleanup struct {
	DefaultProcessor
	ResourceOutputDir string
	All               bool
	// contains filtered or unexported fields
}

func (*Cleanup) After

func (processor *Cleanup) After(ctx *RenderContext, node *ResourceNode) error

func (*Cleanup) AfterResource

func (cleanup *Cleanup) AfterResource(resource *data.Resource) error

func (*Cleanup) Before

func (cleanup *Cleanup) Before(ctx *RenderContext, node *ResourceNode) error

type Compat

type Compat struct {
	DefaultProcessor
	Version string
}

func (*Compat) BeforeResource

func (processor *Compat) BeforeResource(resource *data.Resource) error

type Composite

type Composite struct {
	DefaultProcessor
	ProcessorMetadata
	AdditionalResourcesDir string
	Processors             []Processor
	File                   string
	Template               string
	Parameters             map[string]string
	Trigger                Trigger
}

func (*Composite) After

func (c *Composite) After(ctx *RenderContext, node *ResourceNode) error

func (*Composite) AfterList

func (c *Composite) AfterList(node *data.ListNode)

func (*Composite) AfterListItem

func (c *Composite) AfterListItem(node *data.ListNode, item data.Node, index int)

func (*Composite) AfterMap

func (c *Composite) AfterMap(node *data.MapNode)

func (*Composite) AfterMapItem

func (c *Composite) AfterMapItem(node *data.MapNode, key string, index int)

func (*Composite) AfterResource

func (c *Composite) AfterResource(resource *data.Resource) error

func (*Composite) Before

func (c *Composite) Before(ctx *RenderContext, node *ResourceNode) error

func (*Composite) BeforeList

func (c *Composite) BeforeList(node *data.ListNode)

func (*Composite) BeforeListItem

func (c *Composite) BeforeListItem(node *data.ListNode, item data.Node, index int)

func (*Composite) BeforeMap

func (c *Composite) BeforeMap(node *data.MapNode)

func (*Composite) BeforeMapItem

func (c *Composite) BeforeMapItem(node *data.MapNode, key string, index int)

func (*Composite) BeforeResource

func (c *Composite) BeforeResource(resource *data.Resource) error

func (*Composite) OnKey

func (c *Composite) OnKey(node *data.KeyNode)

func (*Composite) RegisterResources

func (c *Composite) RegisterResources(ctx *RenderContext, node *ResourceNode) error

func (*Composite) ToString

func (processor *Composite) ToString() string

type ConfigHash

type ConfigHash struct {
	DefaultProcessor
	Trigger Trigger
	// contains filtered or unexported fields
}

func (*ConfigHash) Before

func (processor *ConfigHash) Before(ctx *RenderContext, node *ResourceNode) error

func (*ConfigHash) BeforeResource

func (p *ConfigHash) BeforeResource(resource *data.Resource) error

type DaemonToStatefulSet

type DaemonToStatefulSet struct {
	DefaultProcessor
	Trigger Trigger
}

func (*DaemonToStatefulSet) Before

func (processor *DaemonToStatefulSet) Before(ctx *RenderContext, node *ResourceNode) error

func (*DaemonToStatefulSet) BeforeResource

func (processor *DaemonToStatefulSet) BeforeResource(resource *data.Resource) error

type DefaultProcessor

type DefaultProcessor struct {
	data.DefaultVisitor
	Type            string
	Scope           string
	File            string
	CurrentResource *data.Resource
}

func (*DefaultProcessor) After

func (processor *DefaultProcessor) After(ctx *RenderContext, node *ResourceNode) error

func (*DefaultProcessor) AfterResource

func (p *DefaultProcessor) AfterResource(*data.Resource) error

func (*DefaultProcessor) Before

func (processor *DefaultProcessor) Before(ctx *RenderContext, node *ResourceNode) error

func (*DefaultProcessor) BeforeResource

func (p *DefaultProcessor) BeforeResource(resource *data.Resource) error

func (*DefaultProcessor) GetScope

func (processor *DefaultProcessor) GetScope() string

func (*DefaultProcessor) GetType

func (processor *DefaultProcessor) GetType() string

func (*DefaultProcessor) RegisterResources

func (processor *DefaultProcessor) RegisterResources(ctx *RenderContext, node *ResourceNode) error

func (*DefaultProcessor) SetScope

func (processor *DefaultProcessor) SetScope(scope string)

func (*DefaultProcessor) ToString

func (processor *DefaultProcessor) ToString() string

type Env

type Env struct {
	DefaultProcessor
	Envs    map[string]string
	Trigger Trigger
}

func (*Env) BeforeResource

func (env *Env) BeforeResource(resource *data.Resource) error

type Image

type Image struct {
	DefaultProcessor
	Image   string
	Trigger Trigger
}

func (*Image) BeforeResource

func (imageSet *Image) BeforeResource(resource *data.Resource) error

func (*Image) ToString

func (processor *Image) ToString() string

type K8sWriter

type K8sWriter struct {
	DefaultProcessor
	// contains filtered or unexported fields
}

func CreateStdK8sWriter

func CreateStdK8sWriter() *K8sWriter

func (*K8sWriter) Before

func (writer *K8sWriter) Before(ctx *RenderContext, node *ResourceNode) error

func (*K8sWriter) BeforeResource

func (writer *K8sWriter) BeforeResource(resource *data.Resource) error

func (*K8sWriter) ToString

func (writer *K8sWriter) ToString() string

type Mount

type Mount struct {
	DefaultProcessor
	Trigger  Trigger
	HostPath string `yaml:"hostPath"`
	Path     string
	Name     string
}

func (*Mount) BeforeResource

func (mount *Mount) BeforeResource(resource *data.Resource) error

func (*Mount) ToString

func (mount *Mount) ToString() string

type NameFilter

type NameFilter struct {
	DefaultProcessor
	Include []string
	Exclude []string
}

func (*NameFilter) BeforeResource

func (nf *NameFilter) BeforeResource(resource *data.Resource) error

func (*NameFilter) ToString

func (nf *NameFilter) ToString() string

type Namespace

type Namespace struct {
	DefaultProcessor
	Namespace          string
	Force              bool
	ClusterRoleSupport bool
}

func (*Namespace) BeforeResource

func (processor *Namespace) BeforeResource(resource *data.Resource) error

func (*Namespace) ToString

func (processor *Namespace) ToString() string

type Pipe

type Pipe struct {
	DefaultProcessor
	Command string
	Trigger Trigger
	Args    []string
}

func (*Pipe) BeforeResource

func (p *Pipe) BeforeResource(resource *data.Resource) error

type Prefix

type Prefix struct {
	DefaultProcessor
	Prefix    string
	HostNames []string
}

func (*Prefix) Before

func (p *Prefix) Before(ctx *RenderContext, node *ResourceNode) error

func (*Prefix) BeforeResource

func (p *Prefix) BeforeResource(resource *data.Resource) error

type Processor

type Processor interface {
	data.Visitor
	RegisterResources(ctx *RenderContext, node *ResourceNode) error
	Before(ctx *RenderContext, node *ResourceNode) error
	After(ctx *RenderContext, node *ResourceNode) error
	GetType() string
	BeforeResource(*data.Resource) error
	AfterResource(*data.Resource) error
	GetScope() string
	SetScope(scope string)
	ToString() string
}

func CreateCleanup

func CreateCleanup(outputDir string, All bool) Processor

func CreateTransformation

func CreateTransformation(processorTypeName string) (Processor, error)

func CreateTransformationWithConfig

func CreateTransformationWithConfig(processorTypeName string, config *yaml.MapSlice) (Processor, error)

func ParseTransformations

func ParseTransformations(inputDir string) ([]Processor, error)

read transformations from ./transformations/... files

func ReadProcessorDefinition

func ReadProcessorDefinition(data []byte) ([]Processor, error)

read processor definitions from raw yaml file

func ReadProcessorDefinitionFile

func ReadProcessorDefinitionFile(filename string) ([]Processor, error)

read processor definitions from a file (./definitions/xxx)

type ProcessorDefinition

type ProcessorDefinition struct {
	Metadata ProcessorMetadata //metadata to define the name and available parameters
	Factory  ProcessorFactory  //the factory the create the struct
}

type ProcessorFactory

type ProcessorFactory = func(slice *yaml.MapSlice) (Processor, error)

type ProcessorMetadata

type ProcessorMetadata struct {
	Name        string
	Description string
	Parameters  []ProcessorParameter `yaml:"parameters"`
	Doc         string
	Resources   string //directory point to additional resources

}

func ParseDefinition

func ParseDefinition(date []byte) (ProcessorMetadata, string, error)

func (*ProcessorMetadata) FindParam

func (metadata *ProcessorMetadata) FindParam(name string) *ProcessorParameter

type ProcessorParameter

type ProcessorParameter struct {
	Name        string
	Description string
	Required    bool
	Default     string
	Type        string
}

type ProcessorTypes

type ProcessorTypes struct {
	TypeMap map[string]ProcessorDefinition
}

The main processor registry

var ProcessorTypeRegistry ProcessorTypes

func (*ProcessorTypes) Add

func (pt *ProcessorTypes) Add(definition ProcessorDefinition)

func (*ProcessorTypes) Create

func (pt *ProcessorTypes) Create(name string, parameters map[string]string) (Processor, error)

type PublishService

type PublishService struct {
	DefaultProcessor
	Trigger     Trigger
	ServiceType string         `json:"serviceType"`
	NodePorts   map[string]int `json:"nodePorts"`
}

func (*PublishService) Before

func (processor *PublishService) Before(ctx *RenderContext, node *ResourceNode) error

func (*PublishService) ToString

func (processor *PublishService) ToString() string

type Remove

type Remove struct {
	DefaultProcessor
	Path    data.Path
	Trigger Trigger
	Yamlize bool
}

func (*Remove) BeforeResource

func (processor *Remove) BeforeResource(resource *data.Resource) error

type RenderContext

type RenderContext struct {
	OutputDir     string
	Conf          data.Configuration
	Mode          string
	ImageOverride string
	Namespace     string
	RootResource  *ResourceNode
}

func CreateRenderContext

func CreateRenderContext(mode string, inputDir string, outputDir string) *RenderContext

func TestDirAndCompare

func TestDirAndCompare(t *testing.T, inputDir string, outputDir string, expectedDir string) *RenderContext

func TestExample

func TestExample(t *testing.T, name string) *RenderContext

func TestFromDir

func TestFromDir(t *testing.T, dir string) *RenderContext

func (*RenderContext) AddAdHocTransformations

func (context *RenderContext) AddAdHocTransformations(transformations []string) error

func (*RenderContext) AddResources

func (context *RenderContext) AddResources(resources ...*data.Resource)

func (*RenderContext) AppendCustomProcessor

func (context *RenderContext) AppendCustomProcessor(name string, parameters map[string]string) error

func (*RenderContext) AppendProcessor

func (context *RenderContext) AppendProcessor(processor Processor)

func (*RenderContext) Init

func (context *RenderContext) Init() error

func (*RenderContext) InitializeTransformations

func (context *RenderContext) InitializeTransformations() error

func (*RenderContext) ListResourceNodes

func (context *RenderContext) ListResourceNodes() []*ResourceNode

func (*RenderContext) LoadDefinitions

func (ctx *RenderContext) LoadDefinitions() error

load transformation definitions from ./definitions dir (all dir)

func (*RenderContext) LoadResourceTree

func (context *RenderContext) LoadResourceTree() error

func (*RenderContext) Render

func (ctx *RenderContext) Render() error

execute all the transformations in the rendercontext.

func (*RenderContext) Resources

func (context *RenderContext) Resources() []*data.Resource

List all the resources from the resource tree.

type Replace

type Replace struct {
	DefaultProcessor
	Path    data.Path
	Trigger Trigger
	Value   interface{}
}

func (*Replace) BeforeResource

func (processor *Replace) BeforeResource(resource *data.Resource) error

func (*Replace) ToString

func (add *Replace) ToString() string

type ResourceLocation

type ResourceLocation struct {
	Name   string      //the name to import the location (like 'ozone')
	Source data.Source //the source used to load the resource
	Dir    string      //absolute path of the location
}

type ResourceNode

type ResourceNode struct {
	Name   string      //the original import name used in FLekszible files
	Dir    string      //absolut path of the current dir
	Origin data.Source //source used to load the resource

	Destination              string
	Resources                []*data.Resource
	Children                 []*ResourceNode
	PreImportTransformations []byte
	Source                   []data.Source
	ProcessorRepository      *TransformationRepository
	ResourcesDir             string
	Definitions              []string //definitions loaded from this dir
}

func CreateResourceNode

func CreateResourceNode(name string, dir string, destination string, source data.Source) *ResourceNode

func (*ResourceNode) AllResources

func (node *ResourceNode) AllResources() []*data.Resource

func (*ResourceNode) Execute

func (node *ResourceNode) Execute(context *RenderContext, functionCall execute) error

func (*ResourceNode) InitializeTransformations

func (node *ResourceNode) InitializeTransformations(context *RenderContext) error

func (*ResourceNode) LoadDefinitions

func (node *ResourceNode) LoadDefinitions() error

func (*ResourceNode) LoadResourceConfig

func (node *ResourceNode) LoadResourceConfig(sourceCache *data.SourceCacheManager, outputDir string) error

parse the directory structure and the flekszible configs from the dirs

type Run

type Run struct {
	DefaultProcessor
	Args    string
	Trigger Trigger
}

func (*Run) BeforeResource

func (run *Run) BeforeResource(resource *data.Resource) error

type ToStringBuilder

type ToStringBuilder struct {
	// contains filtered or unexported fields
}

func CreateToString

func CreateToString(name string) *ToStringBuilder

func (*ToStringBuilder) Add

func (builder *ToStringBuilder) Add(key string, value string) *ToStringBuilder

func (*ToStringBuilder) AddBool

func (builder *ToStringBuilder) AddBool(key string, value bool) *ToStringBuilder

func (*ToStringBuilder) AddValue

func (builder *ToStringBuilder) AddValue(key string, value interface{}) *ToStringBuilder

func (*ToStringBuilder) Build

func (builder *ToStringBuilder) Build() string

type TransformationRepository

type TransformationRepository struct {
	Processors []Processor
}

the instatiated transformations for a specific run

func CreateProcessorRepository

func CreateProcessorRepository() *TransformationRepository

func (*TransformationRepository) Append

func (repository *TransformationRepository) Append(processor Processor)

func (*TransformationRepository) AppendAll

func (repository *TransformationRepository) AppendAll(processors []Processor)

func (*TransformationRepository) InsertToBeginning

func (repository *TransformationRepository) InsertToBeginning(processor Processor)

type Trigger

type Trigger struct {
	Definition data.Node
}

func (*Trigger) UnmarshalYAML

func (trigger *Trigger) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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