credentials

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 2 Imported by: 0

Documentation

Overview

Package credentials provides centralized registry credential resolution. It defines one contract, implemented once, used by all callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolved

type Resolved struct {
	User      string
	Secret    string
	Kind      SecretKind
	SecretEnv string // e.g. "HARBOR_TOKEN" — the env var that provided the secret
}

Resolved holds the result of resolving a credential prefix. User and Secret may be empty if the env vars were not set.

func ResolvePrefix

func ResolvePrefix(prefix string) Resolved

ResolvePrefix resolves registry credentials from environment variables using the given prefix (e.g. "HARBOR", "DOCKER", "GHCR_ORG").

Resolution order for the secret:

{PREFIX}_TOKEN    → SecretToken    (preferred: scoped, revocable)
{PREFIX}_PASS     → SecretPassword (accepted)
{PREFIX}_PASSWORD → SecretPassword (accepted)

Username is always read from {PREFIX}_USER. Returns a zero Resolved if prefix is empty.

func (Resolved) IsSet

func (r Resolved) IsSet() bool

IsSet returns true if both User and Secret are non-empty.

type SecretKind

type SecretKind string

SecretKind classifies how a secret was issued. It is inferred from the env var suffix — a policy hint, not deep truth. The registry sees only a secret string; the distinction is naming/issuance-side.

const (
	// SecretToken indicates the secret was named with a _TOKEN suffix.
	// Tokens are typically scoped to specific projects/actions and revocable
	// without affecting the account password or other tokens.
	SecretToken SecretKind = "token"

	// SecretPassword indicates the secret was named with a _PASS or _PASSWORD suffix.
	// Passwords authenticate the account directly and are typically broader in scope.
	SecretPassword SecretKind = "password"
)

Jump to

Keyboard shortcuts

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