templatefetch

package
v0.19.1293 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

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

View Source
const (

	// MaxBytes caps the body of a fetched template or UI definition.
	MaxBytes = 10 << 20
)

Variables

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

func IsRefused(err error) bool

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

func NewClient() *http.Client

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

func NewLocalClient() *http.Client

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.

Jump to

Keyboard shortcuts

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