transformer

package
v0.3.3-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LinuxFileSeperator is used to join paths for linux container file system
	LinuxFileSeperator = "/"
)
View Source
const (
	// ResourceRequestKey is the config key for resource requests
	ResourceRequestKey = "ResourceRequest"
)

Variables

This section is empty.

Functions

func Destroy

func Destroy()

Destroy destroys the transformers

func GetServices

func GetServices(prjName string, dir string) (map[string][]plantypes.PlanArtifact, error)

GetServices returns the list of services detected in a directory

func Init

func Init(assetsPath, sourcePath string, selector labels.Selector, outputPath, projName string) (err error)

Init initializes the transformers

func InitTransformers

func InitTransformers(transformerToInit map[string]string, selector labels.Selector, sourcePath string, outputPath, projName string, logError bool) error

InitTransformers initializes a subset of transformers

func RegisterTransformer added in v0.3.3

func RegisterTransformer(tf Transformer) error

RegisterTransformer allows for adding transformers after initialization

func Transform

func Transform(planArtifacts []plantypes.PlanArtifact, sourceDir, outputPath string) error

Transform transforms as per the plan

Types

type CNBContainerizer added in v0.3.3

type CNBContainerizer struct {
	Config              transformertypes.Transformer
	BuilderImageNameCfg artifacts.ImageName
	Env                 *environment.Environment
	CNBEnv              *environment.Environment
}

CNBContainerizer implements Containerizer interface

func (*CNBContainerizer) DirectoryDetect added in v0.3.3

func (t *CNBContainerizer) DirectoryDetect(dir string) (services map[string][]transformertypes.Artifact, err error)

DirectoryDetect runs detect in each sub directory

func (*CNBContainerizer) GetConfig added in v0.3.3

GetConfig returns the transformer config

func (*CNBContainerizer) Init added in v0.3.3

Init Initializes the transformer

func (*CNBContainerizer) Transform added in v0.3.3

func (t *CNBContainerizer) Transform(newArtifacts []transformertypes.Artifact, oldArtifacts []transformertypes.Artifact) (tPathMappings []transformertypes.PathMapping, tArtifacts []transformertypes.Artifact, err error)

Transform transforms the artifacts

type CloudFoundry

type CloudFoundry struct {
	Config transformertypes.Transformer
	Env    *environment.Environment
}

CloudFoundry implements Transformer interface

func (*CloudFoundry) DirectoryDetect

func (t *CloudFoundry) DirectoryDetect(dir string) (services map[string][]transformertypes.Artifact, err error)

DirectoryDetect detects cloud foundry projects in various directories

func (*CloudFoundry) GetConfig

GetConfig returns the transformer config

func (*CloudFoundry) Init

Init Initializes the transformer

func (*CloudFoundry) Transform

func (t *CloudFoundry) Transform(newArtifacts []transformertypes.Artifact, alreadySeenArtifacts []transformertypes.Artifact) ([]transformertypes.PathMapping, []transformertypes.Artifact, error)

Transform transforms the artifacts

type ReadMeGenerator

type ReadMeGenerator struct {
	Config transformertypes.Transformer
	Env    *environment.Environment
}

ReadMeGenerator implements Transformer interface

func (*ReadMeGenerator) DirectoryDetect

func (t *ReadMeGenerator) DirectoryDetect(dir string) (services map[string][]transformertypes.Artifact, err error)

DirectoryDetect executes detect in directories respecting the m2kignore

func (*ReadMeGenerator) GetConfig

GetConfig returns the config of the transformer

func (*ReadMeGenerator) Init

Init initializes the translator

func (*ReadMeGenerator) Transform

Transform transforms the artifacts

type Router

type Router struct {
	Config       transformertypes.Transformer
	Env          *environment.Environment
	RouterConfig *RouterYamlConfig
}

Router implements Transformer interface

func (*Router) DirectoryDetect

func (t *Router) DirectoryDetect(dir string) (services map[string][]transformertypes.Artifact, err error)

DirectoryDetect runs detects if necessary

func (*Router) GetConfig

GetConfig returns the transformer config

func (*Router) GetStringFromTemplate

func (t *Router) GetStringFromTemplate(templateString string, artifact transformertypes.Artifact) (filledString string, err error)

GetStringFromTemplate Translates question properties from templates to string

func (*Router) Init

Init Initializes the transformer

func (*Router) Transform

func (t *Router) Transform(newArtifacts []transformertypes.Artifact, alreadySeenArtifacts []transformertypes.Artifact) ([]transformertypes.PathMapping, []transformertypes.Artifact, error)

Transform transforms the artifacts

type RouterQuestion

type RouterQuestion struct {
	ID    string   `yaml:"id" json:"id"`
	Desc  string   `yaml:"description,omitempty" json:"description,omitempty"`
	Hints []string `yaml:"hints,omitempty" json:"hints,omitempty"`
}

RouterQuestion stores the templated question for Router

type RouterYamlConfig

type RouterYamlConfig struct {
	TransformerSelector metav1.LabelSelector `yaml:"transformerSelector" json:"transformerSelector"`
	RouterQuestion      RouterQuestion       `yaml:"question" json:"question"`
}

RouterYamlConfig stores the yaml configuration for Router transformer

type Transformer

type Transformer interface {
	Init(tc transformertypes.Transformer, env *environment.Environment) (err error)
	// GetConfig returns the transformer config
	GetConfig() (transformertypes.Transformer, *environment.Environment)
	DirectoryDetect(dir string) (services map[string][]transformertypes.Artifact, err error)
	Transform(newArtifacts []transformertypes.Artifact, alreadySeenArtifacts []transformertypes.Artifact) ([]transformertypes.PathMapping, []transformertypes.Artifact, error)
}

Transformer interface defines transformer that transforms files and converts it to ir representation

func GetInitializedTransformers

func GetInitializedTransformers() []Transformer

GetInitializedTransformers returns the list of initialized transformers

func GetInitializedTransformersF

func GetInitializedTransformersF(filters labels.Selector) []Transformer

GetInitializedTransformersF returns the list of initialized transformers after filtering

func GetTransformerByName added in v0.3.1

func GetTransformerByName(name string) (t Transformer, err error)

GetTransformerByName returns the transformer chosen by name

Jump to

Keyboard shortcuts

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