deploymenttransform

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package deploymenttransform provides a generic, version-keyed registry for adapting canonical deployment artifact specs to the capability of a target gateway. Each registered Transformation is scoped to one artifact kind and applied only when its AppliesWhen predicate matches the target gateway version.

Generators produce the canonical (latest) artifact shape unconditionally. The registry's Transform call, invoked in the deploy orchestration layer before the artifact is marshalled and stored, rewrites the spec to whatever shape the target gateway understands.

New version-boundary conversions are registered once, in a package init(), without touching the deploy services. The deploy services call only Default().Transform(kind, target, &spec).

Index

Constants

View Source
const MinSplitPoliciesVersion = "1.2.0"

MinSplitPoliciesVersion is the first gateway release that understands globalPolicies/operationPolicies. Use this constant in tests and call sites instead of a raw string literal so a future version-boundary change is a one-place edit.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds registered Transformations and applies them in order.

func Default

func Default() *Registry

Default returns the package-level Registry. All transformations registered via init() are available here.

func (*Registry) Register

func (r *Registry) Register(t Transformation)

Register adds a Transformation to the registry. Transformations are applied in registration order, so order matters when multiple transformations target the same kind and version range.

func (*Registry) Transform

func (r *Registry) Transform(kind string, target Version, payload any) error

Transform runs every registered Transformation whose Kind matches and AppliesWhen(target) is true, in registration order. An unknown kind or a target version that matches no Transformation is a no-op — the canonical payload passes through unchanged.

type Transformation

type Transformation struct {
	// Name identifies the transformation in logs and error messages.
	Name string
	// Kind is the artifact kind this transformation applies to
	// (e.g. constants.LLMProvider, constants.LLMProxy).
	Kind string
	// AppliesWhen returns true when this transformation must be applied for
	// the given target gateway version.
	AppliesWhen func(target Version) bool
	// Apply mutates the payload (a *dto.*DeploymentSpec) in place.
	Apply func(payload any) error
}

Transformation adapts a canonical deployment spec so a target gateway version can consume it. Scoped to one artifact kind; applied only when AppliesWhen returns true for the target Version.

type Version

type Version struct {
	Major, Minor, Patch int
}

Version is a parsed, comparable gateway semver. Empty or unparseable version strings are treated as 1.0.0 — the implicit version for gateways that predate version reporting.

func ParseVersion

func ParseVersion(s string) Version

ParseVersion parses a gateway version string into a Version. Pre-release suffixes (e.g. "-SNAPSHOT", "-RC1") and a leading "v" are stripped before parsing. An empty or unparseable string returns Version{1, 0, 0}.

func (Version) GTE

func (v Version) GTE(o Version) bool

GTE reports whether v is greater than or equal to o.

Jump to

Keyboard shortcuts

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