config

package
v1.109.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 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. Unlike FindChainloopYML, this does not require projectName to be set.

func LoadProjectFromYML

func LoadProjectFromYML(dir string) string

LoadProjectFromYML looks for a .chainloop.yml (or .chainloop.yaml) file starting from dir and walking up to the git repository root. Returns the projectName if found, or empty string if not found.

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). Unlike FindChainloopYML, this does not require projectName to be set.

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. Unlike FindChainloopYML, this does not require projectName to be set.

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

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.

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 ChainloopYML

type ChainloopYML struct {
	ProjectName    string `yaml:"projectName"`
	ProjectVersion string `yaml:"projectVersion"`
	// Organization, when set, forces trace attestations (init, add, push)
	// to target that organization instead of the CLI's default.
	Organization string `yaml:"organization,omitempty"`
	// RequireTrace controls whether the pre-push hook blocks the push
	// on attestation failure. nil is treated as false (default-off).
	RequireTrace *bool `yaml:"requireTrace,omitempty"`
	// WorkflowName, when set, overrides the default trace workflow name
	// used when initializing attestations from trace hooks.
	WorkflowName string `yaml:"workflowName,omitempty"`
}

ChainloopYML represents the relevant fields in .chainloop.yml.

func FindChainloopYML

func FindChainloopYML(dir string) *ChainloopYML

FindChainloopYML looks for a .chainloop.yml (or .chainloop.yaml) file starting from dir and walking up to the git repository root. Returns the parsed config if found (with a non-empty projectName), or nil.

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