controllers

package
v0.0.0-...-2006d36 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: GPL-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AzureObjType = "azure blob"
	S3ObjType    = "s3"
	SCNameType   = "StorageClass"
	PVCType      = "PVC"
	EmptyDirType = "emptyDir"

	PulpResource     = "Pulp"
	CacheResource    = "Cache"
	DatabaseResource = "Database"

	DotNotEditMessage = `` /* 207-byte string literal not displayed */

	DefaultOCPIngressClass = "openshift-default"
	OperatorHashLabel      = "pulp-operator-hash"
)

Variables

This section is empty.

Functions

func AddHashLabel

func AddHashLabel(r FunctionResources, deployment *appsv1.Deployment)

AddHashLabel creates a label with the calculated hash from the mutated deployment

func CalculateHash

func CalculateHash(obj any) string

CalculateHash returns a string of the hashed value from obj

func CheckDeploymentSpec

func CheckDeploymentSpec(fields ...interface{}) bool

CheckDeployment returns true if a spec from deployment is not with the expected contents defined in Pulp CR

func CheckEmptyDir

func CheckEmptyDir(pulp *repomanagerpulpprojectorgv1beta2.Pulp, resource string)

CheckEmptyDir creates a log warn message in case no persistent storage is provided for the given resource

func ContainerExec

func ContainerExec[T any](client T, pod *corev1.Pod, command []string, container, namespace string) (string, error)

ContainerExec runs a command in the container

func CustomZapLogger

func CustomZapLogger() *zap.Logger

CustomZapLogger should be used only for warn messages it is a kludge to bypass the "limitation" of logr not having warn level

func DeployAptSign

func DeployAptSign(secret corev1.Secret) bool

DeployAptSign returns true if signingScript secret is defined with an apt script

func DeployCollectionSign

func DeployCollectionSign(secret corev1.Secret) bool

DeployCollectionSign returns true if signingScript secret is defined with a collection script

func DeployContainerSign

func DeployContainerSign(secret corev1.Secret) bool

DeployContainerSign returns true if signingScript secret is defined with a container script

func GetAPIRoot

GetAPIRoot returns the definition of API_ROOT in settings.py or /pulp/

func GetAdminSecretName

func GetAdminSecretName(pulp repomanagerpulpprojectorgv1beta2.Pulp) string

GetAdminSecretName retrieves pulp admin user password

func GetContentPathPrefix

func GetContentPathPrefix(r client.Client, pulp *repomanagerpulpprojectorgv1beta2.Pulp) string

GetContentPathPrefix returns the definition of CONTENT_PATH_PREFIX in settings.py or * /pulp/content/default/ if domain is enabled * /pulp/content/ otherwise

func GetCurrentHash

func GetCurrentHash(obj client.Object) string

getCurrentHash retrieves the hash defined in obj label

func GetDBFieldsEncryptionSecret

func GetDBFieldsEncryptionSecret(pulp repomanagerpulpprojectorgv1beta2.Pulp) string

GetDBFieldsEncryptionSecret returns the name of DBFieldsEncryption Secret

func GetPostgresEnvVars

func GetPostgresEnvVars(pulp repomanagerpulpprojectorgv1beta2.Pulp) (envVars []corev1.EnvVar)

GetPostgresEnvVars return the list of postgres environment variables to use in containers

func GetSigningKeyFingerprint

func GetSigningKeyFingerprint(r client.Client, secretName, secretNamespace string) (string, error)

getSigningKeyFingerprint returns the signing key fingerprint from secret object

func GetStorageType

func GetStorageType(pulp repomanagerpulpprojectorgv1beta2.Pulp) []string

GetStorageType retrieves the storage type defined in pulp CR

func HashFromMutated

func HashFromMutated(dep *appsv1.Deployment, resources FunctionResources) string

func IgnoreUpdateCRStatusPredicate

func IgnoreUpdateCRStatusPredicate() predicate.Predicate

IgnoreUpdateCRStatusPredicate filters update events on pulpbackup CR status

func ImageChanged

func ImageChanged(pulp *repomanagerpulpprojectorgv1beta2.Pulp) bool

CheckImageVersionModified verifies if the container image tag defined in Pulp CR matches the one in the Deployment

func IngressDefaults

func IngressDefaults(resources any, plugins []IngressPlugin) (*netv1.Ingress, error)

IngressDefaults returns an k8s Ingress resource with default values

func IsNginxIngressSupported

func IsNginxIngressSupported(pulp *repomanagerpulpprojectorgv1beta2.Pulp) bool

IsNginxIngressSupported returns true if the operator was instructed that this is a nginx ingress controller

