config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environment

func Environment() string

func SetEnvironment

func SetEnvironment(env string)

Types

type AccessRequestConfig added in v0.6.0

type AccessRequestConfig struct {
	// If set, only AccessRequests that match the selector will be reconciled.
	Selector *Selector `json:"selector,omitempty"`
}

func (*AccessRequestConfig) Complete added in v0.6.0

func (c *AccessRequestConfig) Complete(fldPath *field.Path) error

func (*AccessRequestConfig) Validate added in v0.6.0

func (c *AccessRequestConfig) Validate(fldPath *field.Path) error

type ClusterDefinition added in v0.4.0

type ClusterDefinition struct {
	// TenancyCount determines how many ClusterRequests may point to the same Cluster.
	// Has no effect if the tenancy in the Cluster template is set to "Exclusive".
	// Must be equal to or greater than 0 otherwise, with 0 meaning "unlimited".
	TenancyCount int `json:"tenancyCount,omitempty"`

	Template ClusterTemplate `json:"template"`
	Selector *Selector       `json:"selector,omitempty"`
}

type ClusterTemplate added in v0.4.0

type ClusterTemplate struct {
	metav1.ObjectMeta `json:"metadata"`
	Spec              clustersv1alpha1.ClusterSpec `json:"spec"`
}

type Completable

type Completable interface {
	// Complete performs any required transformations on the configuration,
	// e.g. filling a map[string]X field from an []X field with keys.
	// It is expected to modify the configuration in place.
	// The fieldPath parameter can be used to create error messages.
	Complete(fldPath *field.Path) error
}

type Config

type Config struct {

	// Scheduler is the configuration for the cluster scheduler.
	Scheduler *SchedulerConfig `json:"scheduler,omitempty"`

	// AccessRequest is the configuration for the access request controller.
	AccessRequest *AccessRequestConfig `json:"accessRequest,omitempty"`
}

func LoadFromBytes

func LoadFromBytes(rawConfigs ...[]byte) (*Config, error)

LoadFromBytes builds the config from multiple raw YAML byte slices. It merges the configs together, with later configs overriding earlier ones.

func LoadFromFiles

func LoadFromFiles(paths ...string) (*Config, error)

LoadFromFiles builds the config from multiple YAML files.

func (*Config) Complete

func (c *Config) Complete() error

Complete completes the config by calling the Complete() method on each field that implements the Completable interface.

func (*Config) Default

func (c *Config) Default() error

Default defaults the config by calling the Default() method on each field that implements the Defaultable interface.

func (*Config) Dump

func (c *Config) Dump(out io.Writer) error

Dump is used for logging and debugging purposes.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config by calling the Validate() method on each field that implements the Validatable interface.

type Defaultable

type Defaultable interface {
	// Default sets default values for the configuration.
	// It is expected to modify the configuration in place.
	// The fieldPath parameter can be used to create error messages.
	Default(fldPath *field.Path) error
}

type SchedulerConfig added in v0.4.0

type SchedulerConfig struct {
	// Scope determines whether the scheduler considers all clusters or only the ones in the same namespace as the ClusterRequest.
	// Defaults to "Namespaced".
	Scope SchedulerScope `json:"scope"`

	// Strategy determines how the scheduler chooses between multiple fitting clusters:
	// - Random: chooses a random cluster
	// - Simple: chooses the first cluster in the list
	// - Balanced: chooses the cluster with the least number of requests (first one in case of a tie)
	// Defaults to "Balanced".
	Strategy Strategy `json:"strategy"`

	// Note that the cluster selector specified here holds the global cluster selector.
	// During Complete(), the local selector is merged with the global one (or set to the global one if nil).
	// This means that always the local completed selector should be used, unless the task is not tied to a specific ClusterDefinition.
	// +optional
	Selectors SchedulerSelectors `json:"selectors"`

	PurposeMappings map[string]*ClusterDefinition `json:"purposeMappings"`
}

func (*SchedulerConfig) Complete added in v0.4.0

func (c *SchedulerConfig) Complete(fldPath *field.Path) error

func (*SchedulerConfig) Default added in v0.4.0

func (c *SchedulerConfig) Default(_ *field.Path) error

func (*SchedulerConfig) Validate added in v0.4.0

func (c *SchedulerConfig) Validate(fldPath *field.Path) error

type SchedulerScope added in v0.4.0

type SchedulerScope string
const (
	SCOPE_CLUSTER    SchedulerScope = "Cluster"
	SCOPE_NAMESPACED SchedulerScope = "Namespaced"
)

type SchedulerSelectors added in v0.4.0

type SchedulerSelectors struct {
	Clusters *Selector `json:"clusters,omitempty"`
	Requests *Selector `json:"requests,omitempty"`
}

type Selector added in v0.6.0

type Selector struct {
	*metav1.LabelSelector `json:",inline"`
	// contains filtered or unexported fields
}

func (*Selector) Combine added in v0.6.0

func (s *Selector) Combine(other *Selector) (*Selector, error)

Combine returns a new selector that is a combination of the two selectors. Neither the original nor the other selector is modified. For the MatchLabels field, entries from other overwrite entries from the receiver object in case of key collisions. Note that the requirements of both selectors are ANDed. This can lead to selectors that cannot be satisfied. The returned selector is completed, even if neither the receiver nor the other one was.

func (*Selector) Complete added in v0.6.0

func (s *Selector) Complete(fldPath *field.Path) error

func (*Selector) Completed added in v0.6.0

func (s *Selector) Completed() labels.Selector

Completed returns the labels.Selector version of the selector. Returns a selector that matches everything if the selector is nil, empty, or has not been completed yet.

func (*Selector) DeepCopy added in v0.6.0

func (s *Selector) DeepCopy() *Selector

func (*Selector) Validate added in v0.6.0

func (s *Selector) Validate(fldPath *field.Path) error

type Strategy added in v0.4.0

type Strategy string
const (
	STRATEGY_BALANCED Strategy = "Balanced"
	STRATEGY_RANDOM   Strategy = "Random"
	STRATEGY_SIMPLE   Strategy = "Simple"
)

type Validatable

type Validatable interface {
	// Validate validates the configuration.
	// It should return an error if the configuration is invalid.
	// It is not supposed to modify the configuration in any way.
	// The fieldPath parameter can be used to create error messages.
	Validate(fldPath *field.Path) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