Expand description
Kopia identity resolution (ADR §4.2).
Kopia records every snapshot under username@hostname:sourcePath. Kopiur makes
that identity an explicit, overridable part of the API rather than an accident
of metadata.name/metadata.namespace (ADR §2.2 principle 9). This module is
the single place the defaulting + templating rules live; the webhook calls it at
admission and pins the result into status.resolved.identity, which is never
re-rendered afterwards (ADR §4.2).
§Defaults (ADR §4.2)
username←BackupConfig.metadata.namehostname← namespacesourcePath←/pvc/<pvcName>
§ClusterRepository identity templates
A crate::cluster_repository::IdentityTemplate supplies
hostnameTemplate/usernameTemplate, rendered with tera (Jinja2-compatible).
A consumer’s explicit Identity override always wins over the template.
§Template syntax decision
The ADR example is written Go-template-style with a leading dot
(hostnameTemplate: "{{ .Namespace }}"), but tera uses {{ Namespace }}.
Rather than force users to learn that kopiur templates are tera, we
preprocess the leading dot away: {{ .Foo }} → {{ Foo }} (see
strip_leading_dots). Both spellings therefore work, and the exact ADR
example renders correctly (proven in tests). Context variables exposed:
Namespace and ConfigName.
Structs§
- Identity
Inputs - Inputs to identity resolution. Grouped into a struct so call sites are readable and future inputs (e.g. extra template vars) slot in without churning the signature.
Functions§
- identity_
string - Format a kopia identity string. With a source path:
username@hostname:path; without one:username@hostname(kopia’s identity-only form, used for catalog queries that aren’t pinned to a path). - resolve_
identity - Resolve a
ResolvedIdentityfrom defaults, an optionalClusterRepositoryidentity template, and explicit consumer overrides (ADR §4.2).