{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.138.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package config\n\n## Constants\n\n```go\nconst (\n\t// TraceStorageControlPlane uploads a signed attestation to the control\n\t// plane. It is the mode when traceStorage is unset.\n\tTraceStorageControlPlane = \"CONTROL_PLANE\"\n\t// TraceStorageLocal writes the session evidence set to disk, with no\n\t// control plane.\n\tTraceStorageLocal = \"LOCAL\"\n)\n```\n\n## Functions\n\n```go\nfunc ChainloopYMLName(dir string) string\n```\nChainloopYMLName 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.\n\n```go\nfunc IsLocalStorage(dir string) bool\n```\nIsLocalStorage 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.\n\n```go\nfunc LoadOrganizationFromYML(dir string) string\n```\nLoadOrganizationFromYML looks for .chainloop.yml starting from dir and returns the organization value. Returns empty string when the field is absent.\n\n```go\nfunc LoadRequireTraceFromYML(dir string) bool\n```\nLoadRequireTraceFromYML looks for .chainloop.yml starting from dir and returns the requireTrace value. Returns false when the field is absent or nil (default-off).\n\n```go\nfunc LoadTraceRequiredFromYML(dir string) bool\n```\nLoadTraceRequiredFromYML 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).\n\n```go\nfunc LoadTraceStorageFromYML(dir string) (string, error)\n```\nLoadTraceStorageFromYML 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.\n\n```go\nfunc LoadWorkflowFromYML(dir string) string\n```\nLoadWorkflowFromYML looks for .chainloop.yml starting from dir and returns the workflowName value. Returns empty string when the field is absent.\n\n```go\nfunc ResolveContract(flag string) (name string, required bool)\n```\nResolveContract 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.\n\nUnlike 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.\n\n```go\nfunc ResolveTraceStorage(persisted string) (string, error)\n```\nResolveTraceStorage 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).\n\n```go\nfunc ResolveWorkflowName(persisted string) string\n```\nResolveWorkflowName 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.\n\n```go\nfunc SaveOrganizationToYML(dir, org string) error\n```\nSaveOrganizationToYML writes (or updates) the organization field in .chainloop.yml at the given directory, preserving any other fields.\n\n```go\nfunc SaveProjectToYML(dir, project string) error\n```\nSaveProjectToYML writes (or updates) the projectName field in .chainloop.yml (or .chainloop.yaml) at the given directory, preserving any other fields.\n\n```go\nfunc SaveRequireTraceToYML(dir string, val bool) error\n```\nSaveRequireTraceToYML writes (or updates) the requireTrace field in .chainloop.yml at the given directory, preserving any other fields.\n\nDeprecated: write traceRequired with SaveTraceRequiredToYML. This remains for the legacy path until requireTrace is dropped.\n\n```go\nfunc SaveTracePathToYML(dir, path string) error\n```\nSaveTracePathToYML writes (or updates) the tracePath field in .chainloop.yml at the given directory, preserving any other fields.\n\n```go\nfunc SaveTraceRequiredToYML(dir string, val bool) error\n```\nSaveTraceRequiredToYML writes (or updates) the traceRequired field in .chainloop.yml at the given directory, preserving any other fields.\n\n```go\nfunc SaveTraceStorageToYML(dir, mode string) error\n```\nSaveTraceStorageToYML writes (or updates) the traceStorage field in .chainloop.yml at the given directory, preserving any other fields.\n\n```go\nfunc SaveWorkflowToYML(dir, workflow string) error\n```\nSaveWorkflowToYML writes (or updates) the workflowName field in .chainloop.yml at the given directory, preserving any other fields.\n\n```go\nfunc SlugifyDNS1123(name string) string\n```\nSlugifyDNS1123 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.\n\nIt 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.\n\nmaterials.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.\n\n```go\nfunc ValidateDNS1123Label(subject Subject, name string) error\n```\nValidateDNS1123Label 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.\n\n## Types\n\n```go\ntype Subject string\n```\nSubject 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.\n\n```go\nconst (\n\tProjectSubject      Subject = \"project\"\n\tOrganizationSubject Subject = \"organization\"\n)\n```\n\n","path":"github.com/chainloop-dev/chainloop/app/cli/internal/trace/config","name":"config","synopsis":"","isRedistributable":true}
