preflight_kit_sdk

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 18 Imported by: 2

README

PreflightKit Go SDK

This module contains helper and interfaces which will help you to implement preflights using the preflight kit go api.

The module encapsulates the following technical aspects:

  • JSON marshalling and unmarshalling of preflight inputs and outputs
  • The sdk will wrap around your describe call and will provide some meaningful defaults for your endpoint definitions.
  • An additional layer of rollback stability. The SDK will keep a copy of your preflight state in memory to be able to roll back to the previous state in case of connections issues.
  • Automatic handling of file parameters. The SDK will automatically download the file, store it in a temporary directory and delete the file after the preflight has stopped. The Config-map in preflight_kit_api.PreparePreflightRequestBody will contain the path to the downloaded file.

Installation

Add the following to your go.mod file:

go get github.com/steadybit/preflight-kit/go/preflight_kit_sdk

Usage

  1. Implement at least the preflight_kit_sdk.Preflight interface:

  2. Implement other interfaces if you need them:

    • preflight_kit_sdk.PreflightWithStatus
    • preflight_kit_sdk.PreflightWithStop
    • preflight_kit_sdk.PreflightWithMetricQuery
  3. Register your preflight:

    preflight_kit_sdk.RegisterPreflight(NewRolloutRestartPreflight())
    
  4. Add your registered preflights to the index endpoint of your extension:

    exthttp.RegisterHttpHandler("/preflights", exthttp.GetterAsHandler(preflight_kit_sdk.GetPreflightList))
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelAllActivePreflights

func CancelAllActivePreflights(reason string)

func CancelPreflight

func CancelPreflight(ctx context.Context, preflightActionExecutionId uuid.UUID, reason string)

func ClearRegisteredPreflights

func ClearRegisteredPreflights()

ClearRegisteredPreflights clears all registered preflights - used for testing. Warning: This will not remove the registered routes from the http server.

func GetPreflightList

func GetPreflightList() preflight_kit_api.PreflightList

GetPreflightList returns a list of all root endpoints of registered preflights.

func RegisterCoverageEndpoints

func RegisterCoverageEndpoints()

RegisterCoverageEndpoints registers two endpoints which get called by preflight_kit_test to retrieve coverage data.

func RegisterPreflight

func RegisterPreflight(a Preflight)

Types

type Preflight

type Preflight interface {
	// Describe returns the preflight description.
	Describe() preflight_kit_api.PreflightDescription
	// Start is called when the preflight should actually happen.
	// [Details](https://github.com/steadybit/preflight-kit/blob/main/docs/preflight-api.md#start)
	Start(ctx context.Context, request preflight_kit_api.StartPreflightRequestBody) (*preflight_kit_api.StartResult, error)
	// Status is used to observe the current status of the preflight. This is called periodically by the preflight-kit if time control [preflight_kit_api.TimeControlInternal] or [preflight_kit_api.TimeControlExternal] is used.
	// [Details](https://github.com/steadybit/preflight-kit/blob/main/docs/preflight-api.md#status)
	Status(ctx context.Context, request preflight_kit_api.StatusPreflightRequestBody) (*preflight_kit_api.StatusResult, error)
}

type PreflightWithCancel

type PreflightWithCancel interface {
	Preflight
	// Cancel is used to clean up any leftovers. This method is optional.
	// [Details](https://github.com/steadybit/preflight-kit/blob/main/docs/preflight-api.md#cancel)
	Cancel(ctx context.Context, request preflight_kit_api.CancelPreflightRequestBody) (*preflight_kit_api.CancelResult, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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