merger

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AllAgentContainers is a map of all agent containers

Functions

func AddEnvFromSourceFromToContainer

func AddEnvFromSourceFromToContainer(container *corev1.Container, envFromSource *corev1.EnvFromSource, mergeFunc EnvFromSourceFromMergeFunction) ([]corev1.EnvFromSource, error)

AddEnvFromSourceFromToContainer use to add an EnvFromSource to container.

func AddEnvVarToContainer

func AddEnvVarToContainer(container *corev1.Container, envvar *corev1.EnvVar, mergeFunc EnvVarMergeFunction) ([]corev1.EnvVar, error)

AddEnvVarToContainer used to add an EnvVar to a container

func AddPortToContainer

func AddPortToContainer(container *corev1.Container, newPort *corev1.ContainerPort, mergeFunc PortMergeFunction) ([]corev1.ContainerPort, error)

AddPortToContainer used to add an Port to a container

func AddVolumeMountToContainerWithMergeFunc

func AddVolumeMountToContainerWithMergeFunc(container *corev1.Container, volumeMount *corev1.VolumeMount, mergeFunc VolumeMountMergeFunction) ([]corev1.VolumeMount, error)

AddVolumeMountToContainerWithMergeFunc is used to add a corev1.VolumeMount to a container the mergeFunc can be provided to change the default merge behavior

func AddVolumeToPod

func AddVolumeToPod(podSpec *corev1.PodSpec, volume *corev1.Volume, mergeFunc VolumeMergeFunction) ([]corev1.Volume, error)

AddVolumeToPod use to add a corev1.Volume to a Pod the mergeFunc can be provided to change the default merge behavior

func AppendToValueEnvVarMergeFunction

func AppendToValueEnvVarMergeFunction(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error)

AppendToValueEnvVarMergeFunction used when we add the new value to the existing corev1.EnvVar.

func DefaultEnvFromSourceFromMergeFunction

func DefaultEnvFromSourceFromMergeFunction(current, newEnv *corev1.EnvFromSource) (*corev1.EnvFromSource, error)

DefaultEnvFromSourceFromMergeFunction default corev1.EnvFromSource merge function default correspond to OverrideCurrentEnvFromSourceMergeOption

func DefaultEnvVarMergeFunction

func DefaultEnvVarMergeFunction(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error)

DefaultEnvVarMergeFunction default corev1.EnvVar merge function default correspond to OverrideCurrentEnvVarMergeOption

func DefaultPortMergeFunction

func DefaultPortMergeFunction(current, newPort *corev1.ContainerPort) (*corev1.ContainerPort, error)

DefaultPortMergeFunction default corev1.ContainerPort merge function default correspond to OverrideCurrentPortMergeFunction

func DefaultVolumeMergeFunction

func DefaultVolumeMergeFunction(current, newVolume *corev1.Volume) (*corev1.Volume, error)

DefaultVolumeMergeFunction default corev1.Volume merge function default correspond to OverrideCurrentVolumeMergeOption

func DefaultVolumeMountMergeFunction

func DefaultVolumeMountMergeFunction(current, newVolumeMount *corev1.VolumeMount) (*corev1.VolumeMount, error)

DefaultVolumeMountMergeFunction default corev1.VolumeMount merge function default correspond to OverrideCurrentVolumeMountMergeOption

func ErrorOnMergeAttemptdEnvFromSourceFromMergeFunction

func ErrorOnMergeAttemptdEnvFromSourceFromMergeFunction(current, newEnv *corev1.EnvFromSource) (*corev1.EnvFromSource, error)

ErrorOnMergeAttemptdEnvFromSourceFromMergeFunction used to avoid replacing an existing corev1.EnvFromSource

func ErrorOnMergeAttemptdEnvVarMergeFunction

func ErrorOnMergeAttemptdEnvVarMergeFunction(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error)

ErrorOnMergeAttemptdEnvVarMergeFunction used to avoid replacing an existing EnvVar

func ErrorOnMergeAttemptdPortMergeFunction

func ErrorOnMergeAttemptdPortMergeFunction(current, newPort *corev1.ContainerPort) (*corev1.ContainerPort, error)

ErrorOnMergeAttemptdPortMergeFunction used to avoid replacing an existing ContainerPort

func ErrorOnMergeAttemptdVolumeMergeFunction

func ErrorOnMergeAttemptdVolumeMergeFunction(current, newVolume *corev1.Volume) (*corev1.Volume, error)

ErrorOnMergeAttemptdVolumeMergeFunction used to avoid replacing an existing Volume

func ErrorOnMergeAttemptdVolumeMountMergeFunction

func ErrorOnMergeAttemptdVolumeMountMergeFunction(current, newVolumeMount *corev1.VolumeMount) (*corev1.VolumeMount, error)

