cloudflare

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cloudflare is the one hosting provider abcd ships (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

View Source
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.

View Source
const CredentialName = "hosting.cloudflare"

CredentialName is the machine credential this provider resolves.

View Source
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) Connect

func (a Adapter) Connect(token string) hosting.Provider

Connect returns the host half acting with token.

func (Adapter) CredentialName

func (Adapter) CredentialName() string

CredentialName is the name the API token is resolved by.

func (Adapter) DeployStep

func (Adapter) DeployStep() string

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

func (Adapter) HostConfig(s hosting.Site) (string, []byte)

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.

func (Adapter) Name

func (Adapter) Name() string

Name is the manifest key.

func (Adapter) Secrets

func (Adapter) Secrets() []string

Secrets are the deploy environment's secret names.

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.

Jump to

Keyboard shortcuts

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