{"modulePath":"github.com/GoCodeAlone/workflow-plugin-cms","version":"v0.1.10","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package bundle\n\nPackage bundle owns the per-tenant static-content bundle lifecycle: HMAC-verified ingest webhook → authenticated GH release tarball fetch → un-tar into versioned directory → atomic swap of \\`current\\` symlink.\n\nPer gocodealone-multisite SPEC.md:\n\n\tV8: ingest webhook → HMAC sig ! valid; mismatched req → 401.\n\tV9: bundle version monotonic per tenant; replay attempt → 409.\n\tV24: content-repo tarball fetch ! authenticated; ⊥ public-anon GET.\n\n## Constants\n\n```go\nconst SignatureHeader = \"X-Multisite-Sig\"\n```\nSignatureHeader is the canonical HMAC-bearing header.\n\n## Variables\n\n```go\nvar ErrInvalidSignature = errors.New(\"ingest: invalid HMAC signature\")\n```\nErrInvalidSignature is returned when the HMAC header does not match.\n\n```go\nvar ErrSignatureHeaderMissing = errors.New(\"ingest: signature header missing\")\n```\nErrSignatureHeaderMissing is returned when no signature header was supplied.\n\n```go\nvar ErrVersionRegression = errors.New(\"ingest: version regression\")\n```\nErrVersionRegression is returned by OnPayload when the incoming bundle version is not monotonic (V9).\n\n## Functions\n\n```go\nfunc ComputeSignature(body []byte, secret string) string\n```\nComputeSignature is the inverse of VerifyHMAC — used by the content- repo release.yml to sign outgoing requests. Returned header value is \"sha256=\\\u003chex\u003e\".\n\n```go\nfunc VerifyHMAC(header string, body []byte, secret string) error\n```\nVerifyHMAC returns nil iff \\`header\\` matches the HMAC-SHA256 of \\`body\\` using \\`secret\\`.\n\nThe header value must be of the form \"sha256=\\\u003chex\u003e\". Constant-time comparison protects against timing side-channels.\n\n## Types\n\n```go\ntype Fetcher struct {\n\t// BundleRoot is the directory under which tenants are stored.\n\tBundleRoot string\n\n\t// Token is the GH PAT or App token used as `Authorization: Bearer`.\n\t// Required (V24) — never make an anonymous request.\n\tToken string\n\n\t// HTTPClient lets tests inject a recording client. Default is\n\t// http.DefaultClient with a 30s timeout if nil.\n\tHTTPClient *http.Client\n\n\t// Now is a clock injection point for tests.\n\tNow func() time.Time\n\n\t// MaxTarballBytes caps the downloaded size (defence against\n\t// resource exhaustion). Default 200 MiB.\n\tMaxTarballBytes int64\n}\n```\nFetcher fetches a tarball from a GH release URL using a Bearer token, streams it through an integrity hash, un-tars into a versioned dir, and atomically swaps the \\`current\\` symlink.\n\nLayout on disk:\n\n\t\u003croot\u003e/\u003ctenant_slug\u003e/\u003cversion\u003e/...\n\t\u003croot\u003e/\u003ctenant_slug\u003e/current → \u003cversion\u003e\n\n\\`current\\` swap uses rename(2) semantics — readers see either the old target or the new target, never a partial state (V9 monotonic activation).\n\n```go\nfunc (f *Fetcher) Activate(ctx context.Context, tenantSlug, version, tarballURL string) (string, error)\n```\nActivate fetches the tarball, hashes it, extracts it under \\\u003cBundleRoot\u003e/\\\u003ctenantSlug\u003e/\\\u003cversion\u003e/, then atomically swaps the \\`current\\` symlink. Returns the SHA-256 hex of the tarball for integrity recording.\n\n```go\ntype IngestHandler struct {\n\tSecret    string\n\tOnPayload func(IngestPayload) error // host-supplied; usually queues a fetch\n}\n```\nIngestHandler is an http.Handler that verifies the HMAC + parses the payload, then hands off to fn for the actual fetch + activate work.\n\nThe handler itself does NO fetching — that's the bundle fetcher's job (see Fetcher in fetcher.go) — so this handler stays trivially testable.\n\n```go\nfunc (h *IngestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\n\n```go\ntype IngestPayload struct {\n\tTag        string `json:\"tag\"`         // e.g. \"v0.3.0\"\n\tRepo       string `json:\"repo\"`        // \"GoCodeAlone/gocodealone-website\"\n\tTarballURL string `json:\"tarball_url\"` // GH release asset URL\n}\n```\nIngestPayload is the body of POST /api/v1/ingest/release. Sent by the content-repo's release.yml GH Action after a tag is published; the host fetches the actual tarball.\n\n```go\nfunc (p *IngestPayload) Validate() error\n```\nValidate returns nil iff the payload satisfies basic shape rules.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-cms/bundle","name":"bundle","synopsis":"Package bundle owns the per-tenant static-content bundle lifecycle: HMAC-verified ingest webhook → authenticated GH release tarball fetch → un-tar into versioned directory → atomic swap of `current` symlink.","isRedistributable":true}
