controller

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHookFailed indicates a hook executed and failed.
	ErrHookFailed = errors.New("hook failed")
	// ErrHookInProgress indicates a hook is currently running.
	ErrHookInProgress = errors.New("hook in progress")
)

Functions

This section is empty.

Types

type AgentTaskReconciler added in v0.14.0

type AgentTaskReconciler struct {
	client.Client
	Clientset       kubernetes.Interface
	Scheme          *runtime.Scheme
	SandboxRegistry *registry.Registry[pkgsandbox.SandboxProvider]
	TokenMinter     auth.Minter
	TokenStore      auth.TokenStore
	TokenAuditor    auth.TokenAuditor
	Notifier        TaskNotifier
	LifecycleHook   SandboxLifecycleHook
	FeatureGate     FeatureGate
	DefaultProvider string
}

AgentTaskReconciler reconciles an AgentTask object.

func (*AgentTaskReconciler) Reconcile added in v0.14.0

func (r *AgentTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile manages the AgentTask lifecycle.

func (*AgentTaskReconciler) SetupWithManager added in v0.14.0

func (r *AgentTaskReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type DirectSetupRunner added in v0.11.0

type DirectSetupRunner struct {
	// Executor is an optional SQLExecutor (e.g. *sql.DB). If nil, RunSetupSQL connects using adminDSN.
	Executor SQLExecutor
}

DirectSetupRunner executes setup SQL in-process if it was not already handled by the database provider. This is the default runner for Diverge.

func (*DirectSetupRunner) RunSetupSQL added in v0.11.0

func (r *DirectSetupRunner) RunSetupSQL(ctx context.Context, env *divergeiov1alpha1.Environment, setupSQL, adminDSN string) error

RunSetupSQL executes setup SQL in-process against the admin DSN or using the configured executor.

type EnvironmentReconciler

type EnvironmentReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         *events.Recorder
	Router           routing.Router
	DatabaseProvider database.DatabaseProvider
	ChangeDetector   changeset.ChangeDetector
	Notifier         notifier.Notifier
	StatusReporter   notifier.StatusReporter
	Deployer         deployer.Deployer
	TestRunner       divtesting.TestRunner
	AsyncProvisioner async.Provisioner
	FeatureProvider  features.FeatureProvider
	SetupJobImage    string
	SetupRunner      SetupRunner
}

EnvironmentReconciler reconciles a Environment object

func (*EnvironmentReconciler) Reconcile

func (r *EnvironmentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error)

Reconcile performs its designated operation.

func (*EnvironmentReconciler) SetupWithManager

func (r *EnvironmentReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type FeatureGate added in v0.14.0

type FeatureGate interface {
	IsEnabled(ctx context.Context, feature string) bool
}

FeatureGate provides dynamic feature enablement queries.

type HookJobConfig added in v0.7.0

type HookJobConfig struct {
	JobName      string
	Namespace    string
	Image        string
	Args         []string
	EnvVars      []corev1.EnvVar
	EnvFrom      []corev1.EnvFromSource
	Volumes      []corev1.Volume
	VolumeMounts []corev1.VolumeMount
	Timeout      int32
	Owner        metav1.Object
	Labels       map[string]string
}

HookJobConfig holds the parameters for creating a hook Job.

type JobSetupRunner added in v0.11.0

type JobSetupRunner struct {
	Reconciler *EnvironmentReconciler
}

JobSetupRunner executes setup SQL via a Kubernetes Job for isolated environments. Deprecated: In-process database setup via SQLExecutor is preferred for performance, reliability, and security.

func (*JobSetupRunner) RunSetupSQL added in v0.11.0

func (r *JobSetupRunner) RunSetupSQL(ctx context.Context, env *divergeiov1alpha1.Environment, setupSQL, adminDSN string) error

RunSetupSQL delegates execution to the reconciler's runSetupSQLJob method.

type NoopTaskNotifier added in v0.14.0

type NoopTaskNotifier struct{}

NoopTaskNotifier is a default no-op implementation of TaskNotifier.

func (*NoopTaskNotifier) NotifyPhaseChange added in v0.14.0

func (n *NoopTaskNotifier) NotifyPhaseChange(_ context.Context, _ *v1alpha1.AgentTask, _, _ v1alpha1.AgentTaskPhase) error

NotifyPhaseChange does nothing.

type PreviewGroupReconciler

type PreviewGroupReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         *events.Recorder
	Notifier         notifier.PreviewGroupNotifier
	StatusReporter   notifier.StatusReporter
	DatabaseProvider database.DatabaseProvider
	EnableGAMMA      bool // Enable GAMMA mesh routing (requires Istio Ambient)
}

PreviewGroupReconciler reconciles a PreviewGroup object. It acts as an "operator of operators", creating and managing child Environment CRs for each service in the group.

func (*PreviewGroupReconciler) Reconcile

func (r *PreviewGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error)

Reconcile performs its designated operation.

func (*PreviewGroupReconciler) SetupWithManager

func (r *PreviewGroupReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type SQLExecutor added in v0.11.0

type SQLExecutor interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

SQLExecutor defines the contract for executing SQL queries.

type SandboxLifecycleHook added in v0.14.0

type SandboxLifecycleHook interface {
	PreProvision(ctx context.Context, task *v1alpha1.AgentTask) error
	PostProvision(ctx context.Context, task *v1alpha1.AgentTask, res *pkgsandbox.SandboxResult) error
	PreTeardown(ctx context.Context, task *v1alpha1.AgentTask) error
}

SandboxLifecycleHook allows executing custom logic before/after provisioning and before teardown.

type SetupRunner added in v0.11.0

type SetupRunner interface {
	RunSetupSQL(ctx context.Context, env *divergeiov1alpha1.Environment, setupSQL, adminDSN string) error
}

SetupRunner executes initial DDL or schema setup for provisioned databases.

type StaticFeatureGate added in v0.14.0

type StaticFeatureGate struct {
	Enabled bool
}

StaticFeatureGate is a static implementation of FeatureGate.

func (*StaticFeatureGate) IsEnabled added in v0.14.0

func (g *StaticFeatureGate) IsEnabled(_ context.Context, _ string) bool

IsEnabled returns the configured static enablement state.

type TaskNotifier added in v0.14.0

type TaskNotifier interface {
	NotifyPhaseChange(ctx context.Context, task *v1alpha1.AgentTask, oldPhase, newPhase v1alpha1.AgentTaskPhase) error
}

TaskNotifier notifies external observers when an AgentTask changes phases.

Jump to

Keyboard shortcuts

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