util

package
v1.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 25 Imported by: 6

Documentation

Overview

* This file is part of the KubeVirt project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2019 Red Hat, Inc. *

Index

Constants

View Source
const (
	KubeVirtFinalizer string = "foregroundDeleteKubeVirt"

	ConditionReasonDeploymentFailedExisting = "ExistingDeployment"
	ConditionReasonDeploymentFailedError    = "DeploymentFailed"
	ConditionReasonDeletionFailedError      = "DeletionFailed"
	ConditionReasonDeploymentCreated        = "AllResourcesCreated"
	ConditionReasonDeploymentReady          = "AllComponentsReady"
	ConditionReasonDeploying                = "DeploymentInProgress"
	ConditionReasonUpdating                 = "UpdateInProgress"
	ConditionReasonDeleting                 = "DeletionInProgress"
)
View Source
const (
	// Name of env var containing the operator's image name
	// Deprecated. Use VirtOperatorImageEnvName instead
	OldOperatorImageEnvName      = "OPERATOR_IMAGE"
	VirtOperatorImageEnvName     = "VIRT_OPERATOR_IMAGE"
	VirtApiImageEnvName          = "VIRT_API_IMAGE"
	VirtControllerImageEnvName   = "VIRT_CONTROLLER_IMAGE"
	VirtHandlerImageEnvName      = "VIRT_HANDLER_IMAGE"
	VirtLauncherImageEnvName     = "VIRT_LAUNCHER_IMAGE"
	VirtExportProxyImageEnvName  = "VIRT_EXPORTPROXY_IMAGE"
	VirtExportServerImageEnvName = "VIRT_EXPORTSERVER_IMAGE"
	GsImageEnvName               = "GS_IMAGE"
	PrHelperImageEnvName         = "PR_HELPER_IMAGE"
	RunbookURLTemplate           = "RUNBOOK_URL_TEMPLATE"

	// The below Shasum variables would be ignored if Image env vars are being used.
	// Deprecated, use VirtApiImageEnvName instead
	VirtApiShasumEnvName = "VIRT_API_SHASUM"
	// Deprecated, use VirtControllerImageEnvName instead
	VirtControllerShasumEnvName = "VIRT_CONTROLLER_SHASUM"
	// Deprecated, use VirtHandlerImageEnvName instead
	VirtHandlerShasumEnvName = "VIRT_HANDLER_SHASUM"
	// Deprecated, use VirtLauncherImageEnvName instead
	VirtLauncherShasumEnvName = "VIRT_LAUNCHER_SHASUM"
	// Deprecated, use VirtExportProxyImageEnvName instead
	VirtExportProxyShasumEnvName = "VIRT_EXPORTPROXY_SHASUM"
	// Deprecated, use VirtExportServerImageEnvName instead
	VirtExportServerShasumEnvName = "VIRT_EXPORTSERVER_SHASUM"
	// Deprecated, use GsImageEnvName instead
	GsEnvShasumName = "GS_SHASUM"
	// Deprecated, use PrHelperImageEnvName instead
	PrHelperShasumEnvName  = "PR_HELPER_SHASUM"
	KubeVirtVersionEnvName = "KUBEVIRT_VERSION"
	// Deprecated, use TargetDeploymentConfig instead
	TargetInstallNamespace = "TARGET_INSTALL_NAMESPACE"
	// Deprecated, use TargetDeploymentConfig instead
	TargetImagePullPolicy = "TARGET_IMAGE_PULL_POLICY"
	// JSON containing all relevant deployment properties, replaces TargetInstallNamespace and TargetImagePullPolicy
	TargetDeploymentConfig = "TARGET_DEPLOYMENT_CONFIG"

	// these names need to match field names from KubeVirt Spec if they are set from there
	AdditionalPropertiesNamePullPolicy = "ImagePullPolicy"
	AdditionalPropertiesPullSecrets    = "ImagePullSecrets"

	// lookup key in AdditionalProperties
	AdditionalPropertiesMonitorNamespace = "MonitorNamespace"

	// lookup key in AdditionalProperties
	AdditionalPropertiesServiceMonitorNamespace = "ServiceMonitorNamespace"

	// lookup key in AdditionalProperties
	AdditionalPropertiesMonitorServiceAccount = "MonitorAccount"

	// lookup key in AdditionalProperties
	AdditionalPropertiesWorkloadUpdatesEnabled = "WorkloadUpdatesEnabled"

	// lookup key in AdditionalProperties
	AdditionalPropertiesMigrationNetwork = "MigrationNetwork"

	// lookup key in AdditionalProperties
	AdditionalPropertiesPersistentReservationEnabled = "PersistentReservationEnabled"

	// account to use if one is not explicitly named
	DefaultMonitorAccount = "prometheus-k8s"

	// lookup keys in AdditionalProperties
	ImagePrefixKey      = "imagePrefix"
	ProductNameKey      = "productName"
	ProductComponentKey = "productComponent"
	ProductVersionKey   = "productVersion"

	// #nosec 101, the variable is not holding any credential
	// Prefix for env vars that will be passed along
	PassthroughEnvPrefix = "KV_IO_EXTRA_ENV_"
)

