settings

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextKey = Registration
View Source
var Registration = &config.Registration{
	ConfigMapName: "karpenter-global-settings",
	Constructor:   NewSettingsFromConfigMap,
}

Functions

func AsMap

func AsMap(key string, target *map[string]string) configmap.ParseFunc

AsMap parses any value with the prefix key into a map with suffixes as keys and values as values in the target map. e.g. {"aws.tags.tag1":"value1"} gets parsed into the map Tags as {"tag1": "value1"}

func AsTypedString

func AsTypedString[T ~string](key string, target *T) configmap.ParseFunc

AsTypedString passes the value at key through into the target, if it exists.

func FromMap

func FromMap(data map[string]string) func(key string, target *map[string]string) error

FromMap takes values from a map and rewinds the values into map[string]string values where the key contains the prefix key and the value is the map value. e.g. {"tag1": "value1"} becomes {"aws.tags.tag1": "value1"} when passed the key "aws.tags"

func ToContext

func ToContext(ctx context.Context, s Settings) context.Context

Types

type NodeNameConvention

type NodeNameConvention string
const (
	IPName       NodeNameConvention = "ip-name"
	ResourceName NodeNameConvention = "resource-name"
)

type Settings

type Settings struct {
	ClusterName                string             `json:"aws.clusterName" validate:"required"`
	ClusterEndpoint            string             `json:"aws.clusterEndpoint" validate:"required"`
	DefaultInstanceProfile     string             `json:"aws.defaultInstanceProfile"`
	EnablePodENI               bool               `json:"aws.enablePodENI,string"`
	EnableENILimitedPodDensity bool               `json:"aws.enableENILimitedPodDensity,string"`
	IsolatedVPC                bool               `json:"aws.isolatedVPC,string"`
	NodeNameConvention         NodeNameConvention `json:"aws.nodeNameConvention" validate:"required"`
	VMMemoryOverheadPercent    float64            `json:"aws.vmMemoryOverheadPercent,string" validate:"min=0"`
	InterruptionQueueName      string             `json:"aws.interruptionQueueName,string"`
	Tags                       map[string]string  `json:"aws.tags,omitempty"`
}

func FromContext

func FromContext(ctx context.Context) Settings

func NewSettingsFromConfigMap

func NewSettingsFromConfigMap(cm *v1.ConfigMap) (Settings, error)

NewSettingsFromConfigMap creates a Settings from the supplied ConfigMap

func (Settings) Data

func (s Settings) Data() (map[string]string, error)

func (Settings) Validate

func (s Settings) Validate() error

Validate leverages struct tags with go-playground/validator so you can define a struct with custom validation on fields i.e.

type ExampleStruct struct {
    Example  metav1.Duration `json:"example" validate:"required,min=10m"`
}

Jump to

Keyboard shortcuts

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