ErrorOnMergeAttemptdVolumeMountMergeFunction used to avoid replacing an existing VolumeMount

func IgnoreNewEnvFromSourceFromMergeFunction

func IgnoreNewEnvFromSourceFromMergeFunction(current, newEnv *corev1.EnvFromSource) (*corev1.EnvFromSource, error)

IgnoreNewEnvFromSourceFromMergeFunction used when the existing corev1.EnvFromSource needs to be kept.

func IgnoreNewEnvVarMergeFunction

func IgnoreNewEnvVarMergeFunction(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error)

IgnoreNewEnvVarMergeFunction used when the existing corev1.EnvVar needs to be kept.

func IgnoreNewPortMergeFunction

func IgnoreNewPortMergeFunction(current, newPort *corev1.ContainerPort) (*corev1.ContainerPort, error)

IgnoreNewPortMergeFunction used when the existing corev1.ContainerPort needs to be kept.

func IgnoreNewVolumeMergeFunction

func IgnoreNewVolumeMergeFunction(current, newVolume *corev1.Volume) (*corev1.Volume, error)

IgnoreNewVolumeMergeFunction used when the existing corev1.Volume needs to be kept.

func IgnoreNewVolumeMountMergeFunction

func IgnoreNewVolumeMountMergeFunction(current, newVolumeMount *corev1.VolumeMount) (*corev1.VolumeMount, error)

IgnoreNewVolumeMountMergeFunction used when the existing corev1.VolumeMount needs to be kept.

func IsMergeAttemptedError

func IsMergeAttemptedError(err error) bool

IsMergeAttemptedError returns true if the err is a MergeAttemptedError type

func MergeConfigMapItemsVolumeMergeFunction

func MergeConfigMapItemsVolumeMergeFunction(current, newVolume *corev1.Volume) (*corev1.Volume, error)

MergeConfigMapItemsVolumeMergeFunction used when the existing corev1.Volume needs to be replace by the new one.

func OverrideCurrentEnvFromSourceFromMergeFunction

func OverrideCurrentEnvFromSourceFromMergeFunction(current, newEnv *corev1.EnvFromSource) (*corev1.EnvFromSource, error)

OverrideCurrentEnvFromSourceFromMergeFunction used when the existing corev1.EnvFromSource new to be replace by the new one.

func OverrideCurrentEnvVarMergeFunction

func OverrideCurrentEnvVarMergeFunction(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error)

OverrideCurrentEnvVarMergeFunction used when the existing corev1.EnvVar new to be replace by the new one.

func OverrideCurrentPortMergeFunction

func OverrideCurrentPortMergeFunction(current, newPort *corev1.ContainerPort) (*corev1.ContainerPort, error)

OverrideCurrentPortMergeFunction used when the existing corev1.ContainerPort new to be replace by the new one.

func OverrideCurrentVolumeMergeFunction

func OverrideCurrentVolumeMergeFunction(current, newVolume *corev1.Volume) (*corev1.Volume, error)

OverrideCurrentVolumeMergeFunction used when the existing corev1.Volume new to be replace by the new one.

func OverrideCurrentVolumeMountMergeFunction

func OverrideCurrentVolumeMountMergeFunction(current, newVolumeMount *corev1.VolumeMount) (*corev1.VolumeMount, error)

OverrideCurrentVolumeMountMergeFunction used when the existing corev1.VolumeMount new to be replace by the new one.

func SortAndUnique

func SortAndUnique(in []corev1.Capability) []corev1.Capability

Types

type APIServiceManager

type APIServiceManager interface {
	AddAPIService(name, namespace string, spec apiregistrationv1.APIServiceSpec) error
}

APIServiceManager is used to manage service resources.

func NewAPIServiceManager

func NewAPIServiceManager(store dependencies.StoreClient) APIServiceManager

NewAPIServiceManager returns a new APIServiceManager instance

type AnnotationManager

type AnnotationManager interface {
	// AddAnnotation use to add an annotation to a Pod.
	AddAnnotation(key, value string)
}

AnnotationManager is used to manage adding annotations in a PodTemplateSpec

func NewAnnotationManager

func NewAnnotationManager(podTmpl *corev1.PodTemplateSpec) AnnotationManager

NewAnnotationManager returns a new instance of the AnnotationManager

type CiliumPolicyManager

type CiliumPolicyManager interface {
	AddCiliumPolicy(name, namespace string, policySpecs []cilium.NetworkPolicySpec) error
}

CiliumPolicyManager is used to manage cilium policy resources.

func NewCiliumPolicyManager

func NewCiliumPolicyManager(store dependencies.StoreClient) CiliumPolicyManager

NewCiliumPolicyManager returns a new CiliumPolicyManager instance

type ConfigMapManager

