types

package
v0.0.0-...-ae3d3cc Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//HashKey conation the hash of the resource in the annotations
	HashKey = "formation/hash"

	//UpdateKey if is set to "disabled", the resource will not be updated.
	//Once this is set on a resource, it will not be updated unless the annotation is removed.
	UpdateKey = "formation/update"
)

Variables

View Source
var (
	ErrWrongResourceType = errors.New("wrong resource type")
)

Functions

This section is empty.

Types

type AddEnvFromSourceToContainer

type AddEnvFromSourceToContainer interface {
	AddEnvFromSourceToContainer(containerName string, envFromSource v1.EnvFromSource)
}

type AddTemplateVolumeToContainer

type AddTemplateVolumeToContainer interface {
	AddVolumeToContainer(containerName string, containerVolume v1.VolumeMount, template v1.PersistentVolumeClaimSpec)
}

AddTemplateVolumeToContainer is the interface that adds a Volume Template to the builder and which container it belongs to

type AddVolumeToContainer

type AddVolumeToContainer interface {
	AddVolumeToContainer(containerName string, containerVolume v1.VolumeMount, volume v1.VolumeSource)
}

AddVolumeToContainer is the interface that adds a Volume to a Container

type ConfigurableContainer

type ConfigurableContainer interface {
	// AddResourceRequirements Add resource requirements to the container
	AddResourceRequirements(containerName string, requirements v1.ResourceRequirements)

	//AddEnv Add environment variables to the container
	AddEnv(containerName string, env ...v1.EnvVar)

	SetImage(containerName string, image string)

	SetImagePullPolicy(containerName string, policy v1.PullPolicy)

	// SetStartupProbe Set the startup probe for the container
	SetStartupProbe(containerName string, probe v1.Probe)

	// SetReadinessProbe Set the readiness probe for the container
	SetReadinessProbe(containerName string, probe v1.Probe)

	// SetLivenessProbe Set the liveness probe for the container
	SetLivenessProbe(containerName string, probe v1.Probe)
}

ConfigurableContainer is the interface that allows the user to customize the resource

type ConfigurablePod

type ConfigurablePod interface {
	// AddAffinity Add affinity to the pod
	AddAffinity(affinity v1.Affinity)
	// AddTolerations Add tolerations to the pod
	AddTolerations(toleration ...v1.Toleration)
	// AddTopologySpreadConstraints Add Pod Topology Spread Constraints
	AddTopologySpreadConstraints(topologySpreadConstraint ...v1.TopologySpreadConstraint)

	// AddNodeSelector Add node selector to the pod
	AddNodeSelector(name, value string)

	AddImagePullSecrets(secretNames ...string)

	SetServiceAccountName(name string)
}

ConfigurablePod is the interface that allows the user to customize the Pod

type ConfigurableReplicas

type ConfigurableReplicas interface {
	SetReplicas(replica int32)
}

ConfigurableReplicas is the interface that allows the user to customize the number of replicas

type Converged

type Converged interface {
	Converged(ctx context.Context, client client.Client, namespace string) (bool, error)
}

Converged The default implementation for a list of resources once it is created is to move on to the next one, if the controller need to wait for this resource to be ready, it can implement this interface

type ConvergedGroup

type ConvergedGroup struct {
	// contains filtered or unexported fields
}

func (*ConvergedGroup) GetConvergedGroupID

func (c *ConvergedGroup) GetConvergedGroupID() int

func (*ConvergedGroup) SetConvergedGroupID

func (c *ConvergedGroup) SetConvergedGroupID(id int)

type ConvergedGroupInterface

type ConvergedGroupInterface interface {
	// SetConvergedGroupID set the group id for the resource. ID must be greater than 0
	// ID of 0 means the resource is not part of any group and must be converged before the next resource will be checked
	SetConvergedGroupID(uid int)
	// GetConvergedGroupID get the group id for the resource
	GetConvergedGroupID() int
}

ConvergedGroup group of resources that need to be converged together but not necessarily in order

type FormationStatus

type FormationStatus struct {
	Resources []*ResourceStatus `json:"resources,omitempty" yaml:"resources"`
}

func (*FormationStatus) DeepCopy

func (in *FormationStatus) DeepCopy() *FormationStatus

func (*FormationStatus) DeepCopyInto

