config

package
v1.124.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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

func ChainloopYMLName(dir string) string

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

func IsLocalStorage(dir string) bool

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

func LoadOrganizationFromYML(dir string) string

LoadOrganizationFromYML looks for .chainloop.yml starting from dir and returns the organization value. Returns empty string when the field is absent.

func LoadRequireTraceFromYML

func LoadRequireTraceFromYML(dir string) bool

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

func LoadTraceRequiredFromYML(dir string) bool

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

func LoadTraceStorageFromYML(dir string) (string, error)

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

func LoadWorkflowFromYML(dir string) string

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

func ResolveContract(flag string) (name string, required bool)

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

func ResolveTraceStorage(persisted string) (string, error)

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

func ResolveWorkflowName(persisted string) string

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

func SaveOrganizationToYML(dir, org string) error

SaveOrganizationToYML writes (or updates) the organization field in .chainloop.yml at the given directory, preserving any other fields.

func SaveProjectToYML

func SaveProjectToYML(dir, project string) error

SaveProjectToYML writes (or updates) the projectName field in .chainloop.yml (or .chainloop.yaml) at the given directory, preserving any other fields.

func SaveRequireTraceToYML deprecated

func SaveRequireTraceToYML(dir string, val bool) error

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

func SaveTracePathToYML(dir, path string) error

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

func SaveTraceRequiredToYML(dir string, val bool) error

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

func SaveTraceStorageToYML(dir, mode string) error

SaveTraceStorageToYML writes (or updates) the traceStorage field in .chainloop.yml at the given directory, preserving any other fields.

func SaveWorkflowToYML

func SaveWorkflowToYML(dir, workflow string) error

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

func SlugifyDNS1123(name string) string

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

func ValidateDNS1123Label(subject Subject, name string) error

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.

const (
	ProjectSubject      Subject = "project"
	OrganizationSubject Subject = "organization"
)

Jump to

Keyboard shortcuts

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