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 ¶
- func GetConfigGenAnnotion(ps *parameters.Parameters) map[string]string
- func GetGenAnnotionForType(ps *parameters.Parameters, pType parameters.ParameterType) map[string]string
- func GetObjects(s Component) map[int]objects.Object
- func GetSecretGenAnnotion(ps *parameters.Parameters) map[string]string
- func Init(s Component, c client.Client, owner interfaces.Object) error
- func InitParametersValueFrom(s Component, c client.Client, owner interfaces.Object) error
- func ParametersFromSources(srcs *Sources, c client.Client, owner interfaces.Object) (*parameters.Parameters, error)
- func TemplateValues(s Component) map[string]interface{}
- type Component
- type Config
- type CreateOptions
- type Settings
- func (in *Settings) DeepCopy() *Settings
- func (in *Settings) DeepCopyInto(out *Settings)
- func (s *Settings) GetConfig() Config
- func (s *Settings) GetCreateOptions() *CreateOptions
- func (s *Settings) GetMeta() meta.Instance
- func (s *Settings) GetObjects() map[int]objects.Object
- func (s *Settings) Init(c client.Client, owner interfaces.Object) error
- func (s *Settings) SetDefaults()
- type SettingsGenerate
- type SettingsSpec
- type SettingsType
- type Source
- type Sources
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 ¶
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 InitParametersValueFrom ¶
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 ¶
TemplateValues returns the component as values for the template function
Types ¶
type Config ¶
type Config interface { GetParameters() *parameters.Parameters GetSources() *Sources }
func MergeSettings ¶
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 ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Settings.
func (*Settings) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Settings) GetCreateOptions ¶
func (s *Settings) GetCreateOptions() *CreateOptions
GetCreateOptions return the CreateOptions
func (*Settings) GetObjects ¶
GetCreateOptions return the CreateOptions
func (*Settings) Init ¶
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 ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Source.
func (*Source) DeepCopyInto ¶
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 (Sources) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Sources.
func (Sources) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.