libraryapplyconfiguration

package
v0.0.0-...-812810b Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 28 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 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) (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

	AllDesiredMutationsGetter
}

func NewApplyConfigurationResultFromDirectory

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

type ClusterType

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

type ControllerWithInstanceName

type ControllerWithInstanceName interface {
	ControllerInstanceName() string
}

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) 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
	// Controllers hold an optional list of controller names to run.
	// '*' means "all controllersFromFlags are enabled by default"
	// 'foo' means "enable 'foo'"
	// '-foo' means "disable 'foo'"
	Controllers []string
}

func (SimpleOperatorStarter) RunOnce

func (a SimpleOperatorStarter) RunOnce(ctx context.Context) error

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