configsource

package
v0.53.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configsource builds the factory's live config from its file and its Factory, Repository and MergePolicy objects, and publishes it to a config.Live (factory resources D5, D13, D14).

The contract:

  • Sync lists the three kinds in one namespace through an uncached reader, so it works before any cache starts, hands them to resources.Assemble with the file, and publishes the result. Each replica runs its own Source: it needs no leader election (D13).
  • A refused object does not take its repository down: the last version of it that was served is put back and the set assembled again (D5). Its Outcome says it is not accepted and which generation is still served.
  • An error is returned only when nothing can be served and nothing is published yet (startup, D14). Afterwards the current config is kept and the refusals are in Outcomes.
  • With no CRDs installed the objects are none: the factory runs from the file alone, and says so once.
  • Outcomes are what the status writer reports; the Source never writes to the cluster. OnSynced tells it a Sync completed: it runs with no lock held, so it may call Outcomes. A config.Live subscriber must never call Outcomes: Publish runs under the Source's lock.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotServable = errors.New("no config can be served")

ErrNotServable is the first Sync's error when nothing can be served: Assemble refused the file with the resources listed. The factory waits on it for its resources (D14).

Functions

func Kinds

func Kinds() []client.Object

Kinds are the three kinds the config is built from, in the order Sync lists them.

Types

type Outcome

type Outcome struct {
	Kind resources.Kind
	Name string
	// Repository is the owner/name a Repository configures, its spec.repository; empty for the
	// other kinds (a MergePolicy's consumers are in Consumers).
	Repository         string
	ObservedGeneration int64  // the object's current generation
	ServedGeneration   int64  // the generation in the published config; 0 when not served
	Accepted           bool   // the current generation is served
	Reason, Message    string // why not, when !Accepted (a v1alpha1.Reason*)
	// Bindings are a bound Repository's bindings, in list order (B9, B10).
	Bindings []resources.BindingOutcome
	// Consumers are the bindings of a MergePolicy, by Repository (B10).
	Consumers []resources.BindingOutcome
}

Outcome is what the factory made of one object, for the status writer.

type Source

type Source struct {
	Reader    client.Reader // uncached (mgr.GetAPIReader() or a plain client): works before the cache starts
	Namespace string
	File      []byte
	// Live is nil until the first successful Sync, which creates it. That first Sync must complete
	// before Live is shared: the field itself is not synchronized, only what Live serves.
	Live   *config.Live
	Log    *slog.Logger
	Resync time.Duration // 5m when zero
	// OnSynced, optional, runs after each Sync completes, with no lock held: it may call Outcomes.
	OnSynced func()
	Now      func() time.Time // time.Now when nil
	// contains filtered or unexported fields
}

Source builds the factory's config from its file and its resources.

func (*Source) CRDsAbsent added in v0.41.2

func (s *Source) CRDsAbsent() bool

CRDsAbsent reports whether the last Sync found the factory CRDs not installed.

func (*Source) Kick

func (s *Source) Kick()

Kick asks for a Sync soon (non-blocking; coalesced).

func (*Source) NeedLeaderElection

func (s *Source) NeedLeaderElection() bool

NeedLeaderElection is false: every replica serves from its own config (D13).

func (*Source) Outcomes

func (s *Source) Outcomes() ([]Outcome, Synced)

Outcomes returns a copy of the last Sync's outcomes, sorted by Kind then Name, and when that Sync completed with its error. It takes the Source's lock: never call it from a config.Live subscriber, which runs under that lock (Publish is called inside Sync).

func (*Source) Start

func (s *Source) Start(ctx context.Context) error

Start runs Sync on every Kick and every Resync until ctx ends. A Sync error is logged.

func (*Source) Sync

func (s *Source) Sync(ctx context.Context) error

Sync lists, assembles and publishes once. It returns an error only when no config can be served and none is published yet (startup, D14). OnSynced runs once it has completed.

func (*Source) Watch

func (s *Source) Watch(ctx context.Context, c cache.Cache, kinds []client.Object) error

Watch registers handlers that Kick on kinds, a subset of Kinds: the ones the cache was told about (a ByObject entry), so it never starts an informer the manager did not configure. A kind with no CRD is skipped.

type Synced

type Synced struct {
	At  time.Time
	Err error
}

Synced is the last Sync's completion: when, and its error (nil on success). The error is a list error, or Assemble's when nothing new could be served (the current config is then kept).

Jump to

Keyboard shortcuts

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