func (in *FormationStatus) DeepCopyInto(t *FormationStatus)

type FormationStatusInterface

type FormationStatusInterface interface {
	GetStatus() *FormationStatus
}

type LinkVolumeData

type LinkVolumeData struct {
	//The name of the container that this volume is mounted to
	// Format is <PodName>.<ContainerName>
	// Wildcard is supported, e.g. <PodName>.* will mount to all containers in the pod
	// Regex is not supported
	Visibility []string `json:"visibility,omitempty" yaml:"visibility"`

	VolumeMount v1.VolumeMount `json:"volumeMount,omitempty" yaml:"volumeMount"`

	//If the Volume is pre-created, or was created by the Formation, what is the reference to it
	VolumeSource *v1.VolumeSource `json:"volumeSource,omitempty" yaml:"volumeSource"`

	// If Template is set, the volume will be created by the template
	Template *v1.PersistentVolumeClaimSpec `json:"template,omitempty" yaml:"template"`

	// The sources to populate environment variables in the container.
	// The keys defined within a source must be a C_IDENTIFIER. All invalid keys
	// will be reported as an event when the container is starting. When a key exists in multiple
	// sources, the value associated with the last source will take precedence.
	// Values defined by an Env with a duplicate key will take precedence.
	EnvFromSource *v1.EnvFromSource `json:"envFromSource,omitempty" yaml:"envFromSource"`
}

type Reconcile

type Reconcile interface {
	Reconcile(ctx context.Context, client client.Client, owner v11.Object) (bool, error)
}

Reconcile If the resource need to implement their own reconcile logic, they can implement this interface Optional

type Resource

type Resource interface {
	//The type of Resource, Ex configmap
	Type() string
	//The name of the Resource, this name need to be unique per namespace
	Name() string
	//Return an emtpy runtime object of type Resource
	Runtime() client.Object

	//Create the Resource structure
	Create() (client.Object, error)
}

type ResourceState

type ResourceState string
const (
	Creating ResourceState = "Creating"
	Ready    ResourceState = "Ready"
	Waiting  ResourceState = "Waiting"
)

type ResourceStatus

type ResourceStatus struct {
	Name  string        `json:"name,omitempty"`
	Type  string        `json:"type,omitempty"`
	Group string        `json:"group,omitempty"`
	State ResourceState `json:"state,omitempty"`
	// +kubebuilder:validation:Type=string
	// +kubebuilder:validation:Format="date-time"
	LastUpdate metav1.Time `json:"lastUpdate,omitempty"`
}

type ResourcesName

type ResourcesName interface {
	ResourcesName() []string
}

ResourcesName is the interface that returns the name of the resources that the builder creates For example, if the resource is a Deployment, it will return the with a list of container name with the format <Pod-Name>/<Container-Name>

type StorageConfigType

type StorageConfigType string

StorageConfigType manages the formation's interpretation of a StorageConfig; each of the types has near-identical specifications but slightly different behavior. +kubebuilder:validation:Enum=template;existing;create;""

const (
	// StorageConfigTypeTemplate will typically be templated in to any
	// StatefulSet managed by the ResourceConfig parent of this StorageConfig.
	// They will be ignored for any workload object (e.g., Deployment) that
	// doesn't accept VolumeClaimTemplates.
	StorageConfigTypeTemplate StorageConfigType = "template"
	// StorageConfigTypeExisting will typically be inserted in to the Volumes
	// field of the PodSpec for all workload objects (Deployment, StatefulSet)
	// managed by this ResourceConfig.
	StorageConfigTypeExisting StorageConfigType = "existing"
	// StorageConfigTypeCreate are expected to be created by the controllers and then
	// inserted in to the Volumes field of workload objects, just as with
	// Existing.
	StorageConfigTypeCreate StorageConfigType = "create"
)

type ToResource

type ToResource interface {
	ToResource() Resource
}

ToResource is the interface that converts a Builder to a Resource

type Update

type Update interface {
	Update(ctx context.Context, fromApiServer runtime.Object) error
}

Update is the interface that allows each resource to implement their own update logic. The default behaviour for the build-in controller is to merge the new into the old. To get more control of the resource lifecycle, the controller can implement Reconcile Optional

Jump to

Keyboard shortcuts

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