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 ¶
- Variables
- func CheckURL(ctx context.Context, raw string, lookup LookupFunc) (ssh bool, err error)
- func ContentHash(templateYAML, composeYAML string) string
- func DefaultLookup(ctx context.Context, host string) ([]netip.Addr, error)
- func Fetch(ctx context.Context, s Source, lim Limits, lookup LookupFunc) (fs.FS, string, error)
- func IsBuiltin(id string) bool
- func NamespacedID(source, id string, isBuiltin func(string) bool) (string, error)
- func ValidName(name string) bool
- func ValidRef(ref string) bool
- type Limits
- type LookupFunc
- type Result
- type Source
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
ContentHash fingerprints what an install would run: the manifest and its compose.
func DefaultLookup ¶
DefaultLookup resolves through the system resolver with a short timeout.
func Fetch ¶
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 NamespacedID ¶
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.
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 ¶
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.