chef

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: 18 Imported by: 0

Documentation

Overview

Package chef validates Chef cookbook 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    = "chef.name"
	PropVersion = "chef.version"
	PropSHA256  = "chef.sha256"
)

Variables

View Source
var (
	ErrArchive = errors.New("chef: invalid cookbook archive")
)

Functions

func IsMetadata

func IsMetadata(path string) bool

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 UniqueFields

func UniqueFields(data []byte, known ...string) error

func ValidName

func ValidName(name string) bool

func ValidVersion

func ValidVersion(version string) bool

func ValidateManifest

func ValidateManifest(m Manifest) bool

Types

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) GuardTransferSource

func (Handler) GuardTransferSource(
	_ context.Context,
	_ format.Env,
	_ repo.Config,
	it types.Item,
) error

GuardTransferSource keeps unfiltered remote catalog metadata behind the native permission-aware API when a caller copies, moves or reuses content.

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"`
	Maintainer   string            `json:"maintainer,omitempty"`
	Description  string            `json:"description,omitempty"`
	License      string            `json:"license,omitempty"`
	SourceURL    string            `json:"source_url,omitempty"`
	Dependencies map[string]string `json:"dependencies"`
	Platforms    map[string]string `json:"platforms"`
}

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

func (*Manifest) UnmarshalJSON

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

UnmarshalJSON refuses duplicate or case-aliased keys before the cookbook identity and dependency maps reach a native client with different JSON rules.

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