Variables

View Source
var DefaultMonitorNamespaces = []string{
	"openshift-monitoring",
	"monitoring",
}

DefaultMonitorNamespaces holds a set of well known prometheus-operator namespaces. Ordering in the list matters. First entries have precedence.

Functions

func AddFinalizer

func AddFinalizer(kv *virtv1.KubeVirt)

func DaemonSetIsUpToDate added in v0.49.0

func DaemonSetIsUpToDate(kv *v1.KubeVirt, daemonSet *appsv1.DaemonSet) bool

func DaemonsetIsReady added in v0.16.0

func DaemonsetIsReady(kv *v1.KubeVirt, daemonset *appsv1.DaemonSet, stores Stores) bool

func DeploymentIsReady added in v0.16.0

func DeploymentIsReady(kv *v1.KubeVirt, deployment *appsv1.Deployment, stores Stores) bool

func DigestFromImageName added in v0.59.1

func DigestFromImageName(name string) (digest string)

func GetOperatorImage added in v0.58.1

func GetOperatorImage() string

func GetOperatorImageWithEnvVarManager added in v0.58.1

func GetOperatorImageWithEnvVarManager(envVarManager EnvVarManager) string

func GetPassthroughEnv added in v0.30.0

func GetPassthroughEnv() map[string]string

func GetPassthroughEnvWithEnvVarManager added in v0.58.1

func GetPassthroughEnvWithEnvVarManager(envVarManager EnvVarManager) map[string]string

func IsManagedByOperator added in v0.20.0

func IsManagedByOperator(labels map[string]string) bool

func IsPrometheusRuleEnabled added in v0.26.0

func IsPrometheusRuleEnabled(clientset kubecli.KubevirtClient) (bool, error)

IsPrometheusRuleEnabled returns true if prometheusrules cr is defined and false otherwise.

func IsSCCStoreEmpty added in v0.20.0

func IsSCCStoreEmpty(store cache.Store) bool

func IsServiceMonitorEnabled added in v0.20.6

func IsServiceMonitorEnabled(clientset kubecli.KubevirtClient) (bool, error)

func IsStoreEmpty

func IsStoreEmpty(store cache.Store) bool

func IsValidLabel added in v0.39.0

func IsValidLabel(label string) bool

func NewEnvVarMap added in v0.30.0

func NewEnvVarMap(envMap map[string]string) *[]k8sv1.EnvVar

func PodIsCrashLooping added in v0.49.0

func PodIsCrashLooping(pod *k8sv1.Pod) bool

func PodIsReady added in v0.49.0

func PodIsReady(pod *k8sv1.Pod) bool

func PodIsUpToDate added in v0.49.0

func PodIsUpToDate(pod *k8sv1.Pod, kv *v1.KubeVirt) bool

func SetConditionTimestamps added in v0.20.0

func SetConditionTimestamps(kvOrig *virtv1.KubeVirt, kvUpdated *virtv1.KubeVirt)

func SetOperatorVersion added in v0.16.0

func SetOperatorVersion(kv *virtv1.KubeVirt)

func UpdateConditionsAvailable added in v0.20.0

func UpdateConditionsAvailable(kv *virtv1.KubeVirt)

