cloudevent

package
v0.0.0-...-8ee384e Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ArtifactPackagedEventAnnotation cdEventAnnotationType = "cd.artifact.packaged"
View Source
const ArtifactPublishedEventAnnotation cdEventAnnotationType = "cd.artifact.published"
View Source
const ServiceDeployedEventAnnotation cdEventAnnotationType = "cd.service.deployed"
View Source
const ServiceRemovedEventAnnotation cdEventAnnotationType = "cd.service.removed"
View Source
const ServiceRolledbackEventAnnotation cdEventAnnotationType = "cd.service.rolledback"
View Source
const ServiceUpgradedEventAnnotation cdEventAnnotationType = "cd.service.upgraded"

Variables

This section is empty.

Functions

func Get

Get extracts the cloudEventClient client from the context.

func GetCloudEventDeliveryCompareOptions

func GetCloudEventDeliveryCompareOptions() []cmp.Option

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

func SendCloudEventWithRetries

func SendCloudEventWithRetries(ctx context.Context, object runtime.Object, format string) error

SendCloudEventWithRetries sends a cloud event for the specified resource. It does not block and it perform retries with backoff using the cloudevents sdk-go capabilities. It accepts a runtime.Object to avoid making objectWithCondition public since it's only used within the events/cloudevents packages.

func ToContext

func ToContext(ctx context.Context, cec cloudevents.Client) context.Context

ToContext adds the cloud events client to the context

func WithClient

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

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

func WithFakeClient

func WithFakeClient(ctx context.Context, cfg *rest.Config) context.Context

WithFakeClient adds to the context a fake client with the positive behaviour

Types

type CDECloudEventData

type CDECloudEventData map[string]string

type CECKey

type CECKey struct{}

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

type EventStatus

type EventStatus string

TODO(afrittoli) The valid statuses should be encoded in the SDK EvenStatus encodes valid statuses defined in https://github.com/cdfoundation/sig-events/blob/main/vocabulary-draft/core.md#continuous-delivery-core-events

const (
	StatusRunning  EventStatus = "Running"
	StatusFinished EventStatus = "Finished"
	StatusError    EventStatus = "Error"
)

type EventType

type EventType struct {
	Type   cdeevents.CDEventType
	Status EventStatus
}

type FakeClient

type FakeClient struct {

	// Modelled after k8s.io/client-go fake recorder
	Events chan string
	// contains filtered or unexported fields
}

FakeClient is a fake CloudEvent client for unit testing Holding 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,omitempty"`
	PipelineRun *v1beta1.PipelineRun `json:"pipelineRun,omitempty"`
	Run         *v1alpha1.Run        `json:"run,omitempty"`
}

TektonCloudEventData type is used to marshal and unmarshal the payload of a Tekton cloud event. It can include a TaskRun or a PipelineRun

type TektonEventType

type TektonEventType string

TektonEventType holds the types of cloud events sent by Tekton

const (
	// TaskRunStartedEventV1 is sent for TaskRuns with "ConditionSucceeded" "Unknown"
	// the first time they are picked up by the reconciler
	TaskRunStartedEventV1 TektonEventType = "dev.tekton.event.taskrun.started.v1"
	// TaskRunRunningEventV1 is sent for TaskRuns with "ConditionSucceeded" "Unknown"
	// once the TaskRun is validated and Pod created
	TaskRunRunningEventV1 TektonEventType = "dev.tekton.event.taskrun.running.v1"
	// TaskRunUnknownEventV1 is sent for TaskRuns with "ConditionSucceeded" "Unknown"
	// It can be used as a confirmation that the TaskRun is still running.
	TaskRunUnknownEventV1 TektonEventType = "dev.tekton.event.taskrun.unknown.v1"
	// TaskRunSuccessfulEventV1 is sent for TaskRuns with "ConditionSucceeded" "True"
	TaskRunSuccessfulEventV1 TektonEventType = "dev.tekton.event.taskrun.successful.v1"
	// TaskRunFailedEventV1 is sent for TaskRuns with "ConditionSucceeded" "False"
	TaskRunFailedEventV1 TektonEventType = "dev.tekton.event.taskrun.failed.v1"
	// PipelineRunStartedEventV1 is sent for PipelineRuns with "ConditionSucceeded" "Unknown"
	// the first time they are picked up by the reconciler
	PipelineRunStartedEventV1 TektonEventType = "dev.tekton.event.pipelinerun.started.v1"
	// PipelineRunRunningEventV1 is sent for PipelineRuns with "ConditionSucceeded" "Unknown"
	// once the PipelineRun is validated and Pod created
	PipelineRunRunningEventV1 TektonEventType = "dev.tekton.event.pipelinerun.running.v1"
	// PipelineRunUnknownEventV1 is sent for PipelineRuns with "ConditionSucceeded" "Unknown"
	// It can be used as a confirmation that the PipelineRun is still running.
	PipelineRunUnknownEventV1 TektonEventType = "dev.tekton.event.pipelinerun.unknown.v1"
	// PipelineRunSuccessfulEventV1 is sent for PipelineRuns with "ConditionSucceeded" "True"
	PipelineRunSuccessfulEventV1 TektonEventType = "dev.tekton.event.pipelinerun.successful.v1"
	// PipelineRunFailedEventV1 is sent for PipelineRuns with "ConditionSucceeded" "False"
	PipelineRunFailedEventV1 TektonEventType = "dev.tekton.event.pipelinerun.failed.v1"
	// RunStartedEventV1 is sent for Runs with "ConditionSucceeded" "Unknown"
	// the first time they are picked up by the reconciler
	RunStartedEventV1 TektonEventType = "dev.tekton.event.run.started.v1"
	// RunRunningEventV1 is sent for Runs with "ConditionSucceeded" "Unknown"
	// once the Run is validated and Pod created
	RunRunningEventV1 TektonEventType = "dev.tekton.event.run.running.v1"
	// RunSuccessfulEventV1 is sent for Runs with "ConditionSucceeded" "True"
	RunSuccessfulEventV1 TektonEventType = "dev.tekton.event.run.successful.v1"
	// RunFailedEventV1 is sent for Runs with "ConditionSucceeded" "False"
	RunFailedEventV1 TektonEventType = "dev.tekton.event.run.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