type ConfigMapManager interface {
	AddConfigMap(name, namespace string, data map[string]string) error
}

ConfigMapManager is used to manage configmap resources.

func NewConfigMapManager

func NewConfigMapManager(store dependencies.StoreClient) ConfigMapManager

NewConfigMapManager returns a new ConfigMapManager instance

type EnvFromSourceFromMergeFunction

type EnvFromSourceFromMergeFunction func(current, newEnv *corev1.EnvFromSource) (*corev1.EnvFromSource, error)

EnvFromSourceFromMergeFunction signature for corev1.EnvFromSource merge function

type EnvVarManager

type EnvVarManager interface {
	// AddEnvVar use to add an environment variable to all containers present in the Pod.
	AddEnvVar(newEnvVar *corev1.EnvVar)
	// AddEnvVarWithMergeFunc use to add an environment variable to all containers present in the Pod.
	// The way the EnvVar is merge with an existing EnvVar can be tune thank to the EnvVarMergeFunction parameter.
	AddEnvVarWithMergeFunc(newEnvVar *corev1.EnvVar, mergeFunc EnvVarMergeFunction) error
	// AddEnvVarToContainer use to add an environment variable to a specific container present in the Pod.
	AddEnvVarToContainer(containerName commonv1.AgentContainerName, newEnvVar *corev1.EnvVar)
	// AddEnvVarToInitContainer use to add an environment variable to a specific init container present in the Pod.
	AddEnvVarToInitContainer(containerName commonv1.AgentContainerName, newEnvVar *corev1.EnvVar)
	// AddEnvVarWithMergeFunc use to add an environment variable to a specific container present in the Pod.
	// The way the EnvVar is merge with an existing EnvVar can be tune thank to the EnvVarMergeFunction parameter.
	AddEnvVarToContainerWithMergeFunc(containerName commonv1.AgentContainerName, newEnvVar *corev1.EnvVar, mergeFunc EnvVarMergeFunction) error
}

EnvVarManager use to manage adding Environment variable to container in a PodTemplateSpec

func NewEnvVarManager

func NewEnvVarManager(podTmpl *corev1.PodTemplateSpec) EnvVarManager

NewEnvVarManager return new instance of the EnvVarManager

type EnvVarMergeFunction

type EnvVarMergeFunction func(current, newEnv *corev1.EnvVar) (*corev1.EnvVar, error)

EnvVarMergeFunction signature for corev1.EnvVar merge function

type NetworkPolicyManager

type NetworkPolicyManager interface {
	AddKubernetesNetworkPolicy(name, namespace string, podSelector metav1.LabelSelector, policyTypes []netv1.PolicyType, ingress []netv1.NetworkPolicyIngressRule, egress []netv1.NetworkPolicyEgressRule) error
}

NetworkPolicyManager is used to manage network policy resources.

func NewNetworkPolicyManager

func NewNetworkPolicyManager(store dependencies.StoreClient) NetworkPolicyManager

NewNetworkPolicyManager returns a new NetworkPolicyManager instance

type PodSecurityManager

type PodSecurityManager interface {
	// GetPodSecurityPolicy gets a PodSecurityPolicy
	GetPodSecurityPolicy(namespace string, pspName string) (*policyv1beta1.PodSecurityPolicy, error)
	// UpdatePodSecurityPolicy updates a PodSecurityPolicy
	UpdatePodSecurityPolicy(*policyv1beta1.PodSecurityPolicy)
}

PodSecurityManager use to manage Security resources.

func NewPodSecurityManager

func NewPodSecurityManager(store dependencies.StoreClient) PodSecurityManager

NewPodSecurityManager return new PodSecurityManager instance

type PortManager

type PortManager interface {
	// AddPortToContainer use to add a port to a specific container present in the Pod.
	AddPortToContainer(containerName commonv1.AgentContainerName, newPort *corev1.ContainerPort)
	// AddPortWithMergeFunc use to add a port to a specific container present in the Pod.
	// The way the Port is merge with an existing Port can be tune thank to the PortMergeFunction parameter.
	AddPortToContainerWithMergeFunc(containerName commonv1.AgentContainerName, newPort *corev1.ContainerPort, mergeFunc PortMergeFunction) error
}

PortManager use to manage adding ports to a container in a PodTemplateSpec

func NewPortManager

func NewPortManager(podTmpl *corev1.PodTemplateSpec) PortManager

NewPortManager return new instance of the PortManager

type PortMergeFunction

type PortMergeFunction func(current, newPort *corev1.ContainerPort) (*corev1.ContainerPort, error)

PortMergeFunction signature for corev1.ContainerPort merge function

type RBACManager

