Skip to main content

Module duration

Module duration 

Source
Expand description

Go-style duration strings used across the CRDs (30m, 1h, 90s).

Lives in kopiur-api (not the controller) so the admission validators and the reconcilers parse the exact same grammar — a value the webhook admits must never fail to parse at reconcile time.

Functions§

parse_go_duration
Parse a Go-style duration string used in the CRDs (30m, 1h, 90s, or a bare number of seconds). Returns None for unparseable input.
render_go_duration
Render a Duration back to a Go-style duration string, using the largest unit that divides it exactly (21600s"6h", 1200s"20m", else "{n}s").
resolve_timeout
Resolve an optional policy timeout string to an effective deadline duration, with the semantics every *.timeout field shares (spec.preflight.timeout, spec.staging.timeout): absent ⇒ default; parsed-zero (0/0s) ⇒ None (indefinite — never expires); unparseable ⇒ default (defensive only — the webhook rejects unparseable values at admission).