parameters

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByKey

func ByKey(p *Parameters) map[string]*Parameter

ByKey returns the parameters sorted by keys

func GetDataFromResource

func GetDataFromResource(c client.Client, obj, owner interfaces.Object) (data map[string]string, err error)

GetDataFromResource return the data as key:value pairs from external resources. If resources are owned by the owner object, only generated resources are returned. Only secrets and configmaps are supported.

func KeyPairValues

func KeyPairValues(p *Parameters) map[string]string

KeyPairValues returns the parameters as key:value pairs

func OrderByResourceRef

func OrderByResourceRef(ps *Parameters) map[ParameterType]map[string]*Parameters

OrderByResourceRef returns a list of parameters ordered reference type and reference name

Types

type Generate

type Generate string
const (
	// Random value
	GenerateRand Generate = "rand"
	// Random value of size 12
	GenerateRand12 Generate = "rand12"
	// Random value of size 24
	GenerateRand24 Generate = "rand24"
	// Value is generated from a template
	// Value container the template and will be replaced
	GenerateTemplate Generate = "template"
)

type MountPath

type MountPath struct {
	Path    string `json:"path,omitempty"`
	SubPath string `json:"subPath,omitempty"`
}

type MountType

type MountType string
const (
	// Parameter is mounted as key/value in the container envVar specs
	MountLiteral MountType = "literal"
	// Parameter is mounted as as  EnvVarSource in the container envVar specs
	// no data is transformed in a new resource
	MountFrom MountType = "from"
	// Parameter is mouned as file in the container path
	MountFile MountType = "file"
	// Parameter is mounted as EnvFromSource in the container specs
	// Data can be retrieved from the crds or external resources specified in the parameter envFrom
	// and transformed in a new secret or configmap
	MountEnvFile MountType = "envFile"
)

type Parameter

type Parameter struct {
	// Key of the parameter, can be mounted as as an environment variable, used in template
	// or as the key in the key:value data fied in the configmap or secret
	//
	// Key must be unique
	Key string `json:"key,omitempty"`
	// Value of the paramater, should not contain secret values
	// If it is a template, ParameterType should be template
	Value string `json:"value,omitempty"`
	// ValueFrom when specified indicates the source of the parameter.
	// Cannot be used if value is not empty.
	ValueFrom `json:",inline"`
	// MountPath specifies where the parameter will be mounted as a file
	MountPath MountPath `json:"mountFrom,omitempty"`
	// Generate if specified defines how the parameter value will be generated
	Generate Generate `json:"generate,omitempty"`
	// Type specifies specifies the parameter type
	Type ParameterType `json:"type,omitempty"`
	// MountType defined how the parameter will be mounted in the pod
	// Defaults to EnvFile
	MountType MountType `json:"mountType,omitempty"`
}

+kubebuilder:object:generate=true

func (*Parameter) DeepCopy

func (in *Parameter) DeepCopy() *Parameter

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Parameter.

func (*Parameter) DeepCopyInto

func (in *Parameter) DeepCopyInto(out *Parameter)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Parameter) GetEnvVar

func (p *Parameter) GetEnvVar() (envVar corev1.EnvVar, err error)

GetEnvVar return the EnvVar to set in the container.

func (*Parameter) GetPodVolume

func (p *Parameter) GetPodVolume() corev1.Volume

GetPodVolume return the Volume to set in the pod.

func (*Parameter) GetVolumeMount

func (p *Parameter) GetVolumeMount() corev1.VolumeMount

GetVolumeMount returns the VolumeMount to set in the container.

func (*Parameter) IsMount

func (p *Parameter) IsMount() bool

IsMount returns if the parameter is mounted in a secret or configmap

func (*Parameter) IsRand

func (p *Parameter) IsRand() bool

IsRand if the the parameter is randomly generated.

type ParameterType

type ParameterType string
const (
	ConfigParameter      ParameterType = "configmap"
	SecretParameter      ParameterType = "secret"
	ObjectFieldParameter ParameterType = "field"
	TemplateValue        ParameterType = "templateValue"
)

type Parameters

type Parameters []*Parameter

+kubebuilder:object:generate=true

func Marshal

func Marshal(i interface{}) (*Parameters, error)

func (Parameters) DeepCopy

func (in Parameters) DeepCopy() Parameters

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Parameters.

func (Parameters) DeepCopyInto

func (in Parameters) DeepCopyInto(out *Parameters)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Parameters) GetConfigData

func (p *Parameters) GetConfigData() map[string]string

GetConfigData returns the parameters of type ConfigParameter as key:value pairs It implements the configmap interface

func (*Parameters) GetData

func (p *Parameters) GetData() map[string]string

GetData returns the data for the secret or configmap as a key:value pairs This function only returns data which should be either in a secret or a configmap

func (*Parameters) GetEnvVar

func (p *Parameters) GetEnvVar() []corev1.EnvVar

GetEnvVar return a list of EnvVar to set in the container.

func (*Parameters) GetPodVolumes

func (p *Parameters) GetPodVolumes() []corev1.Volume

GetPodVolumes returns a list of Volume to set in the pod.

func (*Parameters) GetSecretData

func (p *Parameters) GetSecretData() map[string][]byte

GetSecretData returns the parameters of type ConfigParameter as key:value pairs It implements the secret interface

func (*Parameters) GetVolumeMounts

func (p *Parameters) GetVolumeMounts() []corev1.VolumeMount

GetVolumeMounts returns a list of VolumeMount to set in the container.

func (*Parameters) InitRandValues

func (p *Parameters) InitRandValues()

InitRandValues initialies the parameters random values

func (*Parameters) InitTemplateValues

func (p *Parameters) InitTemplateValues(values map[string]interface{}) error

InitTemplateValues initialies the parameters values from a template and a key pair value set The template shoud be in the parameter value when GenerateTemplate is specified. The values will be replaced from the result of the template processing.

func (*Parameters) InitValueFrom

func (ps *Parameters) InitValueFrom(c client.Client, owner interfaces.Object) error

InitValueFrom intialise the parameters value from external resources Only secrets and configmaps are supported

func (*Parameters) Merge

func (ps *Parameters) Merge(in *Parameters) error

Merge mergers parameters with new parameters. The new parameters provided takes over the parameters and are appended to the parameters if not set.

func (*Parameters) MergeData

func (ps *Parameters) MergeData(data map[string]string) error

MergeData merges the parameters with a set of data provided as key:values pairs. Data values takes over parameters values and are appended to the parameters if not set.

type ValueFrom

type ValueFrom struct {
	// Key to select from the source
	FromKey string `json:"fromKey,omitempty"`
	// Name of the referent.
	Ref string `json:"ref,omitempty"`
	// Type of the parameter's source
	// Defaults to the parameter type if not specified
	RefType ParameterType `json:"refType,omitempty"`
}

Jump to

Keyboard shortcuts

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