puppet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package puppet validates Puppet module archives and maintains their native index.

Index

Constants

View Source
const (
	MaxArchiveBytes  = 64 << 20
	MaxUnpackedBytes = 128 << 20
	MaxManifestBytes = 1 << 20
	MaxFiles         = 4096
)
View Source
const (
	PropName    = "puppet.name"
	PropVersion = "puppet.version"
	PropSHA256  = "puppet.sha256"
)

Variables

View Source
var (
	ErrArchive = errors.New("puppet: invalid module archive")
)

Functions

func ParsePath

func ParsePath(p string) (name, version string, ok bool)

func Path

func Path(name, version string) string

func Serves

func Serves(t repo.PackageType) bool

func ValidName

func ValidName(name string) bool

func ValidVersion

func ValidVersion(version string) bool

func ValidateManifest

func ValidateManifest(m Manifest) bool

ValidateManifest rejects invalid identities and dependency constraints before metadata can enter the native index. Puppet resolves the validated constraints.

Types

type Dependency

type Dependency struct {
	Name               string `json:"name"`
	VersionRequirement string `json:"version_requirement"`
}

func (*Dependency) UnmarshalJSON

func (d *Dependency) UnmarshalJSON(data []byte) error

type Handler

type Handler struct{ generic.Handler }

func (Handler) Admit

func (Handler) Admit(
	ctx context.Context, env format.Env, c repo.Config, w format.Write,
) (format.Write, error)

func (Handler) Deleted

func (Handler) Deleting

func (Handler) Deployed

func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it types.Item) error

func (Handler) Inspect

func (Handler) Inspect(
	ctx context.Context, env format.Env, _ repo.Config, w format.Write,
) (any, error)

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

Reindex reconstructs all package versions from their admitted archives. The item tree, including the remote cache tree, remains authoritative.

type Manifest

type Manifest struct {
	Name         string       `json:"name"`
	Version      string       `json:"version"`
	Author       string       `json:"author,omitempty"`
	Summary      string       `json:"summary,omitempty"`
	License      string       `json:"license,omitempty"`
	Source       string       `json:"source,omitempty"`
	Dependencies []Dependency `json:"dependencies"`
}

Manifest is the client-visible, validated module identity and dependencies.

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects duplicate identity/dependency fields, including case aliases, so the archive and a client's JSON parser cannot disagree.

type Metadata

type Metadata struct {
	Name     string   `json:"name"`
	Version  string   `json:"version"`
	Manifest Manifest `json:"manifest"`
	Path     string   `json:"path"`
	SHA256   string   `json:"sha256"`
	Size     int64    `json:"size"`
}

func ReadArchive

func ReadArchive(r io.Reader, size int64) (Metadata, error)

ReadArchive validates the entire gzip and TAR stream, including metadata.json. It rejects duplicate and unsafe entries, links, trailing data, oversized decompression, and a manifest whose declared identity is invalid.

Jump to

Keyboard shortcuts

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