func UpdateConditionsCreated added in v0.20.0

func UpdateConditionsCreated(kv *virtv1.KubeVirt)

func UpdateConditionsDeleting added in v0.20.0

func UpdateConditionsDeleting(kv *virtv1.KubeVirt)

func UpdateConditionsDeletionFailed added in v0.20.0

func UpdateConditionsDeletionFailed(kv *virtv1.KubeVirt, err error)

func UpdateConditionsDeploying added in v0.20.0

func UpdateConditionsDeploying(kv *virtv1.KubeVirt)

func UpdateConditionsFailedError added in v0.20.0

func UpdateConditionsFailedError(kv *virtv1.KubeVirt, err error)

func UpdateConditionsFailedExists added in v0.20.0

func UpdateConditionsFailedExists(kv *virtv1.KubeVirt)

func UpdateConditionsUpdating added in v0.20.0

func UpdateConditionsUpdating(kv *virtv1.KubeVirt)

func VerifyEnv added in v0.20.0

func VerifyEnv() error

func VerifyEnvWithEnvVarManager added in v0.58.1

func VerifyEnvWithEnvVarManager(envVarManager EnvVarManager) error

Types

type EnvVarManager added in v0.58.1

type EnvVarManager interface {
	Getenv(key string) string
	Setenv(key, value string) error
	Unsetenv(key string) error
	Environ() []string
}
var DefaultEnvVarManager EnvVarManager = EnvVarManagerImpl{}

type EnvVarManagerImpl added in v0.58.1

type EnvVarManagerImpl struct{}

func (EnvVarManagerImpl) Environ added in v0.58.1

func (e EnvVarManagerImpl) Environ() []string

func (EnvVarManagerImpl) Getenv added in v0.58.1

func (e EnvVarManagerImpl) Getenv(key string) string

func (EnvVarManagerImpl) Setenv added in v0.58.1

func (e EnvVarManagerImpl) Setenv(key, value string) error

func (EnvVarManagerImpl) Unsetenv added in v0.58.1

func (e EnvVarManagerImpl) Unsetenv(key string) error

type EnvVarManagerMock added in v0.58.1

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

func (*EnvVarManagerMock) Environ added in v0.58.1

func (e *EnvVarManagerMock) Environ() (ret []string)

func (*EnvVarManagerMock) Getenv added in v0.58.1

func (e *EnvVarManagerMock) Getenv(key string) string

func (*EnvVarManagerMock) Setenv added in v0.58.1

func (e *EnvVarManagerMock) Setenv(key, value string) error

func (*EnvVarManagerMock) Unsetenv added in v0.58.1

func (e *EnvVarManagerMock) Unsetenv(key string) error

type Expectations

func (*Expectations) DeleteExpectations

func (e *Expectations) DeleteExpectations(key string)

func (*Expectations) ResetExpectations

func (e *Expectations) ResetExpectations(key string)

func (*Expectations) SatisfiedExpectations

func (e *Expectations) SatisfiedExpectations(key string) bool

type KubeVirtDeploymentConfig

