Documentation
¶
Overview ¶
Package cloudflare is the hosting provider abcd's own site deploys through (itd-2609061543533170): an assets-only Cloudflare Worker, the host abcd's own site is served from.
The repository half is data: wrangler.jsonc, and a deploy step that runs the pinned wrangler action with the two environment secrets it names. The host half speaks the Cloudflare v4 API over HTTPS with the person's API token:
GET /accounts the one account the token reaches
GET /accounts/{a}/workers/workers does the Worker exist (paged)
POST /accounts/{a}/workers/workers create it, workers.dev on
GET /accounts/{a}/workers/domains is the domain routed, and to whom
PUT /accounts/{a}/workers/domains route the domain to the Worker
GET /accounts/{a}/workers/subdomain the workers.dev address
These calls are written against Cloudflare's published API reference and are exercised in this repository only against cloudflaretest's in-process fake; none of them has been run against the live service by its tests.
The token is held by the connected client and set on one request header. It is never formatted into an error: a host's error message is remote-controlled text, so it is truncated and has the token scrubbed out of it before it is allowed into a returned error, which callers print.
Index ¶
- Constants
- type Adapter
- func (a Adapter) Connect(token string) hosting.Provider
- func (Adapter) CredentialName() string
- func (Adapter) DeployStep() string
- func (Adapter) HostConfig(s hosting.Site) (string, []byte)
- func (Adapter) Name() string
- func (Adapter) Profile(hosting.Site) hosting.Profile
- func (Adapter) Secrets() []string
Constants ¶
const ( SecretToken = "CLOUDFLARE_API_TOKEN" SecretAccount = "CLOUDFLARE_ACCOUNT_ID" )
Secret names the deploy job reads. The account id is not secret, but it rides as one so the workflow names nothing account-specific in the tree.
const CredentialName = "hosting.cloudflare"
CredentialName is the machine credential this provider resolves.
const ProductionBaseURL = "https://api.cloudflare.com/client/v4"
ProductionBaseURL is the Cloudflare v4 API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
BaseURL string
}
Adapter is the cloudflare provider. The zero value speaks to the production API; BaseURL points it at a fake.
func (Adapter) CredentialName ¶
CredentialName is the name the API token is resolved by.
func (Adapter) DeployStep ¶
DeployStep runs `wrangler deploy` through the pinned action. `deploy` also asserts the routes wrangler.jsonc declares, so a lost domain attachment is re-claimed by the next release rather than staying lost.
func (Adapter) HostConfig ¶
HostConfig renders wrangler.jsonc for s. The values are validated by the caller; they are JSON-encoded here regardless, so no value can break out of its string.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cloudflaretest is an in-process fake of the slice of the Cloudflare v4 API the cloudflare hosting adapter calls, for tests only.
|
Package cloudflaretest is an in-process fake of the slice of the Cloudflare v4 API the cloudflare hosting adapter calls, for tests only. |