Documentation
¶
Index ¶
- Constants
- func ReadRegistrarConfig(config *api.Config) (api.Config, error)
- func ReadTemplateConfig(config *api.Config) (api.Config, error)
- func ToPagesConfig(tpl any, stackDir, stackName string, stackCfg *api.StackConfigStatic) (any, error)
- type AuthConfig
- type PagesInput
- type RegistrarConfig
- type TemplateConfig
Constants ¶
const ProviderType = "cloudflare"
const RegistrarType = "cloudflare"
const TemplateTypeCloudflareStaticWebsite = "cloudflare-static-website"
TemplateTypeCloudflareStaticWebsite is the `type:` discriminator the plugin advertises for a static site served from Cloudflare Pages via Direct Upload. See forge/docs/design/2026-10-31/cloudflare-pages-direct-upload/.
Shape in the parent server.yaml `templates:` block:
templates:
cloudflare-static-website:
type: cloudflare-static-website
config:
credentials: ${secret:CLOUDFLARE_API_TOKEN}
accountId: e2207ddedc3cfe4e321f72b07e0592b5
Shape in the client stack `client.yaml`:
stacks:
staging:
type: static
template: cloudflare-static-website
config:
bundleDir: ${git:root}/sites/<name>/public
domain: <name>.example.com
baseDnsZone: example.com
indexDocument: index.html
errorDocument: index.html
productionBranch: main # optional
Variables ¶
This section is empty.
Functions ¶
func ReadTemplateConfig ¶
ReadTemplateConfig is the api.ConfigRegisterMap entry for the template type, used by SC core's server.yaml parser to decode the `templates:` block.
func ToPagesConfig ¶
func ToPagesConfig(tpl any, stackDir, stackName string, stackCfg *api.StackConfigStatic) (any, error)
ToPagesConfig is the client-side converter registered under api.RegisterCloudStaticSiteConverter — SC core calls it after resolving the parent template config and client stack config, so the plugin receives one merged struct. Mirrors sc-plugin-aws's ToStaticSiteConfig.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
api.Credentials `json:",inline" yaml:",inline"`
AccountId string `json:"accountId" yaml:"accountId"`
}
func (*AuthConfig) CredentialsValue ¶
func (r *AuthConfig) CredentialsValue() string
func (*AuthConfig) ProjectIdValue ¶
func (r *AuthConfig) ProjectIdValue() string
func (*AuthConfig) ProviderType ¶
func (r *AuthConfig) ProviderType() string
type PagesInput ¶
type PagesInput struct {
TemplateConfig `json:"templateConfig" yaml:"templateConfig"`
api.StackConfigStatic `json:",inline" yaml:",inline"`
StackDir string `json:"stackDir" yaml:"stackDir"`
StackName string `json:"stackName" yaml:"stackName"`
ProductionBranch string `json:"productionBranch,omitempty" yaml:"productionBranch,omitempty"`
// Flat mirrors of StackConfigStatic.Site.* — populated by
// ToPagesConfig from stackCfg.Site. The wire-decode gap: `Site
// StaticSiteConfig` is a NAMED field with `json:",inline"`, but
// Go's encoding/json ignores the ",inline" option on a named
// (non-anonymous) field, so SC core's `serializeConfigToInputs`
// serialises `"Site": {...}` nested. The plugin's `decodeInputsAs`
// then does `yaml.Marshal(plain) + yaml.Unmarshal(bytes, out)`,
// and the yaml library treats `Site:` as a KEY while the Go
// struct expects the inner fields at the PARENT level — so the
// `Site:` subtree is dropped silently and `cfg.Site.Domain` is
// "". Live-caught 2026-10-31 on navizon-landing: PagesProject
// created without a `domain:` binding, old aws CNAME deleted, no
// new CNAME, navizon.atriumdev.app public DNS broke until this
// field was wired. Fix is pragmatic rather than fundamental:
// expose the four Site.* fields the Pages driver reads at the
// top of PagesInput, populate from stackCfg.Site in
// ToPagesConfig, read via EffectiveDomain() / OverriddenBaseZone()
// with a Site.* fallback. A proper fix lives in the api repo —
// flatten the Site inline round-trip; see 04 §V.
//
// The yaml keys MUST NOT collide with the inlined Site.* keys —
// yaml.v3 is strict about duplicate keys, so a parse with both
// `domain:` (top-level Domain here) AND `Site: {domain: ...}`
// (from the inline) panics `duplicated key 'domain'`. Prefix the
// mirror keys with `_pages_` so the inline Site keys own the
// "natural" names and the mirrors live beside them without
// collision. Clients NEVER author these fields — they are only
// populated by ToPagesConfig and serialised onto the plugin bus.
Domain string `json:"pagesDomain,omitempty" yaml:"_pages_domain,omitempty"`
BaseDnsZone string `json:"pagesBaseDnsZone,omitempty" yaml:"_pages_baseDnsZone,omitempty"`
IndexDocument string `json:"pagesIndexDocument,omitempty" yaml:"_pages_indexDocument,omitempty"`
ErrorDocument string `json:"pagesErrorDocument,omitempty" yaml:"_pages_errorDocument,omitempty"`
}
PagesInput is the merged shape the plugin's Provision handler receives at deploy-time: the parent-side TemplateConfig (credentials + accountId) plus the client-side StackConfigStatic (bundleDir + domain + baseDnsZone + index / error documents). Mirrors sc-plugin-aws's StaticSiteInput exactly.
ProductionBranch is a Pages-only knob (branch label for direct-upload deployments); defaults to "main" in the driver when empty.
func (*PagesInput) EffectiveDomain ¶
func (i *PagesInput) EffectiveDomain() string
EffectiveDomain returns the custom domain to bind, with the top-level Domain field preferred over Site.Domain (the latter is dropped on the plugin bus — see PagesInput.Domain for the full story).
func (*PagesInput) OverriddenBaseZone ¶
func (i *PagesInput) OverriddenBaseZone() string
OverriddenBaseZone implements api.DnsConfigAware so the Cloudflare registrar uses the stack's own baseDnsZone instead of the parent registrar's default. Prefers the top-level BaseDnsZone (populated by ToPagesConfig) with a Site.BaseDnsZone fallback for callers who construct PagesInput directly.
type RegistrarConfig ¶
type RegistrarConfig struct {
AuthConfig `json:",inline" yaml:",inline"`
ZoneName string `json:"zoneName" yaml:"zoneName"`
Records []api.DnsRecord `json:"dnsRecords" yaml:"dnsRecords"`
}
func (*RegistrarConfig) DnsRecords ¶
func (r *RegistrarConfig) DnsRecords() []api.DnsRecord
func (*RegistrarConfig) Zones ¶
func (r *RegistrarConfig) Zones() []string
Zones implements api.RegistrarZonesAware: a Cloudflare registrar serves exactly the one zone it is configured with.
type TemplateConfig ¶
type TemplateConfig struct {
AuthConfig `json:",inline" yaml:",inline"`
}
TemplateConfig is the parent-side template config for Pages — exactly the cloudflare account coordinates. Mirrors sc-plugin-aws/api/aws.go `TemplateConfig` which embeds `AccountConfig`; here `AuthConfig` plays the same role (same fields: Credentials + AccountId).