config

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultRunAsUserKey  = "default-run-as-user"
	DefaultRunAsGroupKey = "default-run-as-group"
	DefaultFSGroupKey    = "default-fs-group"

	DefaultServiceAccountValue = "default"
)
View Source
const (
	StableAPIFieldValue = "stable"
	AlphaAPIFieldValue  = "alpha"

	DefaultEnableAPIFields = StableAPIFieldValue
)

Variables

This section is empty.

Functions

func GetDefaultsConfigName

func GetDefaultsConfigName() string

GetDefaultsConfigName returns the name of the configmap containing all defined defaults.

func GetFeatureFlagsConfigName

func GetFeatureFlagsConfigName() string

GetFeatureFlagsConfigName returns the name of the configmap containing all feature flags.

func ToContext

func ToContext(ctx context.Context, c *Config) context.Context

ToContext attaches the provided Config to the provided context, returning the new context with the Config attached.

Types

type Config

type Config struct {
	Defaults     *Defaults
	FeatureFlags *FeatureFlags
}

Config holds the collection of configurations that we attach to contexts. +k8s:deepcopy-gen=false

func FromContext

func FromContext(ctx context.Context) *Config

FromContext extracts a Config from the provided context.

func FromContextOrDefaults

func FromContextOrDefaults(ctx context.Context) *Config

FromContextOrDefaults is like FromContext, but when no Config is attached it returns a Config populated with the defaults for each of the Config fields.

type Defaults

type Defaults struct {
	DefaultServiceAccount string
	DefaultRunAsUser      int64
	DefaultRunAsGroup     int64
	DefaultFSGroup        int64
	DefaultRunAsNonRoot   bool
	// These three fields are used to decide whether to configure
	// runAsUser, runAsGroup and fsGroup within a Security Context Constraint (SCC).
	IsDefaultRunAsUserEmpty  bool
	IsDefaultRunAsGroupEmpty bool
	IsDefaultFsGroupEmpty    bool
}

Defaults holds the default configurations +k8s:deepcopy-gen=true

func NewDefaultsFromConfigMap

func NewDefaultsFromConfigMap(config *corev1.ConfigMap) (*Defaults, error)

NewDefaultsFromConfigMap returns a Config for the given configmap

func NewDefaultsFromMap

func NewDefaultsFromMap(cfgMap map[string]string) (*Defaults, error)

NewDefaultsFromMap returns a Config given a map corresponding to a ConfigMap

func (*Defaults) DeepCopy

func (in *Defaults) DeepCopy() *Defaults

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

func (*Defaults) DeepCopyInto

func (in *Defaults) DeepCopyInto(out *Defaults)

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

func (*Defaults) Equals

func (cfg *Defaults) Equals(other *Defaults) bool

Equals returns true if two Configs are identical

type FeatureFlags

type FeatureFlags struct {
	// EnableAPIFields determines which gated features are enabled.
	// Acceptable values are "stable" or "alpha". Defaults to "stable"
	EnableAPIFields string
	// LabelsExclusionPattern determines the regex pattern to use to exclude
	// labels being propagated to resources created by the EventListener
	LabelsExclusionPattern string
}

FeatureFlags holds the features configurations +k8s:deepcopy-gen=true

func NewFeatureFlagsFromConfigMap

func NewFeatureFlagsFromConfigMap(config *corev1.ConfigMap) (*FeatureFlags, error)

NewFeatureFlagsFromConfigMap returns a Config for the given configmap

func NewFeatureFlagsFromMap

func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error)

NewFeatureFlagsFromMap returns a Config given a map corresponding to a ConfigMap

func (*FeatureFlags) DeepCopy

func (in *FeatureFlags) DeepCopy() *FeatureFlags

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

func (*FeatureFlags) DeepCopyInto

func (in *FeatureFlags) DeepCopyInto(out *FeatureFlags)

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

type Store

type Store struct {
	*configmap.UntypedStore
}

Store is a typed wrapper around configmap.Untyped store to handle our configmaps. +k8s:deepcopy-gen=false

func NewStore

func NewStore(logger configmap.Logger, onAfterStore ...func(name string, value interface{})) *Store

NewStore creates a new store of Configs and optionally calls functions when ConfigMaps are updated.

func (*Store) Load

func (s *Store) Load() *Config

Load creates a Config from the current config state of the Store.

func (*Store) ToContext

func (s *Store) ToContext(ctx context.Context) context.Context

ToContext attaches the current Config state to the provided context.

Jump to

Keyboard shortcuts

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