util

package
v0.0.0-...-a52e8f6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SubscriptionSourceID is the key for source id in label
	SubscriptionSourceID = "kyma-source-id"
	// SubscriptionEventType is the key for event type in label
	SubscriptionEventType = "kyma-event-type"
	// SubscriptionEventTypeVersion is the key for event type version in label
	SubscriptionEventTypeVersion = "kyma-event-type-version"
	// SubNs is the key for namespace of the subscription
	SubNs = "kyma-ns"
)
View Source
const (
	// FieldKnativeChannelName knative channel name field
	FieldKnativeChannelName = "knative-channel-name"
)

Variables

This section is empty.

Functions

func ActivateSubscriptionForKnSubscription

func ActivateSubscriptionForKnSubscription(client kymaeventingclientv1alpha1.EventingV1alpha1Interface, sub *kymaeventingv1alpha1.Subscription, log *zap.Logger, time CurrentTime) error

ActivateSubscriptionForKnSubscription activates a Kyma Subscription when Kn Subscription is ready

func ActivateSubscriptions

ActivateSubscriptions activates subscriptions.

func CheckIfEventActivationExistForSubscription

func CheckIfEventActivationExistForSubscription(eventActivationLister applicationconnectorlistersv1alpha1.EventActivationLister, sub *kymaeventingv1alpha1.Subscription) bool

CheckIfEventActivationExistForSubscription returns a boolean value indicating if there is an EventActivation for the Subscription or not.

func ContainsString

func ContainsString(slice *[]string, s string) bool

ContainsString returns true if the string exists in the array.

func DeactivateSubscriptionForKnSubscription

func DeactivateSubscriptionForKnSubscription(client kymaeventingclientv1alpha1.EventingV1alpha1Interface, sub *kymaeventingv1alpha1.Subscription, log *zap.Logger, time CurrentTime) error

DeactivateSubscriptionForKnSubscription deactivates a Kyma Subscription when Kn Subscription is not ready

func DeactivateSubscriptions

DeactivateSubscriptions deactivate subscriptions.

func ErrorInvalidChannelNameLength

func ErrorInvalidChannelNameLength(channelNameMaxLength int) *publish.Error

ErrorInvalidChannelNameLength returns a publish.Error instance.

func GetDefaultChannelNamespace

func GetDefaultChannelNamespace() string

GetDefaultChannelNamespace returns the default namespace of Knative/Eventing channels and subscriptions

func GetKnSubscriptionName

func GetKnSubscriptionName(kySubscriptionName, kySubscriptionNamespace *string) string

GetKnSubscriptionName joins the kySubscriptionName and kySubscriptionNamespace

func GetKymaSubscriptionForSubscription

GetKymaSubscriptionForSubscription gets Kyma Subscription for a particular Knative Subscription

func GetSubscriptionsForEventActivation

GetSubscriptionsForEventActivation gets the "ea" object of all the subscriptions having the same "namespace" and the same "Source"

func IsSubscriptionActivated

func IsSubscriptionActivated(sub *kymaeventingv1alpha1.Subscription) bool

IsSubscriptionActivated checks if the subscription is active or not.

func RemoveString

func RemoveString(slice *[]string, s string) (result []string)

RemoveString removes the string from in the array and returns a new array instance.

func SetNotReadySubscription

SetNotReadySubscription set subscription as not ready.

func SetReadySubscription

SetReadySubscription set subscription as ready.

func UpdateEventActivation

UpdateEventActivation handles Kyma EventActivation

func UpdateKnativeSubscription

func UpdateKnativeSubscription(client messagingv1alpha1.MessagingV1alpha1Interface, subscription *evapisv1alpha1.Subscription) error

UpdateKnativeSubscription updates Knative subscription on change in Finalizer

func WriteSubscription

WriteSubscription writes a subscription.

Types

type ChannelReadyFunc

type ChannelReadyFunc func(name string, lister evlistersv1alpha1.ChannelNamespaceLister) error

ChannelReadyFunc is a function used to ensure that a Channel has become Ready.

func WaitForChannelWithTimeout

func WaitForChannelWithTimeout(timeout time.Duration) ChannelReadyFunc

WaitForChannelWithTimeout returns a function that waits until a Channel gets Ready or fails after a timeout.

type CurrentTime

type CurrentTime interface {
	GetCurrentTime() metav1.Time
}

CurrentTime handles current time

func NewDefaultCurrentTime

func NewDefaultCurrentTime() CurrentTime

NewDefaultCurrentTime returns a new CurrentTime instance

type DefaultCurrentTime

type DefaultCurrentTime struct{}

DefaultCurrentTime represents the default current time

func (*DefaultCurrentTime) GetCurrentTime

func (t *DefaultCurrentTime) GetCurrentTime() metav1.Time

GetCurrentTime returns the current time.

type KnativeAccessLib

