sources

package
v1.5.20 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sources syncs private template sources: a git repo whose templates are validated like built-ins and namespaced so they never replace one.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrURLScheme   = errors.New("sources: only https and ssh git URLs are allowed")
	ErrURLCreds    = errors.New("sources: the URL may not carry a password or token, use a deploy key")
	ErrURLInternal = errors.New("sources: the host is not a public address")
	ErrURLInvalid  = errors.New("sources: not a valid git URL")
)

Errors returned by CheckURL.

Functions

func CheckURL

func CheckURL(ctx context.Context, raw string, lookup LookupFunc) (ssh bool, err error)

CheckURL accepts https and ssh git URLs whose host resolves only to public addresses. The fetch dial re-checks at connect time, so a later DNS change cannot move a source onto an internal address.

func ContentHash

func ContentHash(templateYAML, composeYAML string) string

ContentHash fingerprints what an install would run: the manifest and its compose.

func DefaultLookup

func DefaultLookup(ctx context.Context, host string) ([]netip.Addr, error)

DefaultLookup resolves through the system resolver with a short timeout.

func Fetch

func Fetch(ctx context.Context, s Source, lim Limits, lookup LookupFunc) (fs.FS, string, error)

Fetch shallow-clones the source into memory and returns its files as a read-only filesystem. Nothing touches disk, no hook, filter or submodule ever runs, and symlinks, submodules and LFS pointers are refused.

func IsBuiltin

func IsBuiltin(id string) bool

IsBuiltin reports whether id is a shipped template.

func NamespacedID

func NamespacedID(source, id string, isBuiltin func(string) bool) (string, error)

NamespacedID returns source/id. A bare id that matches a built-in is refused outright, so a source cannot look like (or later shadow) a shipped template.

func ValidName

func ValidName(name string) bool

ValidName reports whether name can namespace a source's templates.

func ValidRef

func ValidRef(ref string) bool

ValidRef reports whether ref is a plain branch name (tags are not supported).

Types

type Limits

type Limits struct {
	MaxBytes int64
	// MaxWireBytes bounds the compressed transfer; it is the real inflation bound, since
	// go-git inflates an object before any size hook sees it. Zero falls back to MaxBytes.
	MaxWireBytes int64
	MaxFiles     int
	MaxDepth     int
	Timeout      time.Duration
}

Limits bound one fetch. All of them come from runtime settings.

type LookupFunc

type LookupFunc func(ctx context.Context, host string) ([]netip.Addr, error)

LookupFunc resolves a host to its addresses; tests replace it.

type Result

type Result struct {
	Entries []store.TemplateSourceEntry
	Skipped []string
}

Result is the outcome of a sync: validated entries and per-template refusals.

func Build

func Build(source string, fsys fs.FS, isBuiltin func(string) bool) Result

Build validates every template directory of fsys and namespaces the ids. The root is templates/ when present, else the repository root.

type Source

type Source struct {
	Name string
	URL  string
	Ref  string
	Auth transport.AuthMethod
}

Source is what one sync needs. Auth is nil for an anonymous https clone.

Jump to

Keyboard shortcuts

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