parameterizer

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PackagingKind is the kind for Packaging yamls
	PackagingKind = "Packaging"
	// ParameterizerKind is the kind for Parameterizer yamls
	ParameterizerKind = "Parameterizer"
	// ReplaceOp replaces the value at the key with a different value
	ReplaceOp PatchOpT = "replace"
	// AddOp inserts a value at the key
	AddOp PatchOpT = "add"
	// RemoveOp removes the value at the key
	RemoveOp PatchOpT = "remove"
	// TargetHelm is used when the target is the parameterization of Helm
	TargetHelm ParamTargetT = "helm"
	// TargetKustomize is used when the target is the parameterization of Kustomize
	TargetKustomize ParamTargetT = "kustomize"
	// TargetOCTemplates is used when the target is the parameterization of Openshift Templates
	TargetOCTemplates ParamTargetT = "openshifttemplates"
	// ParamQuesIDPrefix is used as a prefix when the key is not specified in the questions in a parameterizer
	ParamQuesIDPrefix = common.BaseKey + common.Delim + "parameterization"
)

Variables

This section is empty.

Functions

func CollectParamsFromPath

func CollectParamsFromPath(parameterizersDir string) (map[string][]ParameterizerT, error)

CollectParamsFromPath returns parameterizers found in a directory

func GetSubKeys

func GetSubKeys(key string) []string

GetSubKeys returns the parts of a key. Example aaa.bbb."ccc ddd".eee.fff -> {"aaa", "bbb", "ccc ddd", "eee", "fff"}

func Parameterize

func Parameterize(srcDir, outDir string, packSpecConfig ParameterizerConfigT, ps []ParameterizerT) ([]string, error)

Parameterize does the parameterization based on a spec

Types

type FilterT

type FilterT struct {
	Kind       string   `yaml:"kind,omitempty" json:"kind,omitempty"`
	APIVersion string   `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
	Name       string   `yaml:"name,omitempty" json:"name,omitempty"`
	Envs       []string `yaml:"envs,omitempty" json:"envs,omitempty"`
}

FilterT is used to choose the k8s resources that the parameterizer should be applied on

type HelmValuesT

type HelmValuesT map[string]interface{}

HelmValuesT has Helm Values

type OCParamT

type OCParamT struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

OCParamT is the type for a single Openshift Templates parameter

type ParamOrStringT

type ParamOrStringT struct {
	IsParam bool
	Data    string
}

ParamOrStringT is string along with a flag to indicate if it is a parameter

type ParamTargetT

type ParamTargetT string

ParamTargetT has Param Target

type ParameterT

type ParameterT struct {
	Name              string            `yaml:"name" json:"name"`
	Default           string            `yaml:"default,omitempty" json:"default,omitempty"`
	HelmTemplate      string            `yaml:"helmTemplate,omitempty" json:"helmTemplate,omitempty"`
	OpenshiftTemplate string            `yaml:"openshiftTemplate,omitempty" json:"openshiftTemplate,omitempty"`
	Values            []ParameterValueT `yaml:"values,omitempty" json:"values,omitempty"`
}

ParameterT is used to specify the environment specific defaults for the keys in the template

type ParameterValueT

type ParameterValueT struct {
	Envs         []string          `yaml:"envs,omitempty" json:"envs,omitempty"`
	Kind         string            `yaml:"kind,omitempty" json:"kind,omitempty"`
	APIVersion   string            `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
	MetadataName string            `yaml:"metadataName,omitempty" json:"metadataName,omitempty"`
	Custom       map[string]string `yaml:"custom,omitempty" json:"custom,omitempty"`
	Value        string            `yaml:"value" json:"value"`
}

ParameterValueT is used to specify the value for a parameter in different contexts

type ParameterizerConfigT

type ParameterizerConfigT struct {
	ProjectName string   `yaml:"projectName,omitempty" json:"projectName,omitempty"`
	Helm        string   `yaml:"helm,omitempty" json:"helm,omitempty"`
	Kustomize   string   `yaml:"kustomize,omitempty" json:"kustomize,omitempty"`
	OCTemplates string   `yaml:"openshiftTemplates,omitempty" json:"openshiftTemplates,omitempty"`
	Envs        []string `yaml:"envs,omitempty" json:"envs,omitempty"`
}

ParameterizerConfigT is the set of paths to be parameterized

type ParameterizerFileT

type ParameterizerFileT struct {
	metav1.TypeMeta   `yaml:",inline" json:",inline"`
	metav1.ObjectMeta `yaml:"metadata" json:"metadata"`
	Spec              ParameterizerSpecT `yaml:"spec" json:"spec"`
}

ParameterizerFileT is the file format for the parameterizers

type ParameterizerSpecT

type ParameterizerSpecT struct {
	Parameterizers []ParameterizerT `yaml:"parameterizers" json:"parameterizers"`
}

ParameterizerSpecT is the spec inside the parameterizers file

type ParameterizerT

type ParameterizerT struct {
	Target                     string            `yaml:"target" json:"target"`
	Template                   string            `yaml:"template,omitempty" json:"template,omitempty"`
	Regex                      string            `yaml:"regex,omitempty" json:"regex,omitempty"`
	KeepOriginalValueIfPresent bool              `yaml:"keepOriginalValueIfPresent,omitempty" json:"keepOriginalValueIfPresent,omitempty"`
	Default                    interface{}       `yaml:"default,omitempty" json:"default,omitempty"`
	Question                   *qaengine.Problem `yaml:"question,omitempty" json:"question,omitempty"`
	Filters                    []FilterT         `yaml:"filters,omitempty" json:"filters,omitempty"`
	Parameters                 []ParameterT      `yaml:"parameters,omitempty" json:"parameters,omitempty"`
}

ParameterizerT is a paramterizer

type PatchMetadataT

type PatchMetadataT struct {
	Path   string               `yaml:"path"`
	Target PatchMetadataTargetT `yaml:"target"`
}

PatchMetadataT is contains the target k8s resources and the patch filename

type PatchMetadataTargetT

type PatchMetadataTargetT struct {
	Group     string `yaml:"group"`
	Version   string `yaml:"version"`
	Kind      string `yaml:"kind"`
	Namespace string `yaml:"namespace,omitempty"`
	Name      string `yaml:"name"`
}

PatchMetadataTargetT is used to specify the target k8s resource that the json path should be applied on (this is specific to kustomize)

type PatchOpT

type PatchOpT string

PatchOpT has Patch

type PatchT

type PatchT struct {
	Op    PatchOpT    `yaml:"op"`
	Path  string      `yaml:"path"`
	Value interface{} `yaml:"value"`
}

PatchT represents a single json patch https://tools.ietf.org/html/rfc6902

type RT

type RT struct {
	Key     []string
	Value   interface{}
	Matches map[string]string
}

RT has Key, Value and Matches

func GetAll

func GetAll(key string, resource interface{}) ([]RT, error)

GetAll returns all the keys that matched and all corresponding values

Jump to

Keyboard shortcuts

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