config

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinContext

func JoinContext(parent context.Context, contextWithConfig context.Context) context.Context

JoinContext returns a new context that contains a reference to the Config from the specified context. This function panics if the provided context does not contain a Config. This function is thread-safe.

func NewContext

func NewContext() context.Context

NewContext returns a new context with an empty Config.

func NewContextWithDefaultConfig

func NewContextWithDefaultConfig() context.Context

NewContextWithDefaultConfig returns a new context with a default Config.

func SetContext

func SetContext(ctx context.Context, setFn func(config *Config))

SetContext allows the Config in the provided context to be updated. This function panics if the provided context is nil, does not contain a Config, or setFn is nil. This function is thread-safe.

func SliceToString

func SliceToString(s []string) string

SliceToString returns a comma-separated string for the provided slice. Any "," characters in the elements themselves are escaped with the "\" character. Empty elements or elements that are empty after all leading/trailing white- space is trimmed are ignored.

func StringToSet

func StringToSet(s string) map[string]struct{}

func StringToSlice

func StringToSlice(s string) []string

func UpdateContext

func UpdateContext(ctx context.Context, setFn func(config *Config)) context.Context

UpdateContext allows the Config in the provided context to be updated. This function returns the same context passed into the ctx parameter. This function panics if the provided context is nil, does not contain a Config, or setFn is nil. This function is thread-safe.

func WithConfig

func WithConfig(config Config) context.Context

WithConfig returns a new context with the provided Config.

func WithContext

func WithContext(parent context.Context, config Config) context.Context

WithContext sets the provided Config in the provided context. If ctx is nil, one is created with context.Background.

Types

type Config

type Config struct {
	BuildCommit  string
	BuildNumber  string
	BuildVersion string
	BuildType    string

	ContainerNode bool

	ContentAPIWait  time.Duration
	JSONExtraConfig string

	// DefaultVMClassControllerName is the default value for the
	// VirtualMachineClass field spec.controllerName.
	//
	// Defaults to vmoperator.vmware.com/vsphere.
	DefaultVMClassControllerName string

	// Features reflects the feature states.
	Features FeatureStates

	// InstanceStorage contains configuration details related to the instance
	// storage feature.
	InstanceStorage InstanceStorage

	LeaderElectionID        string
	MaxConcurrentReconciles int

	// MaxCreateVMsOnProvider is the percentage of reconciler threads that can
	// be used to create VMs on the provider concurrently.
	//
	// Defaults to 80.
	MaxCreateVMsOnProvider int

	// MaxDeployThreadsOnProvider is the number of threads used to deploy VMs
	// concurrently.
	//
	// Callers should not read this value directly, instead callers should use
	// the GetMaxDeployThreadsOnProvider function.
	MaxDeployThreadsOnProvider int

	NetworkProviderType  NetworkProviderType
	VSphereNetworking    bool
	LoadBalancerProvider string

	PodName               string
	PodNamespace          string
	PodServiceAccountName string

	// PrivilegedUsers is a comma-delimited a list of users that are, in
	// addition to the kube-admin and system users, treated as privileged by
	// VM Operator, ex. allowed to make changes to certain
	// annotations/labels/properties on resources.
	//
	// For information as to why this field is not a []string, please see the
	// GoDocs for the Config type.
	PrivilegedUsers string

	ProfilerAddr                 string
	RateLimitBurst               int
	RateLimitQPS                 int
	SyncPeriod                   time.Duration
	WatchNamespace               string
	WebhookServiceContainerPort  int
	WebhookServiceName           string
	WebhookServiceNamespace      string
	WebhookSecretName            string
	WebhookSecretNamespace       string
	WebhookSecretVolumeMountPath string
}

Config represents the internal configuration of VM Operator. It should only be read/written via the context functions.

Please note that all fields in this type MUST be types that are copied by value, not reference. That means no string slices, maps, etc. The reason is to prevent the possibility of race conditions when reading/writing data to a Config instance stored in a context.

func Default

func Default() Config

Default returns a Config object with default values.

func FromContext

func FromContext(ctx context.Context) Config

FromContext returns the Config from the provided context. This function panics if the provided context is nil or does not contain a Config. This function is thread-safe.

func FromEnv

func FromEnv() Config

FromEnv returns a new Config that has been initialized from environment variables.

func (Config) GetMaxDeployThreadsOnProvider

func (c Config) GetMaxDeployThreadsOnProvider() int

GetMaxDeployThreadsOnProvider returns MaxDeployThreadsOnProvider if it is >0 or returns a percentage of MaxConcurrentReconciles based on MaxCreateVMsOnProvider.

type FeatureStates

type FeatureStates struct {
	AutoVADPBackupRestore      bool // FSS_WCP_VMSERVICE_BACKUPRESTORE
	InstanceStorage            bool // FSS_WCP_INSTANCE_STORAGE
	PodVMOnStretchedSupervisor bool // FSS_PODVMONSTRETCHEDSUPERVISOR
	TKGMultipleCL              bool // FSS_WCP_TKG_Multiple_CL
}

type InstanceStorage

type InstanceStorage struct {
	// PVPlacementFailedTTL is the wait time before declaring PV placement
	// failed after the error annotation is set on a PVC.
	//
	// Defaults to 5m.
	PVPlacementFailedTTL time.Duration

	// JitterMaxFactor is used to configure the exponential backoff jitter for
	// instance storage.
	//
	// Please note that wait.Jitter sets the maxFactor to 1.0 if the input
	// maxFactor is <= 0.0. For example, with a max factor of 1.0 and seed
	// duration of 10s, wait.Jitter returns a requeue delay between 11 and 19.
	// These numbers ensures multiple reconcile threads are not requeuing at the
	// same intervals.
	//
	// Defaults to 1.0.
	JitterMaxFactor float64

	// SeedRequeueDuration is the seed value for requeuing reconcile attempts
	// related to instance storage resources.
	//
	// Defaults to 10s.
	SeedRequeueDuration time.Duration
}

type NetworkProviderType

type NetworkProviderType string
const (
	NetworkProviderTypeNamed NetworkProviderType = "NAMED"
	NetworkProviderTypeNSXT  NetworkProviderType = "NSXT"
	NetworkProviderTypeVDS   NetworkProviderType = "VSPHERE_NETWORK"
	NetworkProviderTypeVPC   NetworkProviderType = "NSXT_VPC"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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