util

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChannelHostName

func ChannelHostName(channelName, channelNamespace string) string

ChannelHostName Creates A Name For The Channel Host

func ChannelKey

func ChannelKey(channel *kafkav1beta1.KafkaChannel) string

ChannelKey Creates A Knative Reconciler "Key" Formatted Representation Of The Specified Channel

func ChannelLogger

func ChannelLogger(logger *zap.Logger, channel *kafkav1beta1.KafkaChannel) *zap.Logger

ChannelLogger Gets A Logger With Channel Info

func CheckDeploymentChanged added in v0.23.0

func CheckDeploymentChanged(logger *zap.Logger, oldDeployment, newDeployment *appsv1.Deployment) (*appsv1.Deployment, bool)

CheckDeploymentChanged returns a new Deployment based on the oldDeployment but with updated data from the newDeployment as well as a boolean indicator of whether any changes were necessary. Only specific portions of the Deployment are evaluated including...

  • ObjectMeta Labels & Annotations
  • Spec.Template.ObjectMeta Labels & Annotations
  • Spec.Template.Spec.Containers (excluding certain fields)

Note - Spec.Replicas are ignored to avoid overwriting local HPA configuration.

func CheckServiceChanged added in v0.23.0

func CheckServiceChanged(logger *zap.Logger, oldService, newService *corev1.Service) ([]byte, bool)

CheckServiceChanged Modifies A Service With New Fields (If Necessary) Returns True If Any Modifications Were Made

func ConnectionPoolKeyMapper added in v0.24.0

func ConnectionPoolKeyMapper(subscription *messagingv1.Subscription) (string, error)

ConnectionPoolKeyMapper returns a string representing the control-protocol ControlPlaneConnectionPool Key for the specified Knative Subscription.

func DataPlaneLabelsMapper added in v0.24.0

func DataPlaneLabelsMapper(subscription *messagingv1.Subscription) (map[string]string, error)

DataPlaneLabelsMapper returns a map of Kubernetes Labels identifying the distributed KafkaChannels' Dispatcher pods.

func DataPlaneNamespaceMapper added in v0.24.0

func DataPlaneNamespaceMapper(_ *messagingv1.Subscription) (string, error)

DataPlaneNamespaceMapper returns the Kubernetes Namespace where the data-plane components (e.g. Dispatcher) are created by the distributed KafkaChannel controller.

func DispatcherDnsSafeName

func DispatcherDnsSafeName(channel *kafkav1beta1.KafkaChannel) string

DispatcherDnsSafeName creates a DNS-Safe name for the specified KafkaChannel suitable for use with K8S Services

func GenerateHash

func GenerateHash(stringToHash string, length int) string

Generate An MD5 Hash Of A String And Return Desired Number Of Characters

func GenerateValidDnsName

func GenerateValidDnsName(name string, length int, prefix bool, suffix bool) string

Return A Valid DNS Name Which Is As Close To The Specified Name As Possible & Truncated To The Smaller Of Specified Length / 63

func GroupIdMapper added in v0.24.0

func GroupIdMapper(subscription *messagingv1.Subscription) (string, error)

GroupIdMapper returns a string representing the Kafka ConsumerGroup ID for the specified Knative Subscription.

func HasFinalizer

func HasFinalizer(finalizer string, objectMeta *metav1.ObjectMeta) bool

Determine Whether ObjectMeta Contains Specified Finalizer

func KubernetesResourceFinalizerName

func KubernetesResourceFinalizerName(finalizerSuffix string) string

Get A Kubernetes "Qualified" Finalizer Name With The Specified Suffix

When adding finalizers to Kubernetes built-in components (Secrets, ConfigMaps, Services, etc...) it is necessary to "qualify" the finalizer name by including a "/". Kubernetes performs validation on the finalizer names and only accepts the following values if NOT qualified ...

    FinalizerOrphanDependents string = "orphan"
    FinalizerDeleteDependents string = "foregroundDeletion"
	   FinalizerKubernetes FinalizerName = "kubernetes"

... and will produce the following error message ...

metadata.finalizers[0]: Invalid value: \"externaltarget-controller\": name is neither a standard finalizer name nor is it fully qualified

This is in contrast with Finalizers on a Custom Resource which can just be any arbitrary string. There was little to no documentation on this and it required tracing the Kubernetes pkg/apis/core source code to decipher what a "qualified" name format would be.

func NewChannelOwnerReference

func NewChannelOwnerReference(channel *kafkav1beta1.KafkaChannel) metav1.OwnerReference

NewChannelOwnerReference Creates A New OwnerReference For The Specified KafkaChannel (Controller)

func NewSubscriptionControllerRef

func NewSubscriptionControllerRef(subscription *messagingv1.Subscription) metav1.OwnerReference

NewSubscriptionControllerRef creates a new Controller OwnerReference for the specified Knative Subscription.

func ReceiverDnsSafeName

func ReceiverDnsSafeName(kafkaSecretName string) string

ReceiverDnsSafeName Creates A DNS Safe Name For The Receiver Deployment Using The Specified Kafka Secret

Note - The current implementation creates a single Receiver Deployment for each

Kafka Authentication (K8S Secrets) instance.

func RemoveFinalizer

func RemoveFinalizer(finalizer string, objectMeta *metav1.ObjectMeta)

Remove The Specified Finalizer From The Object

func SubscriptionLogger

func SubscriptionLogger(logger *zap.Logger, subscription *messagingv1.Subscription) *zap.Logger

SubscriptionLogger returns a Logger with Subscription info.

func TopicName

func TopicName(channel *kafkav1beta1.KafkaChannel) string

Get The TopicName For Specified KafkaChannel (ChannelNamespace.ChannelName)

func TopicNameMapper added in v0.24.0

func TopicNameMapper(subscription *messagingv1.Subscription) (string, error)

TopicNameMapper returns a string representing the Kafka Topic name for the specified Knative Subscription.

Types

This section is empty.

Jump to

Keyboard shortcuts

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