config

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 47

Documentation

Overview

Package config holds the typed objects that define the schemas for ConfigMap objects that pertain to our API objects.

Index

Constants

View Source
const (
	// DefaultsConfigName is the name of config map for the defaults.
	DefaultsConfigName = "config-defaults"

	// DefaultRevisionTimeoutSeconds will be set if timeoutSeconds not specified.
	DefaultRevisionTimeoutSeconds = 5 * 60

	// DefaultMaxRevisionTimeoutSeconds will be set if MaxRevisionTimeoutSeconds is not specified.
	DefaultMaxRevisionTimeoutSeconds = 10 * 60

	// DefaultRevisionResponseStartTimeoutSeconds will be set if ResponseStartTimeoutSeconds is not specified.
	// for backward compatibility will keep default similar to DefaultRevisionTimeoutSeconds,
	// should be revised in future releases.
	DefaultRevisionResponseStartTimeoutSeconds = 5 * 60

	// DefaultRevisionIdleTimeoutSeconds will be set if idleTimeoutSeconds not specified.
	DefaultRevisionIdleTimeoutSeconds = 0

	// DefaultInitContainerName is the default name we give to the init containers
	// specified by the user, if `name:` is omitted.
	DefaultInitContainerName = "init-container"

	// DefaultUserContainerName is the default name we give to the container
	// specified by the user, if `name:` is omitted.
	DefaultUserContainerName = "user-container"

	// DefaultContainerConcurrency is the default container concurrency. It will be set if ContainerConcurrency is not specified.
	DefaultContainerConcurrency = 0

	// DefaultMaxRevisionContainerConcurrency is the maximum configurable
	// container concurrency.
	DefaultMaxRevisionContainerConcurrency = 1000

	// DefaultAllowContainerConcurrencyZero is whether, by default,
	// containerConcurrency can be set to zero (i.e. unbounded) by users.
	DefaultAllowContainerConcurrencyZero = true
)
View Source
const (
	// QueueProxyPodInfoFeatureKey gates mouting of podinfo with the value 'enabled'
	QueueProxyPodInfoFeatureKey = "features.knative.dev/queueproxy-podinfo"

	// DryRunFeatureKey gates the podspec dryrun feature and runs with the value 'enabled'
	DryRunFeatureKey = "features.knative.dev/podspec-dryrun"

	// AllowHTTPFullDuplexFeatureKey gates the use of http1 full duplex per workload
	AllowHTTPFullDuplexFeatureKey = "features.knative.dev/http-full-duplex"
)

