config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 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 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          *metav1.LabelSelector `json:"selector,omitempty"`
	CompletedSelector labels.Selector       `json:"-"`
}

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 CompletedSchedulerSelectors added in v0.4.0

type CompletedSchedulerSelectors struct {
	Clusters labels.Selector
	Requests labels.Selector
}

type Config

type Config struct {

	// Scheduler is the configuration for the cluster scheduler.
	Scheduler *SchedulerConfig `json:"scheduler,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"`

	// +optional
	Selectors *SchedulerSelectors `json:"selectors,omitempty"`
	// Note that CompletedSelectors.Clusters 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.
	CompletedSelectors CompletedSchedulerSelectors `json:"-"`

	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 *metav1.LabelSelector `json:"clusters,omitempty"`
	Requests *metav1.LabelSelector `json:"requests,omitempty"`
}

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