type KnativeAccessLib interface {
	GetChannelByLabels(namespace string, labels map[string]string) (*messagingV1Alpha1.Channel, error)
	CreateChannel(prefix, namespace string, labels map[string]string, readyFn ...ChannelReadyFunc) (*messagingV1Alpha1.Channel, error)
	DeleteChannel(name string, namespace string) error
	CreateSubscription(name string, namespace string, channelName string, uri *string, labels map[string]string) error
	DeleteSubscription(name string, namespace string) error
	GetSubscription(name string, namespace string) (*messagingV1Alpha1.Subscription, error)
	UpdateSubscription(sub *messagingV1Alpha1.Subscription) (*messagingV1Alpha1.Subscription, error)
	SendMessage(channel *messagingV1Alpha1.Channel, headers *map[string][]string, message *string) error
	InjectClient(evClient eventingv1alpha1.EventingV1alpha1Interface, msgClient messagingv1alpha1.MessagingV1alpha1Interface) error
	MsgChannelClient() messagingv1alpha1.MessagingV1alpha1Interface
}

KnativeAccessLib encapsulates the Knative access lib behaviours.

type KnativeLib

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

KnativeLib represents the knative lib.

func GetKnativeLib

func GetKnativeLib() (*KnativeLib, error)

GetKnativeLib returns the Knative/Eventing access layer

func NewKnativeLib

func NewKnativeLib() (*KnativeLib, error)

NewKnativeLib returns an interface to KnativeLib, which can be mocked

func (*KnativeLib) CreateChannel

func (k *KnativeLib) CreateChannel(prefix, namespace string, labels map[string]string,
	readyFn ...ChannelReadyFunc) (*messagingV1Alpha1.Channel, error)

CreateChannel creates a Knative/Eventing channel controlled by the specified provisioner

func (*KnativeLib) CreateSubscription

func (k *KnativeLib) CreateSubscription(name string, namespace string, channelName string, uri *string, labels map[string]string) error

CreateSubscription creates a Knative/Eventing subscription for the specified channel

func (*KnativeLib) DeleteChannel

func (k *KnativeLib) DeleteChannel(name string, namespace string) error

DeleteChannel deletes a Knative/Eventing channel

func (*KnativeLib) DeleteSubscription

func (k *KnativeLib) DeleteSubscription(name string, namespace string) error

DeleteSubscription deletes a Knative/Eventing subscription

func (*KnativeLib) GetChannelByLabels

func (k *KnativeLib) GetChannelByLabels(namespace string, labels map[string]string) (*messagingV1Alpha1.Channel, error)

GetChannelByLabels return a knative channel fetched via label selectors so based on the labels, we assume that the list of channels should have only one item in it Hence, we'd be returning the item at 0th index.

func (*KnativeLib) GetSubscription

func (k *KnativeLib) GetSubscription(name string, namespace string) (*messagingV1Alpha1.Subscription, error)

GetSubscription gets a Knative/Eventing subscription

func (*KnativeLib) InjectClient

InjectClient injects a client, useful for running tests.

func (*KnativeLib) MsgChannelClient

MsgChannelClient returns a clientset interface for messaging v1alpha1 API

func (*KnativeLib) SendMessage

func (k *KnativeLib) SendMessage(channel *messagingV1Alpha1.Channel, headers *map[string][]string, payload *string) error

SendMessage sends a message to a channel

func (*KnativeLib) UpdateSubscription

UpdateSubscription updates an existing subscription

type SubscriptionBuilder

type SubscriptionBuilder struct {
	*messagingv1alpha1.Subscription
}

SubscriptionBuilder represents the subscription builder that is used in the internal knative util package and the knative subscription controller tests.

func Subscription

func Subscription(name string, namespace string, labels map[string]string) *SubscriptionBuilder

Subscription returns a new SubscriptionBuilder instance.

func (*SubscriptionBuilder) Build

Build returns an v1alpha1.Subscription instance.

func (*SubscriptionBuilder) EmptyReply

func (s *SubscriptionBuilder) EmptyReply() *SubscriptionBuilder

EmptyReply sets the SubscriptionBuilder Reply.

func (*SubscriptionBuilder) ToChannel

func (s *SubscriptionBuilder) ToChannel(name string) *SubscriptionBuilder

ToChannel sets SubscriptionBuilder Channel.

func (*SubscriptionBuilder) ToK8sService

func (s *SubscriptionBuilder) ToK8sService(k8sServiceName string) *SubscriptionBuilder

ToK8sService sets the SubscriptionBuilder Subscriber to Kubernetes service.

func (*SubscriptionBuilder) ToKNService

func (s *SubscriptionBuilder) ToKNService(knServiceName string) *SubscriptionBuilder

ToKNService sets the SubscriptionBuilder Subscriber to Knative service.

func (*SubscriptionBuilder) ToURI

ToURI sets the SubscriptionBuilder Subscriber URI.

type SubscriptionWithError

type SubscriptionWithError struct {
	Sub *kymaeventingv1alpha1.Subscription
	Err error
}

SubscriptionWithError handles Kyma subscriptions

func WriteSubscriptions

WriteSubscriptions writes subscriptions.

Jump to

Keyboard shortcuts

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