common

package
v0.19.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorVersionKey          = "OPERATOR_VERSION"
	TemplateValidatorImageKey   = "VALIDATOR_IMAGE"
	TektonTasksImageKey         = "TEKTON_TASKS_IMAGE"
	TektonTasksDiskVirtImageKey = "TEKTON_TASKS_DISK_VIRT_IMAGE"
	VirtioImageKey              = "VIRTIO_IMG"
	VmConsoleProxyImageKey      = "VM_CONSOLE_PROXY_IMAGE"

	DefaultTektonTasksIMG         = "quay.io/kubevirt/tekton-tasks:" + TektonTasksVersion
	DeafultTektonTasksDiskVirtIMG = "quay.io/kubevirt/tekton-tasks-disk-virt:" + TektonTasksVersion
	DefaultVirtioIMG              = "quay.io/kubevirt/virtio-container-disk:v1.0.1"
)
View Source
const (
	AppKubernetesNameLabel      = "app.kubernetes.io/name"
	AppKubernetesPartOfLabel    = "app.kubernetes.io/part-of"
	AppKubernetesVersionLabel   = "app.kubernetes.io/version"
	AppKubernetesManagedByLabel = "app.kubernetes.io/managed-by"
	AppKubernetesComponentLabel = "app.kubernetes.io/component"

	AppComponentTektonPipelines       AppComponent = "tektonPipelines"
	AppComponentTektonTasks           AppComponent = "tektonTasks"
	AppKubernetesManagedByValue       string       = "ssp-operator"
	TektonAppKubernetesManagedByValue string       = "tekton-tasks-operator"
)
View Source
const (
	TektonTasksVersion = "v0.16.0"
)

Variables

View Source
var (
	SSPOperatorReconcileSucceeded = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "kubevirt_ssp_operator_reconcile_succeeded",
		Help: "Set to 1 if the reconcile process of all operands completes with no errors, and to 0 otherwise",
	})
)
View Source
var (
	// Scheme used for the SSP operator.
	Scheme = runtime.NewScheme()
)

Functions

func AddAppLabels added in v0.2.0

func AddAppLabels(requestInstance *ssp.SSP, name string, component AppComponent, obj client.Object) client.Object

AddAppLabels to the provided obj Name will translate into the AppKubernetesNameLabel Component will translate into the AppKubernetesComponentLabel Instance wide labels will be taken from the request if available

func AddConversionFunctions added in v0.18.0

func AddConversionFunctions(s *runtime.Scheme) error

This function is useful in operand unit tests only

func AppendDeepCopies added in v0.19.0

func AppendDeepCopies[PT interface {
	*T
	client.Object
}, T any](destination []client.Object, objects []T) []client.Object

AppendDeepCopies appends deep copies of objects from a source slice to a destination slice. This function is useful for creating a new slice containing deep copies of the provided objects.

The PT interface {*T ; client.Object } is a trick. It means that type PT satisfies an anonymous typeset defined directly in the function signature. This typeset interface { *T; client.Object } means that it is a pointer to T and implements interface client.Object.

Parameters:

  • destination: The destination slice where the deep copies of objects will be appended.
  • objects: A slice of objects (of type T) to be deep copied and appended to the destination slice.

Returns:

  • The updated destination slice containing the appended deep copies of objects.

Type Parameters:

  • PT: A type that is a pointer to the object type (should implement *T and client.Object interfaces).
  • T: The actual object type.

func CheckOwnerAnnotation added in v0.13.0

func CheckOwnerAnnotation(obj client.Object, owner client.Object) bool

func CipherIDs added in v0.18.3

func CipherIDs(names []string, logger *logr.Logger) (cipherSuites []uint16)

func EnvOrDefault

func EnvOrDefault(envName string, defVal string) string

func GetAppNameSelector added in v0.17.0

func GetAppNameSelector(name string) (labels.Selector, error)

func GetInfrastructureTopology added in v0.13.0

func GetInfrastructureTopology(ctx context.Context, c client.Reader) (osconfv1.TopologyMode, error)

func GetKnownCipherId added in v0.16.2

func GetKnownCipherId(IANACipherName string) (uint16, bool)

func GetOperatorNamespace added in v0.16.1

func GetOperatorNamespace(logger logr.Logger) (string, error)

func GetOperatorVersion added in v0.13.0

func GetOperatorVersion() string

func GetTektonTasksDiskVirtImage added in v0.18.0

func GetTektonTasksDiskVirtImage() string

GetDiskVirtSysprepImage returns disk-virt-sysprep task image url

func GetTektonTasksImage added in v0.18.0

func GetTektonTasksImage() string

GetSSHKeysStatusImage returns generate-ssh-keys task image url

func GetVirtioImage added in v0.18.0

func GetVirtioImage() string

GetVirtioImage returns virtio image url

func RunningOnOpenshift added in v0.16.2

