sdk

package
v0.0.0-...-a0d6768 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 30 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLogger

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

DefaultLogger implementation of Logger using the go log package

func (DefaultLogger) Debug

func (d DefaultLogger) Debug(v ...interface{})

func (DefaultLogger) Debugf

func (d DefaultLogger) Debugf(format string, v ...interface{})

func (DefaultLogger) Error

func (d DefaultLogger) Error(v ...interface{})

func (DefaultLogger) Errorf

func (d DefaultLogger) Errorf(format string, v ...interface{})

func (DefaultLogger) Fatal

func (d DefaultLogger) Fatal(v ...interface{})

func (DefaultLogger) Fatalf

func (d DefaultLogger) Fatalf(format string, v ...interface{})

func (DefaultLogger) Info

func (d DefaultLogger) Info(v ...interface{})

func (DefaultLogger) Infof

func (d DefaultLogger) Infof(format string, v ...interface{})

func (DefaultLogger) Warn

func (d DefaultLogger) Warn(v ...interface{})

func (DefaultLogger) Warnf

func (d DefaultLogger) Warnf(format string, v ...interface{})

type Error

type Error struct {
	StatusType keptnv2.StatusType
	ResultType keptnv2.ResultType
	Message    string
	Err        error
}

func (Error) Error

func (e Error) Error() string

type FailingResourceHandler

type FailingResourceHandler struct {
}

func (FailingResourceHandler) GetResource

func (f FailingResourceHandler) GetResource(scope api.ResourceScope, options ...api.URIOption) (*models.Resource, error)

type FakeKeptn

type FakeKeptn struct {
	TestResourceHandler ResourceHandler
	SentEvents          []models.KeptnContextExtendedCE
	Keptn               *Keptn
}

func NewFakeKeptn

func NewFakeKeptn(source string) *FakeKeptn

func (*FakeKeptn) AddTaskHandler

func (f *FakeKeptn) AddTaskHandler(eventType string, handler TaskHandler, filters ...func(keptnHandle IKeptn, event KeptnEvent) bool)

func (*FakeKeptn) AddTaskHandlerWithSubscriptionID

func (f *FakeKeptn) AddTaskHandlerWithSubscriptionID(eventType string, handler TaskHandler, subscriptionID string, filters ...func(keptnHandle IKeptn, event KeptnEvent) bool)

func (*FakeKeptn) AssertNumberOfEventSent

func (f *FakeKeptn) AssertNumberOfEventSent(t *testing.T, numOfEvents int)

func (*FakeKeptn) AssertSentEvent

func (f *FakeKeptn) AssertSentEvent(t *testing.T, eventIndex int, assertFn func(ce models.KeptnContextExtendedCE) bool)

func (*FakeKeptn) AssertSentEventResult

func (f *FakeKeptn) AssertSentEventResult(t *testing.T, eventIndex int, result v0_2_0.ResultType)

func (*FakeKeptn) AssertSentEventStatus

func (f *FakeKeptn) AssertSentEventStatus(t *testing.T, eventIndex int, status v0_2_0.StatusType)

func (*FakeKeptn) AssertSentEventType

func (f *FakeKeptn) AssertSentEventType(t *testing.T, eventIndex int, eventType string)

func (*FakeKeptn) GetResourceHandler

func (f *FakeKeptn) GetResourceHandler() ResourceHandler

func (*FakeKeptn) NewEvent

func (f *FakeKeptn) NewEvent(event models.KeptnContextExtendedCE) error

func (*FakeKeptn) SetAPI

func (f *FakeKeptn) SetAPI(api api.KeptnInterface)

func (*FakeKeptn) SetAutomaticResponse

func (f *FakeKeptn) SetAutomaticResponse(autoResponse bool)

func (*FakeKeptn) SetResourceHandler

func (f *FakeKeptn) SetResourceHandler(handler ResourceHandler)

type IKeptn

