libraryapplyconfiguration

package
v0.0.0-...-20aa390 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

README

This package is something that is useful for building testing methodology will move to library-go eventually.

Start by calling func NewSampleOperatorApplyConfigurationCommand(applyConfigurationFn ApplyConfigurationFunc, streams genericiooptions.IOStreams) *cobra.Command { and adding that command as your apply-configuration command.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalizeApplyConfigurationRunResult

func CanonicalizeApplyConfigurationRunResult(obj *ApplyConfigurationRunResult)

func EquivalentApplyConfigurationResultIgnoringEvents

func EquivalentApplyConfigurationResultIgnoringEvents(lhs, rhs ApplyConfigurationResult) []string

func EquivalentClusterApplyResultIgnoringEvents

func EquivalentClusterApplyResultIgnoringEvents(field string, lhs, rhs SingleClusterDesiredMutationGetter) []string

func NewApplyConfigurationCommand

func NewApplyConfigurationCommand(applyConfigurationFn ApplyConfigurationFunc, outputResourcesFn libraryoutputresources.OutputResourcesFunc, streams genericiooptions.IOStreams) *cobra.Command

func NewApplyConfigurationFromClient

func NewApplyConfigurationFromClient(
	mutationTracker *manifestclient.AllActionsTracker[manifestclient.TrackedSerializedRequest],
) *applyConfiguration

func NewNamedRunOnce

func NewNamedRunOnce(controllerInstanceName string, runOnce RunOnceFunc) *namedRunOnce

func UnspecifiedOutputResources

func UnspecifiedOutputResources(allDesiredMutationsGetter AllDesiredMutationsGetter, allAllowedOutputResources *libraryoutputresources.OutputResources) []manifestclient.SerializedRequestish

func ValidateAllDesiredMutationsGetter

func ValidateAllDesiredMutationsGetter(allDesiredMutationsGetter AllDesiredMutationsGetter, allAllowedOutputResources *libraryoutputresources.OutputResources) error

func WriteApplyConfiguration

func WriteApplyConfiguration(desiredApplyConfiguration AllDesiredMutationsGetter, outputDirectory string) error

Types

type AllDesiredMutationsGetter

type AllDesiredMutationsGetter interface {
	MutationsForClusterType(clusterType ClusterType) SingleClusterDesiredMutationGetter
}

AllDesiredMutationsGetter provides access to mutations targeted at all available types of clusters

func FilterAllDesiredMutationsGetter

func FilterAllDesiredMutationsGetter(
	in AllDesiredMutationsGetter,
	allAllowedOutputResources *libraryoutputresources.OutputResources,
) AllDesiredMutationsGetter

type ApplyConfigurationFunc

type ApplyConfigurationFunc func(ctx context.Context, applyConfigurationInput ApplyConfigurationInput) (*ApplyConfigurationRunResult, AllDesiredMutationsGetter, error)

ApplyConfigurationFunc is a function called for applying configuration.

type ApplyConfigurationInput

type ApplyConfigurationInput struct {
	// MutationTrackingClient is offered as an alternative to the inputDirectory to make it easier to provide mocks to code.
	// This forces all downstream code to rely on the client reading aspects and not grow an odd dependency to disk.
	MutationTrackingClient manifestclient.MutationTrackingClient

	// Now is the declared time that this function was called at.  It doesn't necessarily bear any relationship to
	// the actual time.  This is another aspect that makes unit and integration testing easier.
	Clock clock.Clock

	// Streams is for I/O.  The StdIn will usually be nil'd out.
	Streams genericiooptions.IOStreams

	// Controllers holds a list of controller names to run.
	Controllers []string
}

ApplyConfigurationInput is provided to the ApplyConfigurationFunc

type ApplyConfigurationResult

type ApplyConfigurationResult interface {
	Error() error
	OutputDirectory() (string, error)
	Stdout() string
	Stderr() string
	ControllerResults() *ApplyConfigurationRunResult

	AllDesiredMutationsGetter
}

func NewApplyConfigurationResultFromDirectory

func NewApplyConfigurationResultFromDirectory(inFS fs.FS, outputDirectory string, execError error) (ApplyConfigurationResult, error)

type ApplyConfigurationRunResult

type ApplyConfigurationRunResult struct {
	ControllerResults []ControllerRunResult `json:"controllerResults"`
}

type ClusterType

type ClusterType string
var (
	ClusterTypeConfiguration ClusterType = "Configuration"
	ClusterTypeManagement    ClusterType = "Management"
	ClusterTypeUserWorkload  ClusterType = "UserWorkload"
	AllClusterTypes                      = sets.New(ClusterTypeConfiguration, ClusterTypeManagement, ClusterTypeUserWorkload)
)

type ControllerRunResult

type ControllerRunResult struct {
	ControllerName string              `json:"controllerName"`
	Status         ControllerRunStatus `json:"status"`
	Errors         []ErrorDetails      `json:"errors,omitempty"`
	PanicStack     string              `json:"panicStack,omitempty"`
}

type ControllerRunStatus

type ControllerRunStatus string
var (
	ControllerRunStatusUnknown   ControllerRunStatus = "Unknown"
	ControllerRunStatusSucceeded ControllerRunStatus = "Succeeded"
	ControllerRunStatusSkipped   ControllerRunStatus = "Skipped"
	ControllerRunStatusFailed    ControllerRunStatus = "Failed"
	ControllerRunStatusPanicked  ControllerRunStatus = "Panicked"
)

type ControllerWithInstanceName

type ControllerWithInstanceName interface {
	ControllerInstanceName() string
}

type ErrorDetails

type ErrorDetails struct {
	Message string `json:"message"`
}

TODO perhaps we add indications about interfaces this matches?

type GeneratedInformerFactory

type GeneratedInformerFactory interface {
	Start(stopCh <-chan struct{})
	WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
}

type GeneratedNamespacedInformerFactory

type GeneratedNamespacedInformerFactory interface {
	Start(stopCh <-chan struct{})
	WaitForCacheSync(stopCh <-chan struct{}) map[string]map[reflect.Type]bool
}

type MutationActionReader

type MutationActionReader interface {
	ListActions() []manifestclient.Action
	RequestsForAction(action manifestclient.Action) []manifestclient.SerializedRequestish
	AllRequests() []manifestclient.SerializedRequestish
}

MutationActionReader provides access to serialized mutation requests

type NamedRunOnce

type NamedRunOnce interface {
	ControllerInstanceName() string
	RunOnce(context.Context) error
}

func AdaptNamedController

func AdaptNamedController(eventRecorder events.Recorder, controller Syncer) NamedRunOnce

func AdaptSyncFn

func AdaptSyncFn(eventRecorder events.Recorder, controllerName string, originalRunOnce func(ctx context.Context, syncCtx factory.SyncContext) error) NamedRunOnce

type OperatorStarter

type OperatorStarter interface {
	RunOnce(ctx context.Context, input ApplyConfigurationInput) (*ApplyConfigurationRunResult, AllDesiredMutationsGetter, error)
	Start(ctx context.Context) error
}

type RunFunc

type RunFunc func(ctx context.Context)

func AdaptRunFn

func AdaptRunFn(fn func(ctx context.Context, workers int)) RunFunc

type RunOnceFunc

type RunOnceFunc func(ctx context.Context) error

type SimpleOperatorStarter

type SimpleOperatorStarter struct {
	Informers                 []SimplifiedInformerFactory
	ControllerNamedRunOnceFns []NamedRunOnce
	// ControllerRunFns is useful during a transition to coalesce the operator launching flow.
	ControllerRunFns []RunFunc
}

func (SimpleOperatorStarter) Start

type SimplifiedInformerFactory

type SimplifiedInformerFactory interface {
	Start(ctx context.Context)
	WaitForCacheSync(ctx context.Context)
}

type SingleClusterDesiredMutationGetter

type SingleClusterDesiredMutationGetter interface {
	GetClusterType() ClusterType
	Requests() MutationActionReader
}

SingleClusterDesiredMutationGetter provides access to mutations targeted at a single type of cluster

type Syncer

type Syncer interface {
	Sync(ctx context.Context, controllerContext factory.SyncContext) error
}

Jump to

Keyboard shortcuts

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