func RunningOnOpenshift(ctx context.Context, cl client.Reader) (bool, error)

func UpdateLabels added in v0.16.0

func UpdateLabels(expected, found client.Object)

Types

type AppComponent added in v0.2.0

type AppComponent string
const (
	AppComponentMonitoring AppComponent = "monitoring"
	AppComponentSchedule   AppComponent = "schedule"
	AppComponentTemplating AppComponent = "templating"
)

func (AppComponent) String added in v0.2.0

func (a AppComponent) String() string

type CleanupResult added in v0.13.0

type CleanupResult struct {
	Resource client.Object
	Deleted  bool
}

func Cleanup added in v0.13.0

func Cleanup(request *Request, resource client.Object) (CleanupResult, error)

func DeleteAll added in v0.13.0

func DeleteAll(request *Request, resources ...client.Object) ([]CleanupResult, error)

type OperationResult added in v0.13.0

type OperationResult string
const (
	OperationResultNone    OperationResult = "unchanged"
	OperationResultCreated OperationResult = "created"
	OperationResultUpdated OperationResult = "updated"
	OperationResultDeleted OperationResult = "deleted"
)

type ReconcileBuilder added in v0.2.0

type ReconcileBuilder interface {
	NamespacedResource(client.Object) ReconcileBuilder
	ClusterResource(client.Object) ReconcileBuilder
	WithAppLabels(name string, component AppComponent) ReconcileBuilder
	UpdateFunc(ResourceUpdateFunc) ReconcileBuilder
	StatusFunc(ResourceStatusFunc) ReconcileBuilder
	ImmutableSpec(getter ResourceSpecGetter) ReconcileBuilder

	Options(options ReconcileOptions) ReconcileBuilder

	Reconcile() (ReconcileResult, error)
}

func CreateOrUpdate added in v0.2.0

func CreateOrUpdate(request *Request) ReconcileBuilder

type ReconcileFunc

type ReconcileFunc = func(*Request) (ReconcileResult, error)

type ReconcileOptions added in v0.13.2

type ReconcileOptions struct {
	// AlwaysCallUpdateFunc specifies if the UpdateFunc should be called
	// on changes that don't increase the .metadata.generation field.
	// For example, labels and annotations.
	AlwaysCallUpdateFunc bool
}

type ReconcileResult added in v0.13.0

type ReconcileResult struct {
	Status          ResourceStatus
	InitialResource client.Object
	Resource        client.Object
	OperationResult OperationResult
}

func CollectResourceStatus

func CollectResourceStatus(request *Request, funcs ...ReconcileFunc) ([]ReconcileResult, error)

func ResourceDeletedResult added in v0.13.0

func ResourceDeletedResult(resource client.Object, res OperationResult) ReconcileResult

func (*ReconcileResult) IsSuccess added in v0.13.0

func (r *ReconcileResult) IsSuccess() bool

type Request

type Request struct {
	reconcile.Request
	Client         client.Client
	UncachedReader client.Reader
	Context        context.Context
	Instance       *ssp.SSP
	Logger         logr.Logger
	VersionCache   VersionCache
	TopologyMode   osconfv1.TopologyMode

	CrdList crd_watch.CrdList
}

func (*Request) IsSingleReplicaTopologyMode added in v0.13.0

func (r *Request) IsSingleReplicaTopologyMode() bool

type ResourceSpecGetter added in v0.13.0

type ResourceSpecGetter = func(resource client.Object) interface{}

type ResourceStatus

type ResourceStatus struct {
	Progressing  StatusMessage
	NotAvailable StatusMessage
	Degraded     StatusMessage
}

type ResourceStatusFunc

type ResourceStatusFunc = func(resource client.Object) ResourceStatus

type ResourceUpdateFunc

type ResourceUpdateFunc = func(expected, found client.Object)

type SSPTLSOptions added in v0.16.1

type SSPTLSOptions struct {
	MinTLSVersion      string
	OpenSSLCipherNames []string
}

func NewSSPTLSOptions added in v0.16.1

func NewSSPTLSOptions(tlsSecurityProfile *ocpv1.TLSSecurityProfile, logger *logr.Logger) (*SSPTLSOptions, error)

func (*SSPTLSOptions) IsEmpty added in v0.16.1

func (s *SSPTLSOptions) IsEmpty() bool

func (*SSPTLSOptions) MinTLSVersionId added in v0.16.1

func (s *SSPTLSOptions) MinTLSVersionId() (uint16, error)

type StatusMessage

type StatusMessage = *string

type VersionCache

type VersionCache map[cacheKey]cacheValue

func (VersionCache) Add

func (v VersionCache) Add(obj client.Object)

func (VersionCache) Contains

func (v VersionCache) Contains(obj client.Object) bool

func (VersionCache) RemoveObj

func (v VersionCache) RemoveObj(obj client.Object)

Jump to

Keyboard shortcuts

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