compatibility

package
v1.234.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package compatibility keeps gomplate v3 function names that gomplate v4/v5 removed or renamed working: templates that still call them execute exactly as before, and a DeprecationReporter is notified (once per template per name) so the removal is visible without breaking the render. See compat_aliases.go for the bare (non-namespaced) v3 aliases and compat_lint.go for the static checks that warn about datasource behavior gomplate v5 changed without removing a name.

Everything here is scheduled for removal in a future major release; keeping it in one package makes that removal a single directory deletion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBareAliasShims

func ApplyBareAliasShims(funcs template.FuncMap, name string, reporter DeprecationReporter)

ApplyBareAliasShims registers the v3 bare aliases gomplate v5 removed, after Sprig has already been layered into funcs, so a name Sprig already provides is left untouched. Call names and hints all point at the pipeline-friendly namespaced replacement and, since Sprig registers equivalent names, at Sprig's version too.

func ApplyNamespaceShims

func ApplyNamespaceShims(funcs, gomplateFuncs template.FuncMap, name string, reporter DeprecationReporter)

ApplyNamespaceShims replaces the conv, strings and net entries of funcs (already populated from gomplateFuncs) with wrappers that keep the v3 method names gomplate v5 removed working. It is a no-op for any namespace gomplateFuncs doesn't provide (gomplate disabled) or whose factory shape doesn't match what this file expects (an upstream gomplate change), in which case templates simply see whatever gomplate itself registered.

func ApplyShims

func ApplyShims(funcs template.FuncMap, templateName string)

ApplyShims keeps the gomplate v3 names gomplate v5 removed working in a function map assembled outside the render engine (for example scaffold templates). The funcs map must already contain Gomplate's namespaces and, if used, Sprig's functions; deprecated calls are reported against templateName with DefaultReporter.

func LintDeprecatedUsage

func LintDeprecatedUsage(parsed *template.Template, templateName string, sources map[string]*url.URL, reporter DeprecationReporter)

LintDeprecatedUsage warns about template constructs whose behavior changed under gomplate v5 without the function name itself being removed, so nothing else in this package catches them. Findings are reported against templateName, and sources maps each configured datasource alias to its parsed URL. It never fails a render: every finding here is a warning through reporter, same as the namespace and bare alias shims.

func NewHTTPFS

func NewHTTPFS(base *url.URL) (fs.FS, error)

NewHTTPFS returns a filesystem for an http or https datasource rooted at base that reads each file with a single GET, as gomplate v3 did. Gomplate v5's HTTP filesystem sends a HEAD request to stat a file before the GET and fails against servers that reject HEAD; this filesystem takes the content type from the GET response instead. Contexts, headers and HTTP clients are applied the same way as gomplate's filesystem (WithContext, WithHeader, WithHTTPClient).

Types

type DeprecationReporter

type DeprecationReporter interface {
	// Deprecated reports that templateName called deprecated, which this
	// package now serves by delegating to replacement. hint is a complete,
	// self-contained sentence naming the exact replacement; it is written to
	// be shown to a user as-is.
	Deprecated(templateName, deprecated, replacement, hint string)
}

DeprecationReporter is notified when a template uses a gomplate v3 name this package keeps working through a shim. Implementations must be safe for concurrent use: stack processing renders many templates concurrently.

func DefaultReporter

func DefaultReporter() DeprecationReporter

DefaultReporter returns the process-wide log-backed DeprecationReporter, which warns once per template per deprecated name.

func NewLogReporter

func NewLogReporter() DeprecationReporter

NewLogReporter creates a log-backed DeprecationReporter with its own deduplication state. Most callers want DefaultReporter instead.

Directories

Path Synopsis
Package netaddr reproduces the inet.af/netaddr IP, IPPrefix and IPRange values that gomplate v3's net.ParseIP, net.ParseIPPrefix and net.ParseIPRange returned.
Package netaddr reproduces the inet.af/netaddr IP, IPPrefix and IPRange values that gomplate v3's net.ParseIP, net.ParseIPPrefix and net.ParseIPRange returned.

Jump to

Keyboard shortcuts

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