Documentation ¶
Index ¶
- Variables
- func DefaultMetaOptions(f *Feature) []cluster.MetaOptions
- func Define(featureName string) *featureBuilder
- func ExtractEntry[T any](key string) func(f *Feature) (T, error)
- func Get[T any](f *Feature, key string) (T, error)
- func OwnedBy(f *Feature) cluster.MetaOptions
- type Action
- func CreateNamespaceIfNotExists(namespace string) Action
- func EnsureOperatorIsInstalled(operatorName string) Action
- func Entry[T any](key string, providerFunc provider.DataProviderFunc[T]) Action
- func WaitForPodsToBeReady(namespace string) Action
- func WaitForResourceToBeCreated(namespace string, gvk schema.GroupVersionKind) Action
- type CleanupFunc
- type DataDefinition
- type DataEntry
- type EnabledFunc
- type Feature
- type FeaturesHandler
- type FeaturesProvider
- type FeaturesRegistry
- type HandlerWithReporter
- type MissingOperatorError
Constants ¶
This section is empty.
Variables ¶
var EmptyFeaturesHandler = &FeaturesHandler{ features: []*Feature{}, featuresProviders: []FeaturesProvider{}, }
EmptyFeaturesHandler is noop handler so that we can avoid nil checks in the code and safely call Apply/Delete methods.
Functions ¶
func DefaultMetaOptions ¶ added in v2.15.0
func DefaultMetaOptions(f *Feature) []cluster.MetaOptions
func Define ¶ added in v2.15.0
func Define(featureName string) *featureBuilder
Define creates a new feature builder with the given name.
func ExtractEntry ¶ added in v2.15.0
ExtractEntry is a convenient way to define how to extract a value from the given Feature's data using defined key.
func Get ¶ added in v2.15.0
Get allows to retrieve arbitrary value from the Feature's data container.
func OwnedBy ¶ added in v2.10.0
func OwnedBy(f *Feature) cluster.MetaOptions
OwnedBy returns a cluster.MetaOptions that sets the owner reference to the FeatureTracker resource.
Types ¶
type Action ¶
Action is a func type which can be used for different purposes during Feature's lifecycle while having access to Feature struct.
func CreateNamespaceIfNotExists ¶ added in v2.7.0
CreateNamespaceIfNotExists will create a namespace with the given name if it does not exist yet. It does not set ownership nor apply extra metadata to the existing namespace.
func EnsureOperatorIsInstalled ¶ added in v2.9.0
func Entry ¶ added in v2.15.0
func Entry[T any](key string, providerFunc provider.DataProviderFunc[T]) Action
Entry allows to define association between a name under which the data is stored in the Feature and a data provider defining the logic for fetching. Provider is a function allowing to fetch a value for a given key dynamically by interacting with Kubernetes client.
If the value is static, consider using provider.ValueOf(variable).Get as passed provider function.
func WaitForPodsToBeReady ¶
func WaitForResourceToBeCreated ¶
func WaitForResourceToBeCreated(namespace string, gvk schema.GroupVersionKind) Action
type CleanupFunc ¶ added in v2.17.0
CleanupFunc defines how to clean up resources associated with a feature. By default, all resources created by the feature are deleted when the feature is, so there is no need to explicitly add cleanup hooks for them. This is useful when you need to perform some additional cleanup actions such as removing effects of a patch operation.
type DataDefinition ¶ added in v2.15.0
type DataDefinition[S, T any] struct { // Define is a factory function to create a Feature's DataEntry from the given source. Define func(source *S) DataEntry[T] // Extract allows to fetch data from the Feature. Extract func(f *Feature) (T, error) }
DataDefinition defines how the data is created and fetched from the Feature's data context. S is a source type from which the data is created. T is a type of the data stored in the Feature.
type DataEntry ¶ added in v2.15.0
type DataEntry[T any] struct { Key string Value provider.DataProviderFunc[T] }
DataEntry associates data provider with a key under which the data is stored in the Feature.
type EnabledFunc ¶ added in v2.15.0
EnabledFunc is a func type used to determine if a feature should be enabled.
type Feature ¶
type Feature struct { Name string TargetNamespace string Enabled EnabledFunc Managed bool Log logr.Logger // contains filtered or unexported fields }
Feature is a high-level abstraction that represents a collection of resources and actions that are applied to the cluster to enable a specific feature.
Features can be either managed or unmanaged. Managed features are reconciled to their desired state based on defined manifests.
In addition to creating resources using manifest files or through Golang functions, a Feature allows defining preconditions and postconditions. These conditions are checked to ensure the cluster is in the desired state for the feature to be applied successfully.
When a Feature is applied, an associated resource called FeatureTracker is created. This resource establishes ownership for related resources, allowing for easy cleanup of all resources associated with the feature when it is about to be removed during reconciliation.
Each Feature can have a list of cleanup functions. These functions can be particularly useful when the cleanup involves actions other than the removal of resources, such as reverting a patch operation.
To create a Feature, use the provided FeatureBuilder. This builder guides through the process using a fluent API.
func (*Feature) Apply ¶
Apply applies the feature to the cluster. It creates a FeatureTracker resource to establish ownership and reports the result of the operation as a condition.
func (*Feature) AsOwnerReference ¶ added in v2.7.0
func (f *Feature) AsOwnerReference() metav1.OwnerReference
AsOwnerReference returns an OwnerReference for the FeatureTracker resource.
type FeaturesHandler ¶ added in v2.7.0
type FeaturesHandler struct {
// contains filtered or unexported fields
}
FeaturesHandler provides a structured way to manage and coordinate the creation, application, and deletion of features needed in particular Data Science Cluster configuration.
func ClusterFeaturesHandler ¶ added in v2.7.0
func ClusterFeaturesHandler(dsci *dsciv1.DSCInitialization, def ...FeaturesProvider) *FeaturesHandler
func ComponentFeaturesHandler ¶ added in v2.7.0
func ComponentFeaturesHandler(owner metav1.Object, componentName, targetNamespace string, def ...FeaturesProvider) *FeaturesHandler
func (*FeaturesHandler) Add ¶ added in v2.15.0
func (fh *FeaturesHandler) Add(builders ...*featureBuilder) error
Add loads features defined by passed builders and adds to internal list which is then used to Apply on the cluster. It also makes sure that both TargetNamespace and Source are added to the feature before it's `Create()`ed.
type FeaturesProvider ¶ added in v2.7.0
type FeaturesProvider func(registry FeaturesRegistry) error
FeaturesProvider is a function which allow to define list of features and add them to the handler's registry.
type FeaturesRegistry ¶ added in v2.15.0
type FeaturesRegistry interface {
Add(builders ...*featureBuilder) error
}
type HandlerWithReporter ¶ added in v2.10.1
HandlerWithReporter is a wrapper around FeaturesHandler and status.Reporter It is intended apply features related to a given resource capabilities and report its status using custom reporter.
func NewHandlerWithReporter ¶ added in v2.10.1
func NewHandlerWithReporter[T client.Object](handler *FeaturesHandler, reporter *status.Reporter[T]) *HandlerWithReporter[T]
type MissingOperatorError ¶ added in v2.10.1
type MissingOperatorError struct {
// contains filtered or unexported fields
}
func NewMissingOperatorError ¶ added in v2.10.1
func NewMissingOperatorError(operatorName string, err error) *MissingOperatorError
func (*MissingOperatorError) Error ¶ added in v2.10.1
func (e *MissingOperatorError) Error() string
func (*MissingOperatorError) Unwrap ¶ added in v2.10.1
func (e *MissingOperatorError) Unwrap() error