pages

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 21 Imported by: 0

Documentation

Overview

Package pages holds the static-site deploy providers for the `kind: pages` target. The lifecycle is provider-agnostic — resolve a build's transport artifact, extract it into a publish workspace, Prepare the workspace, then Deploy — which generalizes to a future PublishProvider (Cloudflare Pages, GitHub Pages, S3 website, Netlify, …). Only method shapes that stay vendor-neutral live on the interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterWorkspace

func FilterWorkspace(ws string, opts DeployOpts) error

FilterWorkspace prunes a publish workspace in place: removes files matching any Exclude glob, then (if Include is non-empty) removes anything NOT matching an Include glob. Patterns match against workspace-relative slash paths. Shared by providers' Prepare so filtering semantics stay identical across vendors.

Types

type AssetHasher

type AssetHasher interface {
	// Hash returns the provider's asset hash for a file. name carries the extension
	// (some protocols fold it into the hash); contents is the raw file bytes.
	Hash(name string, contents []byte) string
}

AssetHasher computes the content hash a static-hosting provider's upload protocol expects for an asset. Isolated behind an interface so a provider whose protocol evolves gets a new versioned implementation (…V2Hasher) rather than a rewrite.

type CredentialRequirement

type CredentialRequirement struct {
	Name        string
	Required    bool
	Description string
}

CredentialRequirement describes one credential a provider needs. Returning structured requirements (not raw names) makes missing-credential diagnostics precise.

type DNSProvider

type DNSProvider string

DNSProvider classifies where a domain's AUTHORITATIVE nameservers live (an NS lookup, not the registrar) — the signal for whether the host can auto-configure DNS. Purely informational: used to tailor diagnostics, never to gate the attach.

const (
	DNSCloudflare DNSProvider = "cloudflare" // every authoritative NS ends in .cloudflare.com
	DNSExternal   DNSProvider = "external"   // authoritative DNS is hosted elsewhere
	DNSUnknown    DNSProvider = "unknown"    // NS lookup failed or was inconclusive
)

type DeployOpts

type DeployOpts struct {
	Project string            // cloudflare project/site name (default: target id)
	Repo    string            // github OWNER/REPO (default: current repo)
	Domains []string          // custom domain(s) to attach, if any
	Include []string          // workspace allowlist globs (empty = keep everything)
	Exclude []string          // workspace denylist globs
	Env     map[string]string // resolved credentials to forward into the deploy
	DryRun  bool              // stage but do not externalize
}

DeployOpts carries the vendor-neutral inputs a deploy needs.

type DeployResult

type DeployResult struct {
	URL     string          // deployment URL (e.g. https://abc.project.pages.dev)
	Domains []DomainOutcome // one per requested custom domain; empty when none requested
}

DeployResult separates the two distinct outcomes of a pages deploy: the site reaching the host (critical — an error on Deploy) and the custom-domain configuration (an enhancement — best-effort, reported as data, never fatal).

type DomainOutcome

type DomainOutcome struct {
	Name        string      // the requested custom domain
	Attached    bool        // the host accepted the custom-domain association
	DNSProvider DNSProvider // authoritative-NS classification (informational)
	Err         string      // non-fatal attach error text; empty on success
}

DomainOutcome is the DATA of a custom-domain attach attempt — the cli/cmd layer turns it into tailored guidance (this package never renders). The Pages API is the authority for whether the hostname is attached; DNSProvider only colors the advice.

type Provider

type Provider interface {
	// Prepare finalizes the workspace in place before deploy: applies include/exclude
	// and writes any provider-specific metadata (e.g. GitHub's CNAME/.nojekyll). Keeps
	// provider quirks out of the publish runner.
	Prepare(ws string, opts DeployOpts) error
	// Deploy publishes the workspace. A returned error means the SITE deploy itself
	// failed (the critical operation). Custom-domain configuration is an enhancement
	// carried in DeployResult.Domains and never surfaces as this error — a domain
	// problem must not retroactively fail a successful deploy.
	Deploy(ctx context.Context, ws string, opts DeployOpts) (DeployResult, error)
	// Credentials declares the env vars this provider needs (for diagnostics + forwarding).
	Credentials() []CredentialRequirement
}

Provider deploys a prepared publish workspace to a static hosting provider.

func Get

func Get(name string) (Provider, error)

Get returns the provider for a name. Cloudflare and GitHub are co-equal — there is no default, so the caller must name one (a pages target requires provider:).

Jump to

Keyboard shortcuts

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