setup

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IndexSentinelNoDescription is used when an EngramTemplate has no description,
	// allowing explicit queries for templates without descriptions.
	IndexSentinelNoDescription = "no-description"

	// IndexSentinelNoVersion is used when an EngramTemplate has no version set.
	IndexSentinelNoVersion = "no-version"

	// StepRunPhaseField is the cache index key for StepRun status.phase lookups.
	StepRunPhaseField = "status.phase"
)

Index sentinel values for special cases.

Variables

View Source
var (
	IndexEngramTemplateRef = IndexRegistration{
		Object:    &bubushv1alpha1.Engram{},
		Field:     contracts.IndexEngramTemplateRef,
		Extractor: extractEngramTemplateName,
		ErrMsg:    "failed to index Engram " + contracts.IndexEngramTemplateRef,
	}
	IndexStepRunEngramRef = IndexRegistration{
		Object:    &runsv1alpha1.StepRun{},
		Field:     contracts.IndexStepRunEngramRef,
		Extractor: extractStepRunEngramRef,
		ErrMsg:    "failed to index StepRun " + contracts.IndexStepRunEngramRef,
	}
	IndexStepRunStoryRunRef = IndexRegistration{
		Object:    &runsv1alpha1.StepRun{},
		Field:     contracts.IndexStepRunStoryRunRef,
		Extractor: extractStepRunStoryRunRef,
		ErrMsg:    "failed to index StepRun " + contracts.IndexStepRunStoryRunRef,
	}
	IndexStepRunPhase = IndexRegistration{
		Object:    &runsv1alpha1.StepRun{},
		Field:     StepRunPhaseField,
		Extractor: extractStepRunPhase,
		ErrMsg:    "failed to index StepRun " + StepRunPhaseField,
	}
	IndexStoryRunImpulseRef = IndexRegistration{
		Object:    &runsv1alpha1.StoryRun{},
		Field:     contracts.IndexStoryRunImpulseRef,
		Extractor: extractStoryRunImpulseRef,
		ErrMsg:    "failed to index StoryRun " + contracts.IndexStoryRunImpulseRef,
	}
	IndexStoryRunStoryRefName = IndexRegistration{
		Object:    &runsv1alpha1.StoryRun{},
		Field:     contracts.IndexStoryRunStoryRefName,
		Extractor: extractStoryRunStoryRefName,
		ErrMsg:    "failed to index StoryRun " + contracts.IndexStoryRunStoryRefName,
	}
	IndexStoryRunStoryRefKey = IndexRegistration{
		Object:    &runsv1alpha1.StoryRun{},
		Field:     contracts.IndexStoryRunStoryRefKey,
		Extractor: extractStoryRunStoryRefKey,
		ErrMsg:    "failed to index StoryRun " + contracts.IndexStoryRunStoryRefKey,
	}
	IndexImpulseTemplateRef = IndexRegistration{
		Object:    &bubushv1alpha1.Impulse{},
		Field:     contracts.IndexImpulseTemplateRef,
		Extractor: extractImpulseTemplateName,
		ErrMsg:    "failed to index Impulse " + contracts.IndexImpulseTemplateRef,
	}
	IndexImpulseStoryRef = IndexRegistration{
		Object:    &bubushv1alpha1.Impulse{},
		Field:     contracts.IndexImpulseStoryRef,
		Extractor: extractImpulseStoryRefName,
		ErrMsg:    "failed to index Impulse " + contracts.IndexImpulseStoryRef,
	}
	IndexStoryStepEngramRefs = IndexRegistration{
		Object:    &bubushv1alpha1.Story{},
		Field:     contracts.IndexStoryStepEngramRefs,
		Extractor: extractStoryStepEngramRefs,
		ErrMsg:    "failed to index Story " + contracts.IndexStoryStepEngramRefs,
	}
	IndexStoryStepStoryRefs = IndexRegistration{
		Object:    &bubushv1alpha1.Story{},
		Field:     contracts.IndexStoryStepStoryRefs,
		Extractor: extractStoryExecuteStoryRefs,
		ErrMsg:    "failed to index Story " + contracts.IndexStoryStepStoryRefs,
	}
	IndexStoryTransportRefs = IndexRegistration{
		Object:    &bubushv1alpha1.Story{},
		Field:     contracts.IndexStoryTransportRefs,
		Extractor: extractStoryTransportRefs,
		ErrMsg:    "failed to index Story " + contracts.IndexStoryTransportRefs,
	}
	IndexTransportBindingTransportRef = IndexRegistration{
		Object:    &transportv1alpha1.TransportBinding{},
		Field:     contracts.IndexTransportBindingTransportRef,
		Extractor: extractTransportBindingTransportRef,
		ErrMsg:    "failed to index TransportBinding " + contracts.IndexTransportBindingTransportRef,
	}
	IndexEngramTemplateDescription = IndexRegistration{
		Object:    &catalogv1alpha1.EngramTemplate{},
		Field:     contracts.IndexEngramTemplateDescription,
		Extractor: extractEngramTemplateDescription,
		ErrMsg:    "failed to index EngramTemplate " + contracts.IndexEngramTemplateDescription,
	}
	IndexEngramTemplateVersion = IndexRegistration{
		Object:    &catalogv1alpha1.EngramTemplate{},
		Field:     contracts.IndexEngramTemplateVersion,
		Extractor: extractEngramTemplateVersion,
		ErrMsg:    "failed to index EngramTemplate " + contracts.IndexEngramTemplateVersion,
	}
)

Functions

func EnsureIndexes added in v0.1.4

func EnsureIndexes(ctx context.Context, mgr manager.Manager, regs []IndexRegistration) error

EnsureIndexes registers each requested field index once per manager process.

func IsIndexRegistered added in v0.1.4

func IsIndexRegistered(obj client.Object, field string) bool

IsIndexRegistered checks if a field index was registered at startup.

Behavior:

  • Returns true if the index was registered via EnsureIndexes.
  • Can be used by controllers to verify index availability before relying on indexed lookups.

Arguments:

  • obj client.Object: the object type the index applies to.
  • field string: the field path for the index.

Returns:

  • bool: true if registered, false otherwise.

func LogRegisteredIndexes added in v0.1.4

func LogRegisteredIndexes()

LogRegisteredIndexes emits a summary log of indexes that were actually registered in the current process. Only entries present in the registeredIndexes sync.Map (i.e. those that completed without error) are reported, so the log accurately reflects the live index state rather than the declared registration list.

Side Effects:

  • Writes a log entry to the setup logger.

func RequiredControllerIndexes added in v0.1.4

func RequiredControllerIndexes() map[string][]string

RequiredControllerIndexes returns a map of controller names to their required indexes. This can be used for runtime verification or documentation.

func SetupIndexers

func SetupIndexers(ctx context.Context, mgr manager.Manager) error

SetupIndexers sets up the field indexers for all the controllers. The provided context must be tied to the manager lifecycle to ensure proper cancellation on shutdown.

Types

type IndexRegistration added in v0.1.4

type IndexRegistration struct {
	Object    client.Object
	Field     string
	Extractor func(client.Object) []string
	ErrMsg    string
}

IndexRegistration describes a single field index requirement.

Jump to

Keyboard shortcuts

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