type RBACManager interface {
	AddServiceAccount(namespace string, name string) error
	AddServiceAccountByComponent(namespace, name, component string) error
	AddPolicyRules(namespace string, roleName string, saName string, policies []rbacv1.PolicyRule) error
	AddPolicyRulesByComponent(namespace string, roleName string, saName string, policies []rbacv1.PolicyRule, component string) error
	AddRoleBinding(roleNamespace, roleName, saNamespace, saName string, roleRef rbacv1.RoleRef) error
	AddClusterPolicyRules(namespace string, roleName string, saName string, policies []rbacv1.PolicyRule) error
	AddClusterPolicyRulesByComponent(namespace string, roleName string, saName string, policies []rbacv1.PolicyRule, component string) error
	AddClusterRoleBinding(namespace string, name string, saName string, roleRef rbacv1.RoleRef) error
	DeleteServiceAccountByComponent(component, namespace string) error
	DeleteRoleByComponent(component, namespace string) error
	DeleteClusterRoleByComponent(component string) error
}

RBACManager use to manage RBAC resources.

func NewRBACManager

func NewRBACManager(store dependencies.StoreClient) RBACManager

NewRBACManager return new RBACManager instance

type SecretManager

type SecretManager interface {
	AddSecret(secretNamespace, secretName, key, value string) error
	AddAnnotations(logger logr.Logger, secretNamespace, secretName string, extraAnnotations map[string]string) error
}

SecretManager Kubernetes Secret Manager interface

func NewSecretManager

func NewSecretManager(store dependencies.StoreClient) SecretManager

NewSecretManager return new SecretManager instance

type SecurityContextManager

type SecurityContextManager interface {
	// AddCapabilitiesToContainer Adds capabilities to a container in the PodTemplate.
	AddCapabilitiesToContainer(capabilities []corev1.Capability, containerName commonv1.AgentContainerName)
}

SecurityContextManager use to add Security Context settings to containers.

func NewSecurityContextManager

func NewSecurityContextManager(podTmpl *corev1.PodTemplateSpec) SecurityContextManager

NewSecurityContextManager returns a new instance of the SecurityContextManager

type ServiceManager

type ServiceManager interface {
	AddService(name, namespace string, selector map[string]string, ports []corev1.ServicePort, internalTrafficPolicy *corev1.ServiceInternalTrafficPolicyType) error
}

ServiceManager is used to manage service resources.

func NewServiceManager

func NewServiceManager(store dependencies.StoreClient) ServiceManager

NewServiceManager returns a new ServiceManager instance

type VolumeManager

type VolumeManager interface {
	// Add the volume to the PodTemplate.
	AddVolume(volume *corev1.Volume)
	// Add the volume to the PodTemplate.
	// Provide merge functions if the merge is specific.
	AddVolumeWithMergeFunc(volume *corev1.Volume, volumeMergeFunc VolumeMergeFunction) error
}

VolumeManager use to add a Volume to Pod and associated containers.

func NewVolumeManager

func NewVolumeManager(podTmpl *corev1.PodTemplateSpec) VolumeManager

NewVolumeManager returns a new instance of the VolumeManager

type VolumeMergeFunction

type VolumeMergeFunction func(current, newVolume *corev1.Volume) (*corev1.Volume, error)

VolumeMergeFunction signature for corev1.Volume merge function

type VolumeMountManager

type VolumeMountManager interface {
	// Add the volumeMount to all containers of the PodTemplate.
	AddVolumeMount(volumeMount *corev1.VolumeMount)
	// Add the volumeMount to one container of the PodTemplate.
	AddVolumeMountToContainer(volumeMount *corev1.VolumeMount, containerName commonv1.AgentContainerName)
	// Add the volumeMount to an init container pfo the PodTemplate.
	AddVolumeMountToInitContainer(volumeMount *corev1.VolumeMount, containerName commonv1.AgentContainerName)
	// Add the volumeMount to a list of containers in the PodTemplate.
	AddVolumeMountToContainers(volumeMount *corev1.VolumeMount, containerNames []commonv1.AgentContainerName)
	// Add the volumeMount to the container matching the containerName.
	// Provide merge functions if the merge is specific.
	AddVolumeMountToContainerWithMergeFunc(volumeMount *corev1.VolumeMount, containerName commonv1.AgentContainerName, volumeMountMergeFunc VolumeMountMergeFunction) error
}

VolumeMountManager use to add a Volume to Pod and associated containers.

func NewVolumeMountManager

func NewVolumeMountManager(podTmpl *corev1.PodTemplateSpec) VolumeMountManager

NewVolumeMountManager returns a new instance of the VolumeMountManager

type VolumeMountMergeFunction

type VolumeMountMergeFunction func(current, newVolumeMount *corev1.VolumeMount) (*corev1.VolumeMount, error)

VolumeMountMergeFunction signature for corev1.VolumeMount merge function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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