func IsOpenShift

func IsOpenShift() (bool, error)

IsOpenShift returns true if the platform cluster is OpenShift

func MultiStorageConfigured

func MultiStorageConfigured(pulp *repomanagerpulpprojectorgv1beta2.Pulp, resource string) (bool, []string)

MultiStorageConfigured returns true if Pulp CR is configured with more than one "storage type" for example, if ObjectStorageAzureSecret and FileStorageClass are defined we can't determine which one the operator should use.

func OtelConfigMap

func OtelConfigMap(resources FunctionResources) client.Object

otelConfigMap defines a configmap resource to keep otel-collector-config.yaml configuration file

func ReconcileMetadata

func ReconcileMetadata(funcResources FunctionResources, expectedState, currentState client.Object, conditionType string) (bool, error)

ReconcileMetadata is a method to handle only .metadata.{labels,annotations} reconciliation for some reason, if we try to use DeepDerivative like

if !equality.Semantic.DeepDerivative(expectedState.(*routev1.Route), currentState.(*routev1.Route)) ...

it will get into an infinite loop

func ReconcileObject

func ReconcileObject(funcResources FunctionResources, expectedState, currentState client.Object, conditionType string, pulpObject PulpObject) (bool, error)

ReconcileObject will check if the definition from Pulp CR is reflecting the current object state and if not will synchronize the configuration func ReconcileObject(funcResources FunctionResources, expectedState, currentState client.Object, conditionType string, pulpObject PulpObject) (bool, error) {

func RemovePulpWebResources

func RemovePulpWebResources(resources FunctionResources) error

RemovePulpWebResources deletes pulp-web Deployment and Service

func RemoveTelemetryResources

func RemoveTelemetryResources(resources FunctionResources)

RemoveTelemetryResources cleans up telemetry resources if telemetry.enabled == false

func RetrieveSecretData

func RetrieveSecretData(ctx context.Context, secretName, secretNamespace string, required bool, r client.Client, keys ...string) (map[string]string, error)

Retrieve specific keys from secret object

func ServiceOtel

func ServiceOtel(resources FunctionResources) client.Object

serviceOtel defines a service to expose otel metrics

func SetCustomEnvVars

func SetCustomEnvVars(pulp repomanagerpulpprojectorgv1beta2.Pulp, component string) []corev1.EnvVar

setCustomEnvVars returns the list of custom environment variables defined in Pulp CR

func SetDefaultSecurityContext

func SetDefaultSecurityContext() *corev1.SecurityContext

SetDefaultSecurityContext defines the container security configuration to be in compliance with PodSecurity "restricted:v1.24"

func SetHashLabel

func SetHashLabel(label string, obj client.Object)

SetHashLabel appends the operator's hash label into object

func SetPulpcoreCustomEnvVars

func SetPulpcoreCustomEnvVars(pulp repomanagerpulpprojectorgv1beta2.Pulp, pulpcoreType settings.PulpcoreType) []corev1.EnvVar

setPulpcoreCustomEnvVars returns the list of custom environment variables defined in Pulp CR

func StorageTypeChanged

func StorageTypeChanged(pulp *repomanagerpulpprojectorgv1beta2.Pulp) bool

StorageTypeChanged verifies if the storage type has been modified

func UpdateCRField

func UpdateCRField(ctx context.Context, r client.Client, pulp *repomanagerpulpprojectorgv1beta2.Pulp, fieldName, fieldValue string) error

UpdatCRField patches fieldName in Pulp CR with fieldValue

func UpdateStatus

func UpdateStatus(ctx context.Context, r client.Client, pulp *repomanagerpulpprojectorgv1beta2.Pulp, conditionStatus metav1.ConditionStatus, conditionType, conditionReason, conditionMessage string)

UpdateStatus will set the new condition value for a .status.conditions[] it will also set Pulp-Operator-Finished-Execution to false

func WaitAPIPods

func WaitAPIPods[T any](resource T, pulp *repomanagerpulpprojectorgv1beta2.Pulp, deployment *appsv1.Deployment, timeout time.Duration)

WaitAPIPods waits until all API pods are in a READY state

Types

type CommonDeployment

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

CommonDeployment has the common definition for all pulpcore deployments

func (CommonDeployment) Deploy

func (d CommonDeployment) Deploy(resources any, pulpcoreType settings.PulpcoreType) client.Object

Deploy returns a common Deployment object that can be used by any pulpcore component

type DeploymentAPICommon

type DeploymentAPICommon struct {
	CommonDeployment
}

DeploymentAPICommon is the common pulpcore-api Deployment definition

func (DeploymentAPICommon) Deploy

func (d DeploymentAPICommon) Deploy(resources any) client.Object

Deploy returns a pulp-api Deployment object

type DeploymentContentCommon

type DeploymentContentCommon struct {
	CommonDeployment
}

DeploymentContentCommon is the common pulpcore-content Deployment definition

func (DeploymentContentCommon) Deploy

func (d DeploymentContentCommon) Deploy(resources any) client.Object

Deploy returns a pulp-content Deployment object

type DeploymentWorkerCommon

type DeploymentWorkerCommon struct {
	CommonDeployment
}

DeploymentWorkerCommon is the common pulpcore-worker Deployment definition

func (DeploymentWorkerCommon) Deploy

func (d DeploymentWorkerCommon) Deploy(resources any) client.Object

Deploy returns a pulp-worker Deployment object

type FunctionResources

FunctionResources contains the list of arguments passed to create new Pulp resources

type IngressPlugin

type IngressPlugin struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	ServiceName string `json:"serviceName"`
	TargetPort  string `json:"targetPort"`
	Rewrite     string `json:"rewrite"`
}

