settings

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: 10 Imported by: 0

Documentation

Overview

Package settings provides some api types and interfaces to manage settings in kubernetes

Settings can be provided in: - The parent CRD with the parameter type - ConfigMaps and Secrets

Settings can be passed to a container: - As EnvVar in the container spec (name & value) - As EnvVarFrom in the container spec with a fromKey and secret/configMap source - As EnvVarFrom object - As EnvFrom mounting all the data from a secret/configmap as env var - As a file configmap/secret

Settings value: - can be randomly generate - provided in the crd - generate by template - provided in a resource in the same namespace - only secrets and configmaps are supported

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigGenAnnotion

func GetConfigGenAnnotion(ps *parameters.Parameters) map[string]string

func GetGenAnnotionForType

func GetGenAnnotionForType(ps *parameters.Parameters, pType parameters.ParameterType) map[string]string

func GetObjects

func GetObjects(s Component) map[int]objects.Object

GetObjects returns an ordered list of objects.Object interfaces. Annotations are added for the generated parameters. Only secrets and configmaps are supported.

func GetSecretGenAnnotion

func GetSecretGenAnnotion(ps *parameters.Parameters) map[string]string

func Init

func Init(s Component, c client.Client, owner interfaces.Object) error

func InitParametersValueFrom

func InitParametersValueFrom(s Component, c client.Client, owner interfaces.Object) error

InitParametersValueFrom intialise the parameters with values provided in external resources in the same namespace. All parameters values are filled from those resources and new parameters are appended. Only Secrets and Configmaps are supported.

func ParametersFromSources

func ParametersFromSources(srcs *Sources, c client.Client, owner interfaces.Object) (*parameters.Parameters, error)

ParametersFromSources returns the parameters from external resources that are provided in the sources. Owner is provided to check if resources is owned in that case, only generated data defined in the annotations are fetched. Only Secrets and Configmaps are supported.

func TemplateValues

func TemplateValues(s Component) map[string]interface{}

TemplateValues returns the component as values for the template function

Types

type Component

type Component interface {
	GetMeta() meta.Instance
	GetConfig() Config
	SetDefaults()
	Config
	GetCreateOptions() *CreateOptions
	GetObjects() map[int]objects.Object
}

type Config

type Config interface {
	GetParameters() *parameters.Parameters
	GetSources() *Sources
}

func MergeSettings

func MergeSettings(src, dest Config) Config

type CreateOptions

type CreateOptions struct {
	CommonMeta   *meta.ObjectMeta `json:"commonMeta,omitempty"`
	SecretMeta   *meta.ObjectMeta `json:"secretMeta,omitempty"`
	ConfigMeta   *meta.ObjectMeta `json:"configMeta,omitempty"`
	Generate     SettingsGenerate `json:"generate,omitempty"`
	SettingsType SettingsType     `json:"type,omitempty"`
}

+kubebuilder:object:generate=true

func (*CreateOptions) DeepCopy

func (in *CreateOptions) DeepCopy() *CreateOptions

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

func (*CreateOptions) DeepCopyInto

func (in *CreateOptions) DeepCopyInto(out *CreateOptions)

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

func (*CreateOptions) Init

func (opts *CreateOptions) Init()

type Settings

type Settings struct {
	CreateOptions *CreateOptions `json:"createOptions,omitempty"`
	*SettingsSpec `json:",inline"`
}

+kubebuilder:object:generate=true

func NewSettings

func NewSettings(co *CreateOptions, srcs *Sources, ps *parameters.Parameters) *Settings

NewSettings returns a Settings struct

func (*Settings) DeepCopy

func (in *Settings) DeepCopy() *Settings

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

func (*Settings) DeepCopyInto

func (in *Settings) DeepCopyInto(out *Settings)

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

func (*Settings) GetConfig

func (s *Settings) GetConfig() Config

GetConfig return the SettingsSpec

func (*Settings) GetCreateOptions

func (s *Settings) GetCreateOptions() *CreateOptions

GetCreateOptions return the CreateOptions

func (*Settings) GetMeta

func (s *Settings) GetMeta() meta.Instance

GetMeta return the meta.Instance interface

func (*Settings) GetObjects

func (s *Settings) GetObjects() map[int]objects.Object

GetCreateOptions return the CreateOptions

func (*Settings) Init

func (s *Settings) Init(c client.Client, owner interfaces.Object) error

Init initialise the settings. ObjectMeta are set from commons meta. Parameters are initialised from external resources set in ValueFrom and random values are generated.

func (*Settings) SetDefaults

func (s *Settings) SetDefaults()

SetDefaults sets the defaults from the create options

type SettingsGenerate

type SettingsGenerate string
const (
	// Generate settings as env variables in a configMap or Secret
	GenEnvFile SettingsGenerate = "envFile"
)

type SettingsSpec

type SettingsSpec struct {
	// Sources is a list of sources for the parameters from kubernetes resources in the same namespace
	// Sources []Source `json:"sources,omitempty"`
	Sources *Sources `json:"sources,omitempty"`
	// Parameters is a list of parameters
	*parameters.Parameters `json:"parameters,omitempty"`
}

SettingsSpec defines a list of parameters and references to resources from which those parameters can be fetched Only secrets and configmaps in the same namespace are supported as references +kubebuilder:object:generate=true

func (*SettingsSpec) DeepCopy

func (in *SettingsSpec) DeepCopy() *SettingsSpec

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

func (*SettingsSpec) DeepCopyInto

func (in *SettingsSpec) DeepCopyInto(out *SettingsSpec)

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

func (*SettingsSpec) GetEnvFrom

func (c *SettingsSpec) GetEnvFrom() []corev1.EnvFromSource

GetEnvFrom returns a list of EnvFromSource to populate environment variables in the container.

func (*SettingsSpec) GetParameters

func (c *SettingsSpec) GetParameters() *parameters.Parameters

GetParameters return the parameters

func (*SettingsSpec) GetSources

func (c *SettingsSpec) GetSources() *Sources

GetSources return the sources

type SettingsType

type SettingsType string
const (
	// Generate settings as env variables in a configMap or Secret
	SecretSettings SettingsType = "secret"
)

type Source

type Source struct {
	// Ref is the name of a resource in the same namespace
	Ref string `json:"ref,omitempty"`
	// Type is the type of the resource
	// Only Secrets and ConfigMaps are supported
	Type string `json:"type,omitempty"`
}

+kubebuilder:object:generate=true

func (*Source) DeepCopy

func (in *Source) DeepCopy() *Source

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

func (*Source) DeepCopyInto

func (in *Source) DeepCopyInto(out *Source)

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

type Sources

type Sources []Source

+kubebuilder:object:generate=true

func AppendSourceIfUnique

func AppendSourceIfUnique(sources *Sources, source Source) *Sources

func (Sources) DeepCopy

func (in Sources) DeepCopy() Sources

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

func (Sources) DeepCopyInto

func (in Sources) DeepCopyInto(out *Sources)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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