steps

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName           = "collector-cluster-check"
	ServiceVersion        = "0.1.0"
	LabelSelector         = "app.kubernetes.io/created-by=collector-cluster-checker"
	CertManagerCrdName    = "issuers.cert-manager.io"
	ServiceMonitorCrdName = "servicemonitors.monitoring.coreos.com"
	OtelCrdName           = "opentelemetrycollectors.opentelemetry.io"
	OtelOperatorSelector  = "app.kubernetes.io/name=opentelemetry-operator"
	CertManagerSelector   = "app.kubernetes.io/name=cert-manager"
)

Variables

View Source
var (
	ColRes = schema.GroupVersionResource{Group: "opentelemetry.io", Version: "v1alpha1", Resource: "opentelemetrycollectors"}
	PodRes = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}
)

Functions

func Empty

func Empty(c *Deps)

Empty is for a step that doesn't change configuration

Types

type Check

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

func NewCheck

func NewCheck(name string, description string, steps []Step) *Check

func (*Check) Dependencies

func (c *Check) Dependencies(conf *Config) []Dependency

func (*Check) Description

func (c *Check) Description() string

func (*Check) Name

func (c *Check) Name() string

func (*Check) Run

func (c *Check) Run(ctx context.Context, deps *Deps, conf *Config) ([]Results, []Results)

type Config

type Config struct {
	Endpoint   string
	Insecure   bool
	Http       bool
	Token      string
	KubeConfig string
}

type Dependency

type Dependency interface {
	// Describable requires that every Dependency has a name and description
	Describable
	// Run can return an option that should be applied to the config object
	// Result represents whether the run was successful
	Run(ctx context.Context, deps *Deps) (Option, Result)

	// Dependencies is a list of dependencies that must be run prior to this one
	Dependencies(conf *Config) []Dependency

	// Shutdown allows the dependency to gracefully exit
	Shutdown(ctx context.Context) error
}

type Deps

type Deps struct {
	KubeClient           kubernetes.Interface
	CustomResourceClient apiextensionsclientset.Interface
	DynamicClient        dynamic.Interface
	MeterProvider        *sdkmetric.MeterProvider
	TracerProvider       *sdktrace.TracerProvider
	OtelColConfig        *unstructured.Unstructured
	KubeConf             *rest.Config
	PortForward          *PortForwardedResource
}

func NewDependencies

func NewDependencies() *Deps

type Describable

type Describable interface {
	// Name is a single word identifier
	Name() string

	// Description is the optional explanation for what the step does
	Description() string
}

type Option

type Option func(c *Deps)

func WithCustomResourceClient

func WithCustomResourceClient(client apiextensionsclientset.Interface) Option

func WithDynamicClient

func WithDynamicClient(client dynamic.Interface) Option

func WithKubeConfig

func WithKubeConfig(conf *rest.Config) Option

func WithKubernetesClient

func WithKubernetesClient(client kubernetes.Interface) Option

func WithMeterProvider

func WithMeterProvider(mp *sdkmetric.MeterProvider) Option

func WithOtelColConfig

func WithOtelColConfig(conf *unstructured.Unstructured) Option

func WithPortForwardedResource

func WithPortForwardedResource(pfr *PortForwardedResource) Option

func WithTracerProvider

func WithTracerProvider(tp *sdktrace.TracerProvider) Option

type PortForwardedResource

type PortForwardedResource struct {
	Name      string
	LocalPort int
	Close     func()
}

type Result

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

func NewAcceptableFailureResult

func NewAcceptableFailureResult(err error) Result

func NewAcceptableFailureResultWithHelp

func NewAcceptableFailureResultWithHelp(err error, help string) Result

func NewFailureResult

func NewFailureResult(err error) Result

func NewFailureResultWithHelp

func NewFailureResultWithHelp(err error, help string) Result

func NewSuccessfulResult

func NewSuccessfulResult(message string) Result

func (Result) Err

func (r Result) Err() error

func (Result) Message

func (r Result) Message() string

func (Result) ShouldContinue

func (r Result) ShouldContinue() bool

func (Result) Successful

func (r Result) Successful() bool

type Results

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

func NewResults

func NewResults(s Describable, r ...Result) Results

func (Results) ShouldStop

func (r Results) ShouldStop() bool

func (Results) StepName

func (r Results) StepName() string

func (Results) Steps

func (r Results) Steps() []Result

type Step

type Step interface {
	// Describable requires that every Step has a name and description
	Describable
	// Run can return an option that should be applied to the config object
	// Result represents whether the run was successful
	Run(ctx context.Context, deps *Deps) Results

	// Dependencies is a list of steps that must be run prior to this step
	Dependencies(conf *Config) []Dependency
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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