cloudevent

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCloudEventDeliveryCompareOptions

func GetCloudEventDeliveryCompareOptions() []cmp.Option

GetCloudEventDeliveryCompareOptions returns compare options to sort and compare a list of CloudEventDelivery

func InitializeCloudEvents

func InitializeCloudEvents(tr *v1alpha1.TaskRun, prs []*v1alpha1.PipelineResource)

InitializeCloudEvents initializes the CloudEvents part of the TaskRunStatus from a slice of PipelineResources

func NewFakeClient

func NewFakeClient(behaviour *FakeClientBehaviour) client.Client

NewFakeClient is a FakeClient factory, it returns a client for the target

func SendCloudEvent

func SendCloudEvent(sinkURI, eventID, eventSourceURI string, data []byte, eventType TektonEventType, logger *zap.SugaredLogger, cloudEventClient CEClient) (cloudevents.Event, error)

SendCloudEvent sends a Cloud Event to the specified SinkURI

func SendCloudEvents

func SendCloudEvents(tr *v1alpha1.TaskRun, ceclient CEClient, logger *zap.SugaredLogger) error

SendCloudEvents is used by the TaskRun controller to send cloud events once the TaskRun is complete. `tr` is used to obtain the list of targets but also to construct the body of the

func SendTaskRunCloudEvent

func SendTaskRunCloudEvent(sinkURI string, taskRun *v1alpha1.TaskRun, logger *zap.SugaredLogger, cloudEventClient CEClient) (cloudevents.Event, error)

SendTaskRunCloudEvent sends a cloud event for a TaskRun

func WithClient

func WithClient(ctx context.Context, behaviour *FakeClientBehaviour) context.Context

WithClient adds to the context a fake client with the desired behaviour

Types

type CECKey

type CECKey struct{}

CECKey is used to associate the CloudEventClient inside the context.Context

type CEClient

type CEClient client.Client

CEClient matches the `Client` interface from github.com/cloudevents/sdk-go/pkg/cloudevents

func Get

func Get(ctx context.Context) CEClient

Get extracts the cloudEventClient client from the context.

type FakeClient

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

FakeClient is a fake CloudEvent client for unit testing Holding a pointer to the behaviour allows to change the behaviour of a client

func (FakeClient) Send

Send fakes the Send method from kncloudevents.NewDefaultClient

func (FakeClient) StartReceiver

func (c FakeClient) StartReceiver(ctx context.Context, fn interface{}) error

StartReceiver fakes the StartReceiver method from kncloudevents.NewDefaultClient

type FakeClientBehaviour

type FakeClientBehaviour struct {
	SendSuccessfully bool
}

FakeClientBehaviour defines how the client will behave

type TektonCloudEventData

type TektonCloudEventData struct {
	TaskRun *v1alpha1.TaskRun `json:"taskRun"`
}

TektonCloudEventData type is used to marshal and unmarshal the payload of a Tekton cloud event. It only includes a TaskRun for now. Using a type opens the possibility for the future to add more data to the payload

func NewTektonCloudEventData

func NewTektonCloudEventData(taskRun *v1alpha1.TaskRun) TektonCloudEventData

NewTektonCloudEventData returns a new instance of NewTektonCloudEventData

type TektonEventType

type TektonEventType string

TektonEventType holds the types of cloud events sent by Tekton

const (
	// TektonTaskRunUnknownV1 is sent for TaskRuns with "ConditionSucceeded" "Unknown"
	TektonTaskRunUnknownV1 TektonEventType = "dev.tekton.event.task.unknown.v1"
	// TektonTaskRunSuccessfulV1 is sent for TaskRuns with "ConditionSucceeded" "True"
	TektonTaskRunSuccessfulV1 TektonEventType = "dev.tekton.event.task.successful.v1"
	// TektonTaskRunFailedV1 is sent for TaskRuns with "ConditionSucceeded" "False"
	TektonTaskRunFailedV1 TektonEventType = "dev.tekton.event.task.failed.v1"
)

Jump to

Keyboard shortcuts

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