type IKeptn interface {
	// Start starts the internal event handling logic and needs to be called by the user
	// after creating value of IKeptn
	Start() error
	// GetResourceHandler returns a handler to fetch data from the configuration service
	GetResourceHandler() ResourceHandler
	// SendStartedEvent sends a started event for the given input event to the Keptn API
	SendStartedEvent(event KeptnEvent) error
	// SendFinishedEvent sends a finished event for the given input event to the Keptn API
	SendFinishedEvent(event KeptnEvent, result interface{}) error
	// Logger returns the logger used by the sdk
	// Per default DefaultLogger is used which internally just uses the go logging package
	// Another logger can be configured using the sdk.WithLogger function
	Logger() Logger
	// APIV1 returns API utils for all Keptn APIs
	APIV1() api.KeptnInterface
}

type Keptn

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

Keptn is the default implementation of IKeptn

func NewKeptn

func NewKeptn(source string, opts ...KeptnOption) *Keptn

NewKeptn creates a new Keptn

func (*Keptn) APIV1

func (k *Keptn) APIV1() api.KeptnInterface

func (*Keptn) GetResourceHandler

func (k *Keptn) GetResourceHandler() ResourceHandler

func (*Keptn) Logger

func (k *Keptn) Logger() Logger

func (*Keptn) OnEvent

func (k *Keptn) OnEvent(ctx context.Context, event models.KeptnContextExtendedCE) error

func (*Keptn) RegistrationData

func (k *Keptn) RegistrationData() controlplane.RegistrationData

func (*Keptn) SendFinishedEvent

func (k *Keptn) SendFinishedEvent(event KeptnEvent, result interface{}) error

func (*Keptn) SendStartedEvent

func (k *Keptn) SendStartedEvent(event KeptnEvent) error

func (*Keptn) Start

func (k *Keptn) Start() error

type KeptnOption

type KeptnOption func(*Keptn)

KeptnOption can be used to configure the keptn sdk

func WithAutomaticResponse

func WithAutomaticResponse(autoResponse bool) KeptnOption

WithAutomaticResponse sets the option to instruct the sdk to automatically send a .started and .finished event. Per default this behavior is turned on and can be disabled with this function

func WithGracefulShutdown

func WithGracefulShutdown(gracefulShutdown bool) KeptnOption

WithGracefulShutdown sets the option to ensure running tasks/handlers will finish in case of interrupt or forced termination Per default this behavior is turned on and can be disabled with this function

func WithLogger

func WithLogger(logger Logger) KeptnOption

WithLogger configures keptn to use another logger

func WithTaskHandler

func WithTaskHandler(eventType string, handler TaskHandler, filters ...func(keptnHandle IKeptn, event KeptnEvent) bool) KeptnOption

WithTaskHandler registers a handler which is responsible for processing a .triggered event

type Logger

type Logger interface {
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
}

Logger interface used by the go sdk

type ResourceHandler

type ResourceHandler interface {
	GetResource(scope api.ResourceScope, options ...api.URIOption) (*models.Resource, error)
}

type StringResourceHandler

type StringResourceHandler struct {
	ResourceContent string
}

func (StringResourceHandler) GetResource

func (s StringResourceHandler) GetResource(scope api.ResourceScope, options ...api.URIOption) (*models.Resource, error)

type TaskHandler

type TaskHandler interface {
	// Execute is called whenever the actual business-logic of the service shall be executed.
	// Thus, the core logic of the service shall be triggered/implemented in this method.
	//
	// Note, that the contract of the method is to return the payload of the .finished event to be sent out as well as a Error Pointer
	// or nil, if there was no error during execution.
	Execute(keptnHandle IKeptn, event KeptnEvent) (interface{}, *Error)
}

type TestResourceHandler

type TestResourceHandler struct {
	Resource models.Resource
}

func (TestResourceHandler) GetResource

func (t TestResourceHandler) GetResource(scope api.ResourceScope, options ...api.URIOption) (*models.Resource, error)

Jump to

Keyboard shortcuts

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