deployer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 9 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClient

func GetClient(ctx context.Context, l logr.Logger, c client.Client, numOfWorker int) *deployer

GetClient return a deployer client, implementing the DeployerInterface

func GetKey

func GetKey(clusterNamespace, clusterName, applicant, featureID string, cleanup bool) string

GetKey returns a unique ID for a request provided: - clusterNamespace and clusterName which are the namespace/name of the CAPI cluster where feature needs to be deployed; - featureID is a unique identifier for the feature that needs to be deployed.

Types

type DeployerInterface

type DeployerInterface interface {
	// RegisterFeatureID allows registering a feature ID.
	// If a featureID is already registered, it returns an error.
	RegisterFeatureID(
		featureID string,
	) error

	// Deploy creates a request to deploy/cleanup a feature in a given
	// CAPI cluster (identified by clusterNamespace, clusterName).
	// cleanup indicates whether request is for feature to be provisioned
	// or removed.
	// When worker is available to fulfill such request, RequestHandler
	// will be invoked in the worker context.
	// If featureID is not registered, an error will be returned.
	// Applicant is an identifier of whatever is making this request.
	// It can be left empty (in case there is no need to differentiate between
	// different applicants).
	Deploy(
		ctx context.Context,
		clusterNamespace, clusterName, applicant, featureID string,
		cleanup bool,
		f RequestHandler,
		m MetricHandler,
	) error

	// IsInProgress returns true, if featureID for clusterNamespace/clusterName
	// requested by applicant is currently in progress.
	// cleanup indicates whether request for feature to be provisioned or
	// removed is currently in progress.
	IsInProgress(
		clusterNamespace, clusterName, applicant, featureID string,
		cleanup bool,
	) bool

	// GetResult returns result for a given request.
	GetResult(
		ctx context.Context,
		clusterNamespace, clusterName, applicant, featureID string,
		cleanup bool,
	) Result

	// CleanupEntries removes any entry (from any internal data structure) for
	// given feature
	CleanupEntries(clusterNamespace, clusterName, applicant, featureID string,
		cleanup bool)
}

type MetricHandler

type MetricHandler func(elapsed time.Duration,
	clusterNamespace, clusterName, featureID string,
	logger logr.Logger)

type RequestHandler

type RequestHandler func(ctx context.Context, c client.Client,
	clusterNamespace, clusterName, applicant, featureID string,
	logger logr.Logger) error

type Result

type Result struct {
	ResultStatus
	Err error
}

type ResultStatus

type ResultStatus int64
const (
	Deployed ResultStatus = iota
	InProgress
	Failed
	Removed
	Unavailable
)

func (ResultStatus) String

func (r ResultStatus) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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