Documentation
¶
Overview ¶
Package templatefetch is the HTTP client for vendor-supplied stack template URLs. Config validation and stack rendering both fetch those URLs, and must apply the same policy so a URL that validates also renders.
Index ¶
Constants ¶
const (
// MaxBytes caps the body of a fetched template or UI definition.
MaxBytes = 10 << 20
)
Variables ¶
var ErrRefused = errors.New("template fetch refused")
ErrRefused marks a fetch the policy refused, as opposed to one that failed on the network. A refused URL fails the same way on every attempt.
Functions ¶
func IsRefused ¶
IsRefused reports whether err is a policy refusal: a disallowed URL, redirect, or body size, or a host that is not on the public internet.
func NewClient ¶
NewClient returns the client used to fetch vendor-supplied template URLs: nested stack templates and createUiDefinition files. Those URLs come straight from app config, so the fetch must not reach anything but the public internet. The client requires https, dials only public addresses (pinning the checked address so a DNS rebind cannot swap it), follows a bounded number of https-only redirects, and fails reads past MaxBytes.
Every environment, including local dev, fetches templates from remote sources; only tests need NewLocalClient.
func NewLocalClient ¶
NewLocalClient is for tests that serve templates from an httptest server: it drops the https and public-network checks. The body cap still applies. It must not be used outside tests.
Types ¶
This section is empty.