Documentation
¶
Overview ¶
Package gatewaytranslator adapts a deployment artifact between two version axes:
- the platform data version the artifact was generated from (the shape platform-api stored it as — see PlatformDataVersion), and
- the gateway data version the target gateway accepts (its CRD apiVersion, derived from its semver — see GatewayDataVersion).
Generators always produce the canonical, gateway-latest artifact shape. Translate first normalizes the artifact up to that shape (a no-op unless the stored source lags behind), then — only if the target gateway is older than latest — down-converts to whatever shape that gateway understands. This is invoked in the deploy orchestration layer, before the artifact is marshalled and stored; the deploy services call only Translate.
Index ¶
Constants ¶
const MinGatewayV1Version = "1.2.0"
MinGatewayV1Version is the first gateway release whose CRD apiVersion is "gateway.api-platform.wso2.com/v1". Every artifact kind flips apiVersion together at this boundary — it is a gateway-wide fact, not a per-kind one — so it lives here, in exactly one place. Kind-specific data-shape transforms (see versiontranslator/v1alpha1) never hardcode this constant; they are reached only because GatewayDataVersion already resolved the target using it.
Variables ¶
This section is empty.
Functions ¶
func Translate ¶
func Translate(kind string, sourceDataVersion PlatformDataVersion, targetDataVersion GatewayDataVersion, artifact any) error
Translate adapts artifact (a pointer to one of the *DeploymentYAML structs, mutated in place) so the target gateway can consume it.
- kind is the artifact kind (e.g. constants.LLMProvider).
- sourceDataVersion is the platform data version the artifact was generated from.
- targetDataVersion is the gateway data version the target gateway accepts (see TargetGatewayDataVersion).
Types ¶
type GatewayDataVersion ¶
type GatewayDataVersion string
GatewayDataVersion is the CRD apiVersion a target gateway accepts, in normalized form.
const ( // GatewayDataVersionV1 is the latest gateway artifact shape // (gateways >= MinGatewayV1Version). GatewayDataVersionV1 GatewayDataVersion = "v1" // GatewayDataVersionV1Alpha1 is the legacy shape understood by gateways // older than MinGatewayV1Version. GatewayDataVersionV1Alpha1 GatewayDataVersion = "v1alpha1" )
func GatewayDataVersionForGateway ¶
func GatewayDataVersionForGateway(rawVersion string) GatewayDataVersion
GatewayDataVersionForGateway resolves the gateway data version a target gateway accepts from its raw reported version string (model.Gateway.Version). Down-conversion is lossy, so it applies only when the gateway positively reports a semver below MinGatewayV1Version; a blank or non-semver version (unregistered, or dev/e2e build tags like "it-e2e") is assumed to be a current build and resolves to latest (v1).
func TargetGatewayDataVersion ¶
func TargetGatewayDataVersion(gatewayTargetVersion Version) GatewayDataVersion
TargetGatewayDataVersion derives the gateway data version a target gateway accepts from its semver.
type PlatformDataVersion ¶
type PlatformDataVersion string
PlatformDataVersion is the shape platform-api stored an entity as, recorded in the DB data_version column as "<major>.<minor>" (e.g. "1.0", "1.1").
func ComputeDataVersion ¶
func ComputeDataVersion(kind string, apiVersion string) PlatformDataVersion
ComputeDataVersion derives the stored data_version "<major>.<minor>" for kind from its gateway apiVersion (major) and the per-kind data-shape minor constant. Falls back to defaultPlatformDataVersion ("1.0") when apiVersion is empty or unparseable, or kind is unrecognized.
Ported from gateway-controller's ComputeDataVersion (gateway/gateway-controller/pkg/models/data_version.go) so both sides compute the same value for the same inputs.
type Version ¶
type Version struct {
Major, Minor, Patch int
}
Version is a parsed, comparable gateway semver — the "gateway target version" the deploy orchestration layer resolves from a gateway record. Empty or unparseable version strings are treated as 1.0.0 — the implicit version for gateways that predate version reporting.
func ParseVersion ¶
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}.
Callers that must distinguish "genuinely old" from "not a semver at all" (e.g. dev/e2e builds versioned "it-e2e") should use parseVersion directly — see GatewayDataVersionForGateway.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package normalizer up-converts a deployment artifact from whatever platform data version it was generated from up to the gateway-latest shape, so the rest of the translator (and any subsequent down-conversion) always starts from a canonical, fully-split artifact.
|
Package normalizer up-converts a deployment artifact from whatever platform data version it was generated from up to the gateway-latest shape, so the rest of the translator (and any subsequent down-conversion) always starts from a canonical, fully-split artifact. |
|
Package versiontranslator routes a gateway-latest-shaped deployment artifact to the sub-package that knows how to produce the shape a given target gateway data version expects.
|
Package versiontranslator routes a gateway-latest-shaped deployment artifact to the sub-package that knows how to produce the shape a given target gateway data version expects. |
|
v1alpha1
Package v1alpha1 produces deployment artifacts for gateways older than gatewaytranslator.MinGatewayV1Version — gateways whose CRD apiVersion is "gateway.api-platform.wso2.com/v1alpha1".
|
Package v1alpha1 produces deployment artifacts for gateways older than gatewaytranslator.MinGatewayV1Version — gateways whose CRD apiVersion is "gateway.api-platform.wso2.com/v1alpha1". |