Documentation
¶
Index ¶
- Constants
- func ChainloopYMLName(dir string) string
- func IsLocalStorage(dir string) bool
- func LoadOrganizationFromYML(dir string) string
- func LoadRequireTraceFromYML(dir string) bool
- func LoadTraceRequiredFromYML(dir string) bool
- func LoadTraceStorageFromYML(dir string) (string, error)
- func LoadWorkflowFromYML(dir string) string
- func ResolveContract(flag string) (name string, required bool)
- func ResolveTraceStorage(persisted string) (string, error)
- func ResolveWorkflowName(persisted string) string
- func SaveOrganizationToYML(dir, org string) error
- func SaveProjectToYML(dir, project string) error
- func SaveRequireTraceToYML(dir string, val bool) errordeprecated
- func SaveTracePathToYML(dir, path string) error
- func SaveTraceRequiredToYML(dir string, val bool) error
- func SaveTraceStorageToYML(dir, mode string) error
- func SaveWorkflowToYML(dir, workflow string) error
- func SlugifyDNS1123(name string) string
- func ValidateDNS1123Label(subject Subject, name string) error
- type Subject
Constants ¶
const ( // TraceStorageControlPlane uploads a signed attestation to the control // plane. It is the mode when traceStorage is unset. TraceStorageControlPlane = "CONTROL_PLANE" // TraceStorageLocal writes the session evidence set to disk, with no // control plane. TraceStorageLocal = "LOCAL" )
Variables ¶
This section is empty.
Functions ¶
func ChainloopYMLName ¶ added in v1.109.0
ChainloopYMLName returns the base name of the Chainloop config file in dir: whichever of the two spellings is already there, or .chainloop.yml when neither is. Callers use it to name the file, for instance when asking the user to commit it.
func IsLocalStorage ¶ added in v1.124.0
IsLocalStorage reports whether the repository is configured for LOCAL trace storage. It is best-effort: a missing config, or an invalid value, is treated as not-local, so a caller that only shapes local-mode behavior (a banner, a self-heal) falls back to the control-plane path. The pre-push hook calls LoadTraceStorageFromYML directly instead, so an invalid value blocks the push rather than being ignored.
func LoadOrganizationFromYML ¶
LoadOrganizationFromYML looks for .chainloop.yml starting from dir and returns the organization value. Returns empty string when the field is absent.
func LoadRequireTraceFromYML ¶
LoadRequireTraceFromYML looks for .chainloop.yml starting from dir and returns the requireTrace value. Returns false when the field is absent or nil (default-off).
func LoadTraceRequiredFromYML ¶ added in v1.124.0
LoadTraceRequiredFromYML reports whether a required trace must block a push. It prefers traceRequired and falls back to the deprecated requireTrace, so an older .chainloop.yml keeps working. Absent in both is false (default-off).
func LoadTraceStorageFromYML ¶ added in v1.124.0
LoadTraceStorageFromYML reads and canonicalizes the traceStorage mode from the nearest .chainloop.yml. A missing config or field is CONTROL_PLANE, but a config that exists and cannot be read or parsed is an error, never a silent CONTROL_PLANE. A LOCAL repository whose config broke must not have its pre-push hook fall back to the control plane and upload a local-only session.
func LoadWorkflowFromYML ¶
LoadWorkflowFromYML looks for .chainloop.yml starting from dir and returns the workflowName value. Returns empty string when the field is absent.
func ResolveContract ¶ added in v1.108.6
ResolveContract returns the contract to attach when the trace workflow is created: the one given on the command line, or the trace default. required reports that the name came from the user, where a missing contract is an error instead of something to fall back from, because a typo must not silently bind another contract.
Unlike the workflow name, the contract is not persisted to .chainloop.yml: it is only needed when the workflow is created, never on the push path.
func ResolveTraceStorage ¶ added in v1.124.0
ResolveTraceStorage canonicalizes a traceStorage value: surrounding space is trimmed and the name upper-cased, an empty value is CONTROL_PLANE, and any value other than the two known modes is an error, so a committed typo surfaces instead of silently falling back to the control plane (and pushing to a backend a LOCAL repository means to avoid).
func ResolveWorkflowName ¶
ResolveWorkflowName returns the persisted workflow name when non-empty, otherwise falls back to the trace default. Centralizes the default so the CLI command and the hook handler stay in sync.
func SaveOrganizationToYML ¶
SaveOrganizationToYML writes (or updates) the organization field in .chainloop.yml at the given directory, preserving any other fields.
func SaveProjectToYML ¶
SaveProjectToYML writes (or updates) the projectName field in .chainloop.yml (or .chainloop.yaml) at the given directory, preserving any other fields.
func SaveRequireTraceToYML
deprecated
SaveRequireTraceToYML writes (or updates) the requireTrace field in .chainloop.yml at the given directory, preserving any other fields.
Deprecated: write traceRequired with SaveTraceRequiredToYML. This remains for the legacy path until requireTrace is dropped.
func SaveTracePathToYML ¶ added in v1.124.0
SaveTracePathToYML writes (or updates) the tracePath field in .chainloop.yml at the given directory, preserving any other fields.
func SaveTraceRequiredToYML ¶ added in v1.124.0
SaveTraceRequiredToYML writes (or updates) the traceRequired field in .chainloop.yml at the given directory, preserving any other fields.
func SaveTraceStorageToYML ¶ added in v1.124.0
SaveTraceStorageToYML writes (or updates) the traceStorage field in .chainloop.yml at the given directory, preserving any other fields.
func SaveWorkflowToYML ¶
SaveWorkflowToYML writes (or updates) the workflowName field in .chainloop.yml at the given directory, preserving any other fields.
func SlugifyDNS1123 ¶ added in v1.109.0
SlugifyDNS1123 turns a free-form project name into a DNS-1123 label, the form the control plane accepts. It lowercases, replaces every run of characters that are not lowercase alphanumerics with a single dash, and trims the dashes off both ends. Names longer than the limit are cut, and cutting never leaves a trailing dash behind.
It returns an empty string for input that has nothing usable in it, e.g. "!!!". Callers are expected to reject that rather than pass it on; ValidateDNS1123Label produces the message for it.
materials.SanitizeMaterialName does the same to material names, and the two agree on everything but the length cap, which it leaves to its own caller. They are kept apart on purpose: importing it here would put the whole material crafter, some 377 packages, behind this one.
func ValidateDNS1123Label ¶ added in v1.109.0
ValidateDNS1123Label reports whether name is one the control plane will accept for a subject of that kind, using the same rule the server applies at creation time so a bad name is caught at the prompt rather than by a failing API call.
Types ¶
type Subject ¶ added in v1.109.0
type Subject string
Subject is the kind of thing ValidateDNS1123Label names in what it reports. Projects and organizations are named by the same rule, so the caller says which one it is asking about and the message names it. It is a type of its own so it cannot be swapped with the name being validated.