IngressPlugin defines a plugin ingress.

type PulpConfigMap

type PulpConfigMap struct{}

func (PulpConfigMap) GetFieldAndKind

func (PulpConfigMap) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpConfigMap) GetFields

func (PulpConfigMap) GetFields(obj ...interface{}) []interface{}

GetFields expects 2 arguments: * the current ConfigMap data * the expected ConfigMap data

func (PulpConfigMap) GetModifiedFunc

func (PulpConfigMap) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the COnfigMap modification

type PulpDeployment

type PulpDeployment struct{}

func (PulpDeployment) GetFieldAndKind

func (PulpDeployment) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpDeployment) GetFields

func (PulpDeployment) GetFields(obj ...interface{}) []interface{}

GetFields expects 3 arguments: * the current Deployment spec * the expected Deployment spec * a FunctionResources so that CheckDeploymentSpec can use it to get the labels from current Deployment

func (PulpDeployment) GetModifiedFunc

func (PulpDeployment) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the Deployment modification

type PulpIngress

type PulpIngress struct{}

func (PulpIngress) GetFieldAndKind

func (PulpIngress) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpIngress) GetFields

func (PulpIngress) GetFields(obj ...interface{}) []interface{}

GetFields expects 2 arguments: * the current Service spec field * the expected Service spec field

func (PulpIngress) GetModifiedFunc

func (PulpIngress) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the Ingress modification

type PulpObject

type PulpObject interface {
	GetFields(...interface{}) []interface{}
	GetModifiedFunc() func(...interface{}) bool
	GetFieldAndKind() (string, string)
}

PulpObject represents Pulp resources managed by pulp-operator

type PulpObjectMetadata

type PulpObjectMetadata struct{}

func (PulpObjectMetadata) GetFieldAndKind

func (PulpObjectMetadata) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpObjectMetadata) GetFields

func (PulpObjectMetadata) GetFields(obj ...interface{}) []interface{}

GetFields expects 2 arguments: * the current Object definition * the expected Object definition

func (PulpObjectMetadata) GetModifiedFunc

func (PulpObjectMetadata) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the Metadata modification

type PulpRoute

type PulpRoute struct{}

func (PulpRoute) GetFieldAndKind

func (PulpRoute) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpRoute) GetFields

func (PulpRoute) GetFields(obj ...interface{}) []interface{}

GetFields expects 3 arguments: * the current Deployment spec * the expected Deployment spec * a FunctionResources so that CheckDeploymentSpec can use it to get the labels from current Deployment

func (PulpRoute) GetModifiedFunc

func (PulpRoute) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the Route modification

type PulpSecret

type PulpSecret struct{}

func (PulpSecret) GetFieldAndKind

func (PulpSecret) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpSecret) GetFields

func (PulpSecret) GetFields(obj ...interface{}) []interface{}

GetFields expects 2 arguments: * the current encoded Secret data * the expected "raw" Secret string data

func (PulpSecret) GetModifiedFunc

func (PulpSecret) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the Secret modification

type PulpService

type PulpService struct{}

func (PulpService) GetFieldAndKind

func (PulpService) GetFieldAndKind() (string, string)

GetFieldAndKind returns the field being checked and the object kind

func (PulpService) GetFields

func (PulpService) GetFields(obj ...interface{}) []interface{}

GetFields expects 2 arguments: * the current Service spec field * the expected Service spec field

func (PulpService) GetModifiedFunc

func (PulpService) GetModifiedFunc() func(...interface{}) bool

GetModifiedFunc returns the function used to check the Service modification

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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