Documentation ¶
Index ¶
- type DefaultLogger
- func (d DefaultLogger) Debug(v ...interface{})
- func (d DefaultLogger) Debugf(format string, v ...interface{})
- func (d DefaultLogger) Error(v ...interface{})
- func (d DefaultLogger) Errorf(format string, v ...interface{})
- func (d DefaultLogger) Fatal(v ...interface{})
- func (d DefaultLogger) Fatalf(format string, v ...interface{})
- func (d DefaultLogger) Info(v ...interface{})
- func (d DefaultLogger) Infof(format string, v ...interface{})
- func (d DefaultLogger) Warn(v ...interface{})
- func (d DefaultLogger) Warnf(format string, v ...interface{})
- type Error
- type FailingResourceHandler
- type FakeKeptn
- func (f *FakeKeptn) AddTaskEventHandler(eventType string, handler TaskHandler, options TaskHandlerOptions)
- func (f *FakeKeptn) AddTaskHandler(eventType string, handler TaskHandler, ...)
- func (f *FakeKeptn) AddTaskHandlerWithSubscriptionID(eventType string, handler TaskHandler, subscriptionID string, ...)
- func (f *FakeKeptn) AssertNumberOfEventSent(t *testing.T, numOfEvents int)
- func (f *FakeKeptn) AssertSentEvent(t *testing.T, eventIndex int, ...)
- func (f *FakeKeptn) AssertSentEventResult(t *testing.T, eventIndex int, result v0_2_0.ResultType)
- func (f *FakeKeptn) AssertSentEventStatus(t *testing.T, eventIndex int, status v0_2_0.StatusType)
- func (f *FakeKeptn) AssertSentEventType(t *testing.T, eventIndex int, eventType string)
- func (f *FakeKeptn) GetResourceHandler() ResourceHandler
- func (f *FakeKeptn) NewEvent(event models.KeptnContextExtendedCE) error
- func (f *FakeKeptn) SetAPI(api api.KeptnInterface)
- func (f *FakeKeptn) SetAutomaticResponse(autoResponse bool)
- func (f *FakeKeptn) SetResourceHandler(handler ResourceHandler)
- type IKeptn
- type Keptn
- func (k *Keptn) APIV1() api.KeptnInterface
- func (k *Keptn) APIV2() apiv2.KeptnInterface
- func (k *Keptn) GetResourceHandler() ResourceHandler
- func (k *Keptn) Logger() Logger
- func (k *Keptn) OnEvent(ctx context.Context, event models.KeptnContextExtendedCE) error
- func (k *Keptn) RegistrationData() controlplane.RegistrationData
- func (k *Keptn) SendFinishedEvent(parentEvent KeptnEvent, newEventData interface{}) error
- func (k *Keptn) SendStartedEvent(parentEvent KeptnEvent) error
- func (k *Keptn) Start() error
- type KeptnEvent
- type KeptnOption
- func WithAutomaticResponse(autoResponse bool) KeptnOption
- func WithGracefulShutdown(gracefulShutdown bool) KeptnOption
- func WithLogger(logger Logger) KeptnOption
- func WithTaskEventHandler(eventType string, handler TaskHandler, options TaskHandlerOptions) KeptnOption
- func WithTaskHandler(eventType string, handler TaskHandler, ...) KeptnOption
- type Logger
- type ResourceHandler
- type StringResourceHandler
- type TaskHandler
- type TaskHandlerOptions
- type TestResourceHandler
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 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 (*FakeKeptn) AddTaskEventHandler ¶ added in v0.19.0
func (f *FakeKeptn) AddTaskEventHandler(eventType string, handler TaskHandler, options TaskHandlerOptions)
func (*FakeKeptn) AddTaskHandler ¶
func (f *FakeKeptn) AddTaskHandler(eventType string, handler TaskHandler, filters ...func(keptnHandle IKeptn, event KeptnEvent) bool)
AddTaskEventHandler registers a TaskHandler Deprecated: use AddTaskEventHandler
func (*FakeKeptn) AddTaskHandlerWithSubscriptionID ¶
func (f *FakeKeptn) AddTaskHandlerWithSubscriptionID(eventType string, handler TaskHandler, subscriptionID string, filters ...func(keptnHandle IKeptn, event KeptnEvent) bool)
func (*FakeKeptn) AssertNumberOfEventSent ¶
func (*FakeKeptn) AssertSentEvent ¶
func (*FakeKeptn) AssertSentEventResult ¶
func (*FakeKeptn) AssertSentEventStatus ¶
func (*FakeKeptn) AssertSentEventType ¶
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 (*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 // The first parameter is the "parent" event from which common information like e.g. // the keptn context, task name, ... are taken and used for constructing the corresponding .started event SendStartedEvent(KeptnEvent) error // SendFinishedEvent sends a finished event for the given input event to the Keptn API. // The first parameter can be seen as the "parent" event from which common information like e.g. // the keptn context, task name, ... are taken and used for constructing the corresponding .finished event. // The second parameter is the new event data to be set on the newly constructed .finished event SendFinishedEvent(KeptnEvent, 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 // APIV2 returns API utils for all v2 Keptn APIs APIV2() apiv2.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
APIV1 retrieves the APIV1 client Deprecated use APIV2 instead
func (*Keptn) APIV2 ¶ added in v0.19.0
func (k *Keptn) APIV2() apiv2.KeptnInterface
APIV2 retrieves the APIV2 client
func (*Keptn) GetResourceHandler ¶
func (k *Keptn) GetResourceHandler() ResourceHandler
func (*Keptn) RegistrationData ¶
func (k *Keptn) RegistrationData() controlplane.RegistrationData
func (*Keptn) SendFinishedEvent ¶
func (k *Keptn) SendFinishedEvent(parentEvent KeptnEvent, newEventData interface{}) error
func (*Keptn) SendStartedEvent ¶
func (k *Keptn) SendStartedEvent(parentEvent KeptnEvent) error
type KeptnEvent ¶
type KeptnEvent models.KeptnContextExtendedCE
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. Note, that this affects ALL task handlers. If you want to disable automatic event responses for a specific task handler, this can be done with the respective TaskHandlerOptions passed to WithTaskEventHandler
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 WithTaskEventHandler ¶ added in v0.19.0
func WithTaskEventHandler(eventType string, handler TaskHandler, options TaskHandlerOptions) KeptnOption
WithTaskEventHandler registers a handler which is responsible for processing a received .triggered event
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. Note, that if you want to have more control on configuring the behavior of the task handler, you can use WithTaskEventHandler instead
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 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 TaskHandlerOptions ¶ added in v0.19.0
type TaskHandlerOptions struct { // Filters specifies functions that determine whether the event shall be handled or ignored Filters []func(IKeptn, KeptnEvent) bool // SkipAutomaticResponse determines whether automatic sending of .started/.finished events should be skipped SkipAutomaticResponse bool }
TaskHandlerOptions are specific options for a task handler
type TestResourceHandler ¶
func (TestResourceHandler) GetResource ¶
func (t TestResourceHandler) GetResource(scope api.ResourceScope, options ...api.URIOption) (*models.Resource, error)