util

package
v0.0.0-...-0010da6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCredentials

func GetCredentials(ctx context.Context, client client.Client, secretRef *v1.ObjectReference, key string) (*google.Credentials, error)

GetCredentials gets GCP credentials from a secretRef. The credentials must be stored in JSON format in the secretRef.

func SetInternalStatus

func SetInternalStatus(ctx context.Context, c *eventingv1alpha1.Channel, pcs *GcpPubSubChannelStatus) error

SetInternalStatus saves GcpPubSubChannelStatus to the given Channel, which should only be one whose provisioner is gcp-pubsub.

Types

type GcpPubSubChannelStatus

type GcpPubSubChannelStatus struct {
	// Secret is the Secret that contains the credential to use.
	Secret *corev1.ObjectReference `json:"secret"`
	// SecretKey is the key in Secret that contains the credential to use.
	SecretKey string `json:"secretKey"`

	// GCPProject is the GCP project where the Topic and Subscription exist.
	GCPProject string `json:"gcpProject"`
	// Topic is the name of the PubSub Topic created in GCP to represent this Channel.
	Topic string `json:"topic,omitempty"`
	// Subscriptions is the list of Knative Eventing Subscriptions to this Channel, each paired with
	// the PubSub Subscription in GCP that represents it.
	Subscriptions []GcpPubSubSubscriptionStatus `json:"subscriptions,omitempty"`
}

GcpPubSubChannelStatus is the struct saved to Channel's status.internal if the Channel's provisioner is gcp-pubsub. It is used to send data to the dispatcher from the controller.

func GetInternalStatus

func GetInternalStatus(c *eventingv1alpha1.Channel) (*GcpPubSubChannelStatus, error)

GetInternalStatus reads GcpPubSubChannelStatus from the given Channel, which should only be one whose provisioner is gcp-pubsub. If the internal status is not set, then the empty GcpPubSubChannelStatus is returned.

func (*GcpPubSubChannelStatus) IsEmpty

func (pcs *GcpPubSubChannelStatus) IsEmpty() bool

IsEmpty determines if this GcpPubSubChannelStatus is equivalent to &GcpPubSubChannelStatus{}. It exists because slices are not compared by golang's ==.

type GcpPubSubSubscriptionStatus

type GcpPubSubSubscriptionStatus struct {
	// Ref is a reference to the Knative Eventing Subscription that this status represents.
	// +optional
	Ref *corev1.ObjectReference `json:"ref,omitempty"`
	// SubscriberURI is a copy of the SubscriberURI of this Subscription.
	// +optional
	SubscriberURI string `json:"subscriberURI,omitempty"`
	// ReplyURI is a copy of the ReplyURI of this Subscription.
	// +optional
	ReplyURI string `json:"replyURI,omitempty"`

	// Subscription is the name of the PubSub Subscription resource in GCP that represents this
	// Knative Eventing Subscription.
	Subscription string `json:"subscription,omitempty"`
}

GcpPubSubSubscriptionStatus represents the saved status of a gcp-pubsub Channel.

type PubSubClient

type PubSubClient interface {
	SubscriptionInProject(id, projectId string) PubSubSubscription
	CreateSubscription(ctx context.Context, id string, topic PubSubTopic) (PubSubSubscription, error)
	Topic(id string) PubSubTopic
	CreateTopic(ctx context.Context, id string) (PubSubTopic, error)
}

PubSubClient is the set of methods we use on pubsub.Client. See pubsub.Client for documentation of the functions.

func GcpPubSubClientCreator

func GcpPubSubClientCreator(ctx context.Context, creds *google.Credentials, googleCloudProject string) (PubSubClient, error)

GcpPubSubClientCreator creates a real GCP PubSub client. It should always be used, except during unit tests.

type PubSubClientCreator

type PubSubClientCreator func(ctx context.Context, creds *google.Credentials, googleCloudProject string) (PubSubClient, error)

PubSubClientCreator creates a pubSubClient.

type PubSubMessage

type PubSubMessage interface {
	ID() string
	Data() []byte
	Attributes() map[string]string
	Ack()
	Nack()
}

PubSubMessage is the set of methods we use on pubsub.Message. It exists to make PubSubClient unit testable. See pubsub.Message for documentation of the functions.

type PubSubPublishResult

type PubSubPublishResult interface {
	Ready() <-chan struct{}
	Get(ctx context.Context) (serverID string, err error)
}

PubSubPublishResult is the set of methods we use on pubsub.PublishResult. It exists to make PubSubClient unit testable. See pubsub.PublishResult for documentation of any functions.

type PubSubSubscription

type PubSubSubscription interface {
	Exists(ctx context.Context) (bool, error)
	ID() string
	Delete(ctx context.Context) error
	Receive(ctx context.Context, f func(context.Context, PubSubMessage)) error
}

PubSubSubscription is the set of methods we use on pubsub.Subscription. It exists to make PubSubClient unit testable. See pubsub.Subscription for documentation of the functions.

type PubSubTopic

type PubSubTopic interface {
	Exists(ctx context.Context) (bool, error)
	ID() string
	Delete(ctx context.Context) error
	Publish(ctx context.Context, msg *pubsub.Message) PubSubPublishResult
	Stop()
}

PubSubTopic is the set of methods we use on pubsub.Topic. It exists to make PubSubClient unit testable. See pubsub.Topic for documentation of the functions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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