cloudevent

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 20 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventForTaskRun

func EventForTaskRun(taskRun *v1beta1.TaskRun) (*cloudevents.Event, error)

EventForTaskRun will create a new event based on a TaskRun, or return an error if not possible.

func GetCloudEventDeliveryCompareOptions

func GetCloudEventDeliveryCompareOptions() []cmp.Option

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

func InitializeCloudEvents

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

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

func NewFakeClient

func NewFakeClient(behaviour *FakeClientBehaviour) cloudevents.Client

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

func SendCloudEvents

func SendCloudEvents(tr *v1beta1.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

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 cloudevents.Client

CEClient matches the `Client` interface from github.com/cloudevents/sdk-go/v2/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) Request

Request fakes the Request method from cloudevents.Client

func (FakeClient) Send

Send fakes the Send method from cloudevents.Client

func (FakeClient) StartReceiver

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

StartReceiver fakes StartReceiver method from cloudevents.Client

type FakeClientBehaviour

type FakeClientBehaviour struct {
	SendSuccessfully bool
}

FakeClientBehaviour defines how the client will behave

type TektonCloudEventData

type TektonCloudEventData struct {
	TaskRun *v1beta1.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 *v1beta1.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"
)

func (TektonEventType) String

func (t TektonEventType) String() string

Jump to

Keyboard shortcuts

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