pkgregistry

package
v0.8.1 Latest Latest
Warning

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

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

Documentation

Overview

Package pkgregistry renders private package registry credentials into the tool config files a Dockerfile build reads through BuildKit secret mounts, so a token is never baked into an image layer or a build log.

Index

Constants

View Source
const (
	EcosystemNPM      = "npm"
	EcosystemPyPI     = "pypi"
	EcosystemMaven    = "maven"
	EcosystemNuGet    = "nuget"
	EcosystemCargo    = "cargo"
	EcosystemGo       = "go"
	EcosystemRubyGems = "rubygems"
)

Ecosystems a package registry credential can target.

View Source
const (
	ScopeInstance = "instance"
	ScopeProject  = "project"
	ScopeApp      = "app"
)

Scope kinds: how widely a package registry applies.

Variables

Ecosystems lists every supported ecosystem in display order.

View Source
var SecretIDs = map[string]string{
	EcosystemNPM:      "npmrc",
	EcosystemPyPI:     "pip_conf",
	EcosystemMaven:    "maven_settings",
	EcosystemNuGet:    "nuget_config",
	EcosystemCargo:    "cargo_config",
	EcosystemGo:       "netrc",
	EcosystemRubyGems: "bundle_config",
}

SecretIDs maps an ecosystem to the BuildKit secret id its generated config is mounted under, the id a Dockerfile references.

Functions

func IsEcosystem

func IsEcosystem(e string) bool

IsEcosystem reports whether e is a supported ecosystem.

func Redactor

func Redactor(redact []string) func(string) string

Redactor masks every value in redact (longest first) with ***.

func ValidateURL

func ValidateURL(raw string) error

ValidateURL requires an http or https URL with no embedded credentials, which would otherwise leak through build args and logs.

Types

type Entry

type Entry struct {
	Ecosystem string
	URL       string
	Username  string
	Secret    string
	// ModulePatterns is a comma separated GOPRIVATE list (go only).
	ModulePatterns string
}

Entry is one resolved package registry credential, secret included.

type Output

type Output struct {
	Files  map[string][]byte
	Args   map[string]string
	Redact []string
}

Output is what a build receives: secret file contents by mount id, non-secret build args, and every string that must be masked in logs.

func Render

func Render(entries []Entry) (Output, error)

Render produces the build inputs for entries. When several entries share an ecosystem the first wins, so callers order narrowest scope first.

type Resolver

type Resolver struct {
	Store   Source
	Secrets SecretResolver
}

Resolver turns the registries in scope for one service into build inputs.

func (*Resolver) BuildSecrets

func (r *Resolver) BuildSecrets(ctx context.Context, serviceName string) (Output, error)

BuildSecrets returns the secret mounts and build args for a service's Dockerfile build, narrowest scope first so an app can override a project or instance default. An empty Output means nothing applies.

type SecretResolver

type SecretResolver interface {
	Resolve(ctx context.Context, serviceName, envKey string) (string, error)
}

SecretResolver reads a stored credential value.

type Source

type Source interface {
	ListPackageRegistries(ctx context.Context) ([]store.PackageRegistry, error)
	GetDesiredService(ctx context.Context, name string) (*store.DesiredService, error)
}

Source is the store surface the resolver reads.

Jump to

Keyboard shortcuts

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