bundle

package
v0.10.17 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bundle defines the single source of truth for which files may appear inside a deploy bundle. Both the CLI zipper and the server extractor call Inspect with the same Rules so client-side and server-side enforcement cannot drift.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DigestZipReader added in v0.5.6

func DigestZipReader(zr *zip.Reader) (string, error)

DigestZipReader computes a stable content digest over the accepted entries of a deploy bundle. Client (CLI) and server compute it from the same produced zip so the two cannot drift.

Definition: apply Rules.Inspect to every entry.

  • FilterAccept regular file -> contributes (name, execBit, sha256(body)).
  • FilterSkipCacheDir -> ignored (matches extractor behavior).
  • any FilterReject* -> hard error (the live bundle rejects it too).

Directory entries never contribute. Entries are sorted by name; the digest is sha256 over a length-prefixed serialization so no field boundary is ambiguous. A duplicate accepted name is a hard error.

Types

type FilterDecision

type FilterDecision int

FilterDecision is the per-entry classification produced by Rules.Inspect.

const (
	// FilterAccept: include in the bundle.
	FilterAccept FilterDecision = iota
	// FilterSkipCacheDir: known build/VCS cache; omit silently, not an error.
	FilterSkipCacheDir
	// FilterRejectDataDir: first segment is exactly "data" — reserved by the
	// platform for the persistent data mount. Hard error.
	FilterRejectDataDir
	// FilterRejectDatasetDir: first segment is "datasets" or
	// ".shinyhub-data" — reserved namespaces for data shipped via push.
	FilterRejectDatasetDir
	// FilterRejectExtension: data-format file (parquet, duckdb, sqlite, …).
	FilterRejectExtension
	// FilterRejectFileSize: single file exceeds Rules.MaxFileBytes.
	FilterRejectFileSize
)

func (FilterDecision) String

func (d FilterDecision) String() string

String renders a decision for log/error messages.

type Rules

type Rules struct {
	MaxFileBytes   int64    `json:"maxFileBytes"`
	CacheDirs      []string `json:"cacheDirs"`
	DataExtensions []string `json:"dataExtensions"`
	// MaxBundleBytes is informational for clients (UI shows it, server
	// re-asserts via Storage.MaxBundleMB at the multipart boundary).
	MaxBundleBytes int64 `json:"maxBundleBytes"`
}

Rules is the per-bundle policy. Total bundle size is enforced separately at the multipart layer because per-entry inspection cannot know it.

func DefaultRules

func DefaultRules() Rules

DefaultRules returns the policy embedded in v1.

func (Rules) Inspect

func (r Rules) Inspect(relPath string, size int64) FilterDecision

Inspect classifies a single bundle entry. relPath is forward-slash separated, relative to the bundle root, with no leading slash.

Jump to

Keyboard shortcuts

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