type KubeVirtDeploymentConfig struct {
	ID          string `json:"id,omitempty" optional:"true"`
	Namespace   string `json:"namespace,omitempty" optional:"true"`
	Registry    string `json:"registry,omitempty" optional:"true"`
	ImagePrefix string `json:"imagePrefix,omitempty" optional:"true"`

	// the KubeVirt version
	// matches the image tag, if tags are used, either by the manifest, or by the KubeVirt CR
	// used on the KubeVirt CR status and on annotations, and for determining up-/downgrade path, even when using shasums for the images
	KubeVirtVersion string `json:"kubeVirtVersion,omitempty" optional:"true"`

	// the images names of every image we use
	VirtOperatorImage     string `json:"virtOperatorImage,omitempty" optional:"true"`
	VirtApiImage          string `json:"virtApiImage,omitempty" optional:"true"`
	VirtControllerImage   string `json:"virtControllerImage,omitempty" optional:"true"`
	VirtHandlerImage      string `json:"virtHandlerImage,omitempty" optional:"true"`
	VirtLauncherImage     string `json:"virtLauncherImage,omitempty" optional:"true"`
	VirtExportProxyImage  string `json:"virtExportProxyImage,omitempty" optional:"true"`
	VirtExportServerImage string `json:"virtExportServerImage,omitempty" optional:"true"`
	GsImage               string `json:"GsImage,omitempty" optional:"true"`
	PrHelperImage         string `json:"PrHelperImage,omitempty" optional:"true"`

	// the shasums of every image we use
	VirtOperatorSha     string `json:"virtOperatorSha,omitempty" optional:"true"`
	VirtApiSha          string `json:"virtApiSha,omitempty" optional:"true"`
	VirtControllerSha   string `json:"virtControllerSha,omitempty" optional:"true"`
	VirtHandlerSha      string `json:"virtHandlerSha,omitempty" optional:"true"`
	VirtLauncherSha     string `json:"virtLauncherSha,omitempty" optional:"true"`
	VirtExportProxySha  string `json:"virtExportProxySha,omitempty" optional:"true"`
	VirtExportServerSha string `json:"virtExportServerSha,omitempty" optional:"true"`
	GsSha               string `json:"gsSha,omitempty" optional:"true"`
	PrHelperSha         string `json:"prHelperSha,omitempty" optional:"true"`

	// everything else, which can e.g. come from KubeVirt CR spec
	AdditionalProperties map[string]string `json:"additionalProperties,omitempty" optional:"true"`

	// environment variables from virt-operator to pass along
	PassthroughEnvVars map[string]string `json:"passthroughEnvVars,omitempty" optional:"true"`
}

func GetConfigFromEnv added in v0.20.0

func GetConfigFromEnv() (*KubeVirtDeploymentConfig, error)

func GetConfigFromEnvWithEnvVarManager added in v0.58.1

func GetConfigFromEnvWithEnvVarManager(envVarManager EnvVarManager) (*KubeVirtDeploymentConfig, error)

func GetTargetConfigFromKV added in v0.20.0

func GetTargetConfigFromKV(kv *v1.KubeVirt) *KubeVirtDeploymentConfig

func GetTargetConfigFromKVWithEnvVarManager added in v0.58.1

func GetTargetConfigFromKVWithEnvVarManager(kv *v1.KubeVirt, envVarManager EnvVarManager) *KubeVirtDeploymentConfig

func (*KubeVirtDeploymentConfig) GetApiVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetApiVersion() string

func (*KubeVirtDeploymentConfig) GetControllerVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetControllerVersion() string

func (*KubeVirtDeploymentConfig) GetDeploymentID added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetDeploymentID() string

func (*KubeVirtDeploymentConfig) GetExportProxyVersion added in v0.55.0

func (c *KubeVirtDeploymentConfig) GetExportProxyVersion() string

func (*KubeVirtDeploymentConfig) GetExportServerVersion added in v0.55.0

func (c *KubeVirtDeploymentConfig) GetExportServerVersion() string

func (*KubeVirtDeploymentConfig) GetExtraEnv added in v0.30.0

func (c *KubeVirtDeploymentConfig) GetExtraEnv() map[string]string

func (*KubeVirtDeploymentConfig) GetHandlerVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetHandlerVersion() string

func (*KubeVirtDeploymentConfig) GetImagePrefix added in v0.20.8

func (c *KubeVirtDeploymentConfig) GetImagePrefix() string

func (*KubeVirtDeploymentConfig) GetImagePullPolicy added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetImagePullPolicy() k8sv1.PullPolicy

func (*KubeVirtDeploymentConfig) GetImagePullSecrets added in v0.59.0

func (c *KubeVirtDeploymentConfig) GetImagePullSecrets() []k8sv1.LocalObjectReference

func (*KubeVirtDeploymentConfig) GetImageRegistry added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetImageRegistry() string

func (*KubeVirtDeploymentConfig) GetJson added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetJson() (string, error)

func (*KubeVirtDeploymentConfig) GetKubeVirtVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetKubeVirtVersion() string

func (*KubeVirtDeploymentConfig) GetLauncherVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetLauncherVersion() string

func (*KubeVirtDeploymentConfig) GetMigrationNetwork added in v0.49.0

