util

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OperatorNamespaceEnv   = "OPERATOR_NAMESPACE"
	OperatorWebhookModeEnv = "WEBHOOK_MODE"
	ContainerAppName       = "APP"
	ContainerOperatorApp   = "OPERATOR"
	ContainerWebhookApp    = "WEBHOOK"
	HcoKvIoVersionName     = "HCO_KV_IO_VERSION"
	KubevirtVersionEnvV    = "KUBEVIRT_VERSION"
	CdiVersionEnvV         = "CDI_VERSION"
	CnaoVersionEnvV        = "NETWORK_ADDONS_VERSION"
	SspVersionEnvV         = "SSP_VERSION"
	NmoVersionEnvV         = "NMO_VERSION"
	HppoVersionEnvV        = "HPPO_VERSION"
	VMImportEnvV           = "VM_IMPORT_VERSION"
	HcoValidatingWebhook   = "validate-hco.kubevirt.io"
	HcoMutatingWebhookNS   = "mutate-ns-hco.kubevirt.io"
	AppLabel               = "app"
	UndefinedNamespace     = ""
	OpenshiftNamespace     = "openshift"
	APIVersionAlpha        = "v1alpha1"
	APIVersionBeta         = "v1beta1"
	CurrentAPIVersion      = APIVersionBeta
	APIVersionGroup        = "hco.kubevirt.io"
	APIVersion             = APIVersionGroup + "/" + APIVersionBeta
	// HyperConvergedName is the name of the HyperConverged resource that will be reconciled
	HyperConvergedName          = "kubevirt-hyperconverged"
	MetricsHost                 = "0.0.0.0"
	MetricsPort           int32 = 8383
	OperatorMetricsPort   int32 = 8686
	HealthProbeHost             = "0.0.0.0"
	HealthProbePort       int32 = 6060
	ReadinessEndpointName       = "/readyz"
	LivenessEndpointName        = "/livez"
	HCOWebhookPath              = "/validate-hco-kubevirt-io-v1beta1-hyperconverged"
	HCONSWebhookPath            = "/mutate-ns-hco-kubevirt-io"
	WebhookPort                 = 4343
)

HCO common constants

View Source
const (
	LocalRunMode   RunModeType = "local"
	ClusterRunMode RunModeType = "cluster"

	// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
	// which is the namespace where the watch activity happens.
	// this value is empty if the operator is running with clusterScope.
	WatchNamespaceEnvVar = "WATCH_NAMESPACE"

	// PodNameEnvVar is the constant for env variable POD_NAME
	// which is the name of the current pod.
	PodNameEnvVar = "POD_NAME"
)

Variables

View Source
var ErrNoNamespace = fmt.Errorf("namespace not found for current environment")

ErrNoNamespace indicates that a namespace could not be found for the current environment

View Source
var ErrRunLocal = fmt.Errorf("operator run mode forced to local")

ErrRunLocal indicates that the operator is set to run in local mode (this error is returned by functions that only work on operators running in cluster mode)

View Source
var ForceRunModeEnv = "OSDK_FORCE_RUN_MODE"

ForceRunModeEnv indicates if the operator should be forced to run in either local or cluster mode (currently only used for local mode)

Functions

func ComponentResourceRemoval added in v1.2.0

func ComponentResourceRemoval(ctx context.Context, c client.Client, obj interface{}, hcoName string, logger logr.Logger, dryRun bool, wait bool) error

ComponentResourceRemoval removes the resource `obj` if it exists and belongs to the HCO with wait=true it will wait, (util ctx timeout, please set it!) for the resource to be effectively deleted

func ContainsString added in v1.3.0

func ContainsString(s []string, word string) bool

func EnsureCreated added in v1.2.0

func EnsureCreated(ctx context.Context, c client.Client, obj runtime.Object, logger logr.Logger) error

EnsureCreated creates the runtime object if it does not exist

func EnsureDeleted added in v1.2.0

func EnsureDeleted(ctx context.Context, c client.Client, obj runtime.Object, hcoName string, logger logr.Logger, dryRun bool, wait bool) error

EnsureDeleted calls ComponentResourceRemoval if the runtime object exists with wait=true it will wait, (util ctx timeout, please set it!) for the resource to be effectively deleted

func GetCSVfromPod

func GetCSVfromPod(pod *corev1.Pod, c client.Reader, logger logr.Logger) (*csvv1alpha1.ClusterServiceVersion, error)

func GetHcoPing added in v1.3.0

func GetHcoPing() healthz.Checker

func GetOperatorNamespace added in v1.3.0

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

GetOperatorNamespace returns the namespace the operator should be running in.

func GetOperatorNamespaceFromEnv

func GetOperatorNamespaceFromEnv() (string, error)

func GetPod

func GetPod(ctx context.Context, c client.Reader, logger logr.Logger, ci ClusterInfo) (*corev1.Pod, error)

func GetRuntimeObject added in v1.2.0

func GetRuntimeObject(ctx context.Context, c client.Client, obj runtime.Object, logger logr.Logger) error

GetRuntimeObject will query the apiserver for the object

func GetWatchNamespace added in v1.3.0

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func IsReady added in v1.3.0

func IsReady() bool

func SetReady added in v1.3.0

func SetReady(ready bool)

Types

type ClusterInfo added in v1.1.0

type ClusterInfo interface {
	CheckRunningInOpenshift(creader client.Reader, ctx context.Context, logger logr.Logger, runningLocally bool) error
	IsOpenshift() bool
	IsRunningLocally() bool
}

func GetClusterInfo added in v1.2.0

func GetClusterInfo() ClusterInfo

type ClusterInfoImp added in v1.1.0

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

func (*ClusterInfoImp) CheckRunningInOpenshift added in v1.1.0

func (c *ClusterInfoImp) CheckRunningInOpenshift(creader client.Reader, ctx context.Context, logger logr.Logger, runningLocally bool) error

func (ClusterInfoImp) IsOpenshift added in v1.1.0

func (c ClusterInfoImp) IsOpenshift() bool

func (ClusterInfoImp) IsRunningLocally added in v1.2.0

func (c ClusterInfoImp) IsRunningLocally() bool

type EventEmitter added in v1.2.0

type EventEmitter interface {
	Init(ctx context.Context, mgr manager.Manager, ci ClusterInfo, logger logr.Logger)
	EmitEvent(object runtime.Object, eventType, reason, msg string)
	UpdateClient(ctx context.Context, clnt client.Reader, logger logr.Logger)
}

func GetEventEmitter added in v1.2.0

func GetEventEmitter() EventEmitter

type RunModeType added in v1.3.0

type RunModeType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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