providerns

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package providerns answers one question for every configuration validator in the framework: does this key belong to the private subtree of a REGISTERED provider, rather than to app.Config's schema?

It exists because that question was answered twice, differently. The builder path exempted `storage.<provider>.*` for a registered provider; app.LoadConfig — the path every CLI command takes — did not, so a Ceph deployment that booted fine had `nucleus check`, `doctor` and `config print` all reporting an unknown key against the file the server was running on. That is the "same file, two verdicts" class, and the fix is not to teach the second validator the same rule but to leave exactly one place where the rule lives.

The exemption is per REGISTERED name and never for the namespace: a misspelling under `storage.` or `auth.` is still an unknown key. A namespace-wide exemption would turn these into the one place in the configuration where any typo passes unseen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(k *koanf.Koanf, ns, name string) map[string]any

Capture cuts `<ns>.<name>.*` out of a merged koanf so it can be handed to the provider that owns it. The framework never interprets the contents; the provider binds them into its own typed struct.

koanf appears here and not in any exported signature on purpose: a third-party provider must not inherit a dependency on the framework's configuration decoder (ADR-015).

func CaptureAll

func CaptureAll(k *koanf.Koanf, ns string, names []string) map[string]map[string]any

CaptureAll captures the subtree of every name in names, skipping the ones that turn out to be empty.

func CaptureStorage

func CaptureStorage(k *koanf.Koanf, provider string) map[string]any

CaptureStorage captures a storage provider's subtree, skipping the built-ins.

The built-ins bind through their own typed fields (storage.s3.*, storage.local.*), so there is nothing to capture for them — and capturing anyway would hand a provider a subtree the schema already owns. The list lives here and not at either call site because both configuration paths need the same answer.

func IsProviderKey

func IsProviderKey(key string, d Declared) bool

IsProviderKey reports whether key sits under `<namespace>.<registered name>.` for one of the namespaces above.

A key with only two segments (`storage.ceph`) is NOT a provider key: the subtree is what a provider owns, and the bare name is either a schema field or a typo.

func Namespaces

func Namespaces() map[string][]string

Namespaces returns every config namespace that can hold a registered provider's own subtree, mapped to the names currently registered in it.

This is the single table both validators read. A registry whose providers can declare open-ended configuration belongs here; one whose factory takes a typed struct the framework owns (mail, the session store) does not, because there is no subtree to exempt.

func NamespacesWith

func NamespacesWith(d Declared) map[string][]string

NamespacesWith is Namespaces for a caller that has read the file and therefore knows which federated instances were declared.

func OrphanAuthSubtreeError

func OrphanAuthSubtreeError(orphans []string) error

OrphanAuthSubtreeError renders the orphans as the error both configuration paths return, so the same file cannot get two verdicts.

func OrphanAuthSubtrees

func OrphanAuthSubtrees(k *koanf.Koanf, chain []string) []string

OrphanAuthSubtrees returns the `auth.<name>.*` sections that belong to a registered backend which the chain does not name.

The unknown-key guard cannot see these: the name IS registered, so the section is legitimately exempt — and then nothing reads it, because the chain is its only consumer. An operator who configures a directory and forgets the `auth_backends` entry gets a clean boot, a green `check`, and a login page that never consults the directory. That is the "exit 0 without the effect" class, and it is worth an error rather than a warning: there is no reading of this configuration under which it does something.

Storage deliberately gets no equivalent. `storage.s3.*` while `storage.provider` is `local` is a stanza kept for another environment, and the schema has always allowed it; a third-party section is the same thing and must not be treated more harshly than the built-in one.

func StripKeys

func StripKeys(keys []string, d Declared) []string

StripKeys removes every registered provider's subtree from an unknown-key set.

Types

type Declared

type Declared struct {
	// FederatedAuth are the instance names declared in auth_federated.
	FederatedAuth []string
}

Declared carries the parts of the rule that come from the CONFIGURATION rather than from a registry.

A credential backend is exempted by its REGISTERED name, because the name an operator writes is the name the package registered. A federated identity provider is not: its registry is keyed by protocol ("oidc") while the subtree is keyed by the INSTANCE the operator named ("corp"), so the only place that knows "corp" is legitimate is the declaration in auth_federated. Passing it here rather than teaching each validator keeps the rule in one place, which is the entire reason this package exists — the exemption already lived in two validators once, and only one of them had it.

Jump to

Keyboard shortcuts

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