func (c *KubeVirtDeploymentConfig) GetMigrationNetwork() *string

func (*KubeVirtDeploymentConfig) GetMonitorServiceAccountName added in v0.53.0

func (c *KubeVirtDeploymentConfig) GetMonitorServiceAccountName() string

func (*KubeVirtDeploymentConfig) GetNamespace added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetNamespace() string

func (*KubeVirtDeploymentConfig) GetOperatorVersion added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetOperatorVersion() string

func (*KubeVirtDeploymentConfig) GetPotentialMonitorNamespaces added in v0.53.0

func (c *KubeVirtDeploymentConfig) GetPotentialMonitorNamespaces() []string

if the monitoring namespace field is defiend in kubevirtCR than return it otherwise we return common monitoring namespaces.

func (*KubeVirtDeploymentConfig) GetPrHelperVersion added in v1.0.0

func (c *KubeVirtDeploymentConfig) GetPrHelperVersion() string

func (*KubeVirtDeploymentConfig) GetProductComponent added in v0.48.0

func (c *KubeVirtDeploymentConfig) GetProductComponent() string

func (*KubeVirtDeploymentConfig) GetProductName added in v0.33.0

func (c *KubeVirtDeploymentConfig) GetProductName() string

func (*KubeVirtDeploymentConfig) GetProductVersion added in v0.33.0

func (c *KubeVirtDeploymentConfig) GetProductVersion() string

func (*KubeVirtDeploymentConfig) GetServiceMonitorNamespace added in v0.53.0

func (c *KubeVirtDeploymentConfig) GetServiceMonitorNamespace() string

func (*KubeVirtDeploymentConfig) GetVerbosity added in v0.20.0

func (c *KubeVirtDeploymentConfig) GetVerbosity() string

func (*KubeVirtDeploymentConfig) PersistentReservationEnabled added in v1.0.0

func (c *KubeVirtDeploymentConfig) PersistentReservationEnabled() bool

func (*KubeVirtDeploymentConfig) SetDefaultArchitecture added in v1.0.0

func (c *KubeVirtDeploymentConfig) SetDefaultArchitecture(kv *v1.KubeVirt) error

func (*KubeVirtDeploymentConfig) SetObservedDeploymentConfig added in v0.20.0

func (c *KubeVirtDeploymentConfig) SetObservedDeploymentConfig(kv *v1.KubeVirt) error

func (*KubeVirtDeploymentConfig) SetTargetDeploymentConfig added in v0.20.0

func (c *KubeVirtDeploymentConfig) SetTargetDeploymentConfig(kv *v1.KubeVirt) error

func (*KubeVirtDeploymentConfig) UseShasums added in v0.20.0

func (c *KubeVirtDeploymentConfig) UseShasums() bool

func (*KubeVirtDeploymentConfig) WorkloadUpdatesEnabled added in v0.39.0

func (c *KubeVirtDeploymentConfig) WorkloadUpdatesEnabled() bool

type Stores

type Stores struct {
	ServiceAccountCache           cache.Store
	ClusterRoleCache              cache.Store
	ClusterRoleBindingCache       cache.Store
	RoleCache                     cache.Store
	RoleBindingCache              cache.Store
	CrdCache                      cache.Store
	ServiceCache                  cache.Store
	DeploymentCache               cache.Store
	DaemonSetCache                cache.Store
	ValidationWebhookCache        cache.Store
	MutatingWebhookCache          cache.Store
	APIServiceCache               cache.Store
	SCCCache                      cache.Store
	RouteCache                    cache.Store
	InstallStrategyConfigMapCache cache.Store
	InstallStrategyJobCache       cache.Store
	InfrastructurePodCache        cache.Store
	PodDisruptionBudgetCache      cache.Store
	ServiceMonitorCache           cache.Store
	NamespaceCache                cache.Store
	PrometheusRuleCache           cache.Store
	SecretCache                   cache.Store
	ConfigMapCache                cache.Store
	IsOnOpenshift                 bool
	ServiceMonitorEnabled         bool
	PrometheusRulesEnabled        bool
}

func (*Stores) AllEmpty

func (s *Stores) AllEmpty() bool

Jump to

Keyboard shortcuts

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