service annotations under features.knative.dev/*

Variables

View Source
var (
	DefaultInitContainerNameTemplate = mustParseTemplate(DefaultInitContainerName)
	DefaultUserContainerNameTemplate = mustParseTemplate(DefaultUserContainerName)
)

Functions

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
	Features   *Features
	Autoscaler *autoscalerconfig.Config
}

Config holds the collection of configurations that we attach to contexts.

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.

func (*Config) DeepCopy added in v0.19.0

func (in *Config) DeepCopy() *Config

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

func (*Config) DeepCopyInto added in v0.19.0

func (in *Config) DeepCopyInto(out *Config)

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

type Defaults

type Defaults struct {
	RevisionTimeoutSeconds int64
	// This is the timeout set for ingress.
	// RevisionTimeoutSeconds must be less than this value.
	MaxRevisionTimeoutSeconds int64

	// This is  the default number of seconds a request will be allowed to
	// stay open while waiting to receive any bytes from the user's application
	RevisionResponseStartTimeoutSeconds int64

	// RevisionIdleTimeoutSeconds is the maximum duration in seconds a request
	// will be allowed to stay open while not receiving any bytes from the user's application.
	RevisionIdleTimeoutSeconds int64

	InitContainerNameTemplate *ObjectMetaTemplate

	UserContainerNameTemplate *ObjectMetaTemplate

	ContainerConcurrency int64

	// ContainerConcurrencyMaxLimit is the maximum permitted container concurrency
	// or target value in the system.
	ContainerConcurrencyMaxLimit int64

	// AllowContainerConcurrencyZero determines whether users are permitted to specify
	// a containerConcurrency of 0 (i.e. unbounded).
	AllowContainerConcurrencyZero bool

	// Permits defaulting of `enableServiceLinks` pod spec field.
	// See: https://github.com/knative/serving/issues/8498 for details.
	EnableServiceLinks *bool

	RevisionCPURequest              *resource.Quantity
	RevisionCPULimit                *resource.Quantity
	RevisionMemoryRequest           *resource.Quantity
	RevisionMemoryLimit             *resource.Quantity
	RevisionEphemeralStorageRequest *resource.Quantity
	RevisionEphemeralStorageLimit   *resource.Quantity
}

Defaults includes the default values to be populated by the webhook.

func NewDefaultsConfigFromConfigMap

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

NewDefaultsConfigFromConfigMap creates a Defaults from the supplied configMap.

func NewDefaultsConfigFromMap

func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error)

NewDefaultsConfigFromMap creates a Defaults from the supplied Map.

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) InitContainerName added in v0.28.0

func (d Defaults) InitContainerName(ctx context.Context) string

InitContainerName returns the name of the init container based on the context.

func (Defaults) UserContainerName added in v0.7.0

func (d Defaults) UserContainerName(ctx context.Context) string

UserContainerName returns the name of the user container based on the context.

type Features added in v0.16.0

type Features struct {
	MultiContainer                   Flag
	MultiContainerProbing            Flag
	PodSpecAffinity                  Flag
	PodSpecTopologySpreadConstraints Flag
	PodSpecDryRun                    Flag
	PodSpecFieldRef                  Flag
	PodSpecHostAliases               Flag
	PodSpecNodeSelector              Flag
	PodSpecRuntimeClassName          Flag
	PodSpecSecurityContext           Flag
	PodSpecShareProcessNamespace     Flag
	PodSpecHostIPC                   Flag
	PodSpecHostPID                   Flag
	PodSpecHostNetwork               Flag
	PodSpecPriorityClassName         Flag
	PodSpecSchedulerName             Flag
	ContainerSpecAddCapabilities     Flag
	PodSpecTolerations               Flag
	PodSpecVolumesEmptyDir           Flag
	PodSpecInitContainers            Flag
	PodSpecPersistentVolumeClaim     Flag
	PodSpecPersistentVolumeWrite     Flag
	QueueProxyMountPodInfo           Flag
	QueueProxyResourceDefaults       Flag
	PodSpecDNSPolicy                 Flag
	PodSpecDNSConfig                 Flag
	SecurePodDefaults                Flag
	TagHeaderBasedRouting            Flag
	AutoDetectHTTP2                  Flag
}

Features specifies which features are allowed by the webhook.

func NewFeaturesConfigFromConfigMap added in v0.16.0

func NewFeaturesConfigFromConfigMap(config *corev1.ConfigMap) (*Features, error)

NewFeaturesConfigFromConfigMap creates a Features from the supplied ConfigMap

func NewFeaturesConfigFromMap added in v0.16.0

func NewFeaturesConfigFromMap(data map[string]string) (*Features, error)

NewFeaturesConfigFromMap creates a Features from the supplied Map

func (*Features) DeepCopy added in v0.16.0

func (in *Features) DeepCopy() *Features

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

func (*Features) DeepCopyInto added in v0.16.0

func (in *Features) DeepCopyInto(out *Features)

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

type Flag added in v0.16.0

type Flag string

Flag is a string value which can be either Enabled, Disabled, or Allowed.

const (
	// FeaturesConfigName is the name of the ConfigMap for the features.
	FeaturesConfigName = "config-features"

	// Enabled turns on an optional behavior.
	Enabled Flag = "Enabled"
	// Disabled turns off an optional behavior.
	Disabled Flag = "Disabled"
	// Allowed neither explicitly disables or enables a behavior.
	// eg. allow a client to control behavior with an annotation or allow a new value through validation.
	Allowed Flag = "Allowed"
)

type ObjectMetaTemplate added in v0.28.0

type ObjectMetaTemplate struct {
	*template.Template
}

ObjectMetaTemplate is a template.Template wrapper for templates which can be applied to ObjectMeta. It implements DeepCopy and Equal so it can be used in Config structs and with go-cmp in tests.

func (ObjectMetaTemplate) DeepCopy added in v0.28.0

func (*ObjectMetaTemplate) DeepCopyInto added in v0.28.0

func (in *ObjectMetaTemplate) DeepCopyInto(out *ObjectMetaTemplate)

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

func (ObjectMetaTemplate) Equal added in v0.28.0

Equal compares two ObjectMetaTemplates for equality, it is implemented so that tests using go-cmp work nicely. Equality is defined to mean that applying the template results in the same value given the same ObjectMeta.Name.

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