Documentation
¶
Overview ¶
Package platformrelease defines the MCP Runtime platform component catalog, the per-release component manifest format, and version/image helpers shared by `mcp-runtime setup` (version stamping) and `mcp-runtime update`.
Index ¶
- Constants
- Variables
- func BundleCRDs(dir string) (string, error)
- func BundlePlatformObjects(dir string, keys []string, extraDirs ...string) (string, error)
- func CRDObjectNames(crdsYAML string) ([]string, error)
- func CompareVersionStrings(a, b string) (cmp int, ok bool)
- func ComponentNames() []string
- func DigestFromImageID(imageID string) string
- func FilterCRDBundle(crdsYAML string) (filtered string, names []string, err error)
- func FindK8sDeployment(dir, namespace, name string) (map[string]any, error)
- func FlagName(arg string) string
- func K8sDeploymentImage(dir, component string) (repository, tag string, err error)
- func LoadManifest(ctx context.Context, source string, client *http.Client) ([]byte, error)
- func MetadataPatch(c Component, version string) map[string]any
- func PreviousImageAnnotation(component string) string
- func ReleaseCRDsURL(version string) string
- func ReleaseCommitFromImageTag(tag string) (string, bool)
- func ReleaseManifestURL(version string) string
- func ReleaseVersionFromImageTag(tag string) string
- func StampInstalledVersion(ctx context.Context, cs kubernetes.Interface, version string) error
- func ValidDigest(s string) bool
- func ValidTag(s string) bool
- type Component
- type ComponentWiring
- type ConfigMapSpec
- type DNSOption
- type ImageRef
- type Manifest
- func GenerateManifest(version string, crdChange bool, crdsYAML string) (*Manifest, error)
- func GenerateManifestForCommit(version, commit string, crdChange bool, crdsYAML string) (*Manifest, error)
- func GenerateReleaseManifest(opts ReleaseOptions) (*Manifest, error)
- func ParseManifest(data []byte) (*Manifest, error)
- func (m *Manifest) ApplyReleaseExtras(extras ReleaseExtras) error
- func (m *Manifest) Component(name string) (ManifestComponent, bool)
- func (m *Manifest) TargetRef(c ManifestComponent, fallbackRegistry string) (ImageRef, error)
- func (m *Manifest) Validate() error
- func (m *Manifest) VerifyRelease(version, commit string) error
- type ManifestComponent
- type ManifestConfigMap
- type OptIn
- type PlatformObject
- type ReleaseExtras
- type ReleaseOptions
- type ReleaseWiring
- type SecretEnvRef
- type Version
Constants ¶
const ( LabelPartOf = "app.kubernetes.io/part-of" LabelPartOfValue = "github.com/mcp-runtime/mcp-runtime" LabelComponent = "mcpruntime.org/component" AnnotationVersion = "mcpruntime.org/platform-version" )
Metadata keys written on platform Deployments. They live on Deployment metadata (never the pod template) so writing them never triggers a rollout.
const ( // OperatorDeployment is the operator controller-manager Deployment name. OperatorDeployment = "mcp-runtime-operator-controller-manager" // OperatorNamespace is the namespace the operator runs in. OperatorNamespace = nsRuntime )
const ( // ManifestAPIVersion is the release manifest schema version. ManifestAPIVersion = "mcpruntime.org/v1alpha1" // ManifestKind is the release manifest kind. ManifestKind = "PlatformRelease" // ManifestAssetName is the file name attached to GitHub releases. ManifestAssetName = "platform-manifest.json" // CRDsAssetName is the standalone multi-document CRD YAML attached to // GitHub releases. update also accepts CRDs embedded in the manifest. CRDsAssetName = "platform-crds.yaml" // DefaultReleaseBaseURL is where --to resolves release manifests. DefaultReleaseBaseURL = "https://github.com/mcp-runtime/mcp-runtime/releases/download" )
Variables ¶
var RepeatableFlags = map[string]bool{"--enable-feature": true}
RepeatableFlags are flags that may legitimately appear more than once, so wiring appends them instead of replacing an existing occurrence.
Functions ¶
func BundleCRDs ¶
BundleCRDs reads every .yaml/.yml file under dir (lexically sorted) and returns a multi-document YAML bundle suitable for embedding in a release manifest or publishing as platform-crds.yaml.
func BundlePlatformObjects ¶
BundlePlatformObjects collects the named ServiceAccount/RBAC objects (keys like "ClusterRole/mcp-ingest-tokenreview" or "ServiceAccount/mcp-observability/mcp-ingest") from the repository's k8s/ manifests into one validated multi-document bundle, in key order. Releases declare the objects update manages explicitly, so update never touches the rest of the platform's RBAC.
func CRDObjectNames ¶
CRDObjectNames returns metadata.name values for CustomResourceDefinition documents in a multi-document YAML bundle.
func CompareVersionStrings ¶
CompareVersionStrings compares two version strings. ok is false when either side is not a semantic version, in which case the result is meaningless.
func ComponentNames ¶
func ComponentNames() []string
ComponentNames returns all catalog component names, sorted.
func DigestFromImageID ¶
DigestFromImageID extracts the sha256 digest from a container status imageID such as "docker-pullable://repo@sha256:..." or "repo@sha256:...".
func FilterCRDBundle ¶
FilterCRDBundle keeps only CustomResourceDefinition documents from a multi-document YAML bundle and returns their metadata.name values in order. Any other non-empty kind is rejected so update cannot apply arbitrary cluster objects from a release or --crds file.
func FindK8sDeployment ¶
FindK8sDeployment loads a Deployment document from the repository's k8s/ manifests.
func K8sDeploymentImage ¶
K8sDeploymentImage returns repository and tag of a component's container image as written in the repository's k8s/ manifests.
func LoadManifest ¶
LoadManifest reads a manifest from a local path or an https:// URL.
func MetadataPatch ¶
MetadataPatch returns a merge patch that sets the platform labels and, for MCP Runtime-built components, the platform-version annotation on a Deployment's own metadata. It never touches the pod template.
func PreviousImageAnnotation ¶
PreviousImageAnnotation returns the annotation key update uses to record the image a component ran before the most recent update, for manual recovery.
func ReleaseCRDsURL ¶
ReleaseCRDsURL returns the GitHub release asset URL for the CRD bundle.
func ReleaseCommitFromImageTag ¶
ReleaseCommitFromImageTag recognizes the commit suffix used by release manifests. A short or arbitrary prerelease suffix is not a source revision.
func ReleaseManifestURL ¶
ReleaseManifestURL returns the GitHub release asset URL for a version.
func ReleaseVersionFromImageTag ¶
ReleaseVersionFromImageTag removes the full Git revision suffix from tags emitted for built release images. Other prerelease tags retain their semantic version ordering.
func StampInstalledVersion ¶
StampInstalledVersion labels and annotates every installed MCP Runtime Deployment with the platform version setup just deployed. Missing Deployments are skipped. Third-party components (cert-manager) are never stamped. Metadata-only patches do not trigger rollouts.
func ValidDigest ¶
ValidDigest reports whether s is a sha256 digest.
Types ¶
type Component ¶
type Component struct {
// Name is the stable component identifier used in manifests and --only.
Name string
// Namespace and Deployment identify the workload. Empty Deployment means
// the image has no long-running workload (for example doctor-smoke).
Namespace string
Deployment string
// Container is the container name inside the Deployment pod template.
Container string
// EnvVar, when set, means the image is stored in this env var on the
// container instead of the container image (gateway proxy sidecar image).
EnvVar string
// Repository is the default image repository, used for manifest generation.
// Empty for components MCP Runtime does not build.
Repository string
// Built reports whether MCP Runtime builds and versions this image with
// the platform release (so the platform-version annotation applies).
Built bool
// OptIn marks components excluded unless explicitly selected.
OptIn OptIn
// Note is shown in plans when the component changes.
Note string
}
Component maps a release-manifest component name to the single workload container (or env var) that carries its image. The CLI owns this mapping; release manifests only provide image coordinates, so a manifest can never direct update at an arbitrary workload.
func Catalog ¶
func Catalog() []Component
Catalog returns a copy of the component catalog in rollout order.
func (Component) HasWorkload ¶
HasWorkload reports whether the component is backed by a Deployment.
type ComponentWiring ¶
type ComponentWiring struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty"`
Env map[string]string `json:"env,omitempty"`
// SecretEnv are env vars sourced from a Secret key. update adds a missing
// one or corrects a literal or differing reference; the Secret itself is
// never written by wiring.
SecretEnv []SecretEnvRef `json:"secretEnv,omitempty"`
// RemoveEnv are env vars the release retires; update deletes them from the
// container (rollback restores the previous definition).
RemoveEnv []string `json:"removeEnv,omitempty"`
// Args are container flags in --name or --name=value form. A missing flag
// is appended; an existing flag with the same name is replaced unless the
// flag is repeatable (see RepeatableFlags).
Args []string `json:"args,omitempty"`
// DNSOptions are pod resolver options (for example ndots) that must be set.
DNSOptions []DNSOption `json:"dnsOptions,omitempty"`
// ResourceHistoryToken installs one fixed projected token in Prometheus.
// It is not a general volume/mount declaration.
ResourceHistoryToken bool `json:"resourceHistoryToken,omitempty"`
}
ComponentWiring is the non-image pod configuration a release requires of a component's Deployment: the identity it runs as and literal env it needs. update adds missing wiring and corrects drift in exactly these fields; it never removes other env, so operator customisation is preserved.
func (*ComponentWiring) IsZero ¶
func (w *ComponentWiring) IsZero() bool
IsZero reports whether the wiring asks for nothing.
type ConfigMapSpec ¶
type ConfigMapSpec struct {
// Key is "<namespace>/<name>".
Key string `json:"key"`
Restart []string `json:"restart,omitempty"`
}
ConfigMapSpec selects a k8s/ ConfigMap for a release.
type ImageRef ¶
type ImageRef struct {
// Registry is the registry host (with optional port); empty when the
// reference is relative (for example "mcp-ui:v1").
Registry string
// Path is the repository path without the registry host.
Path string
Tag string
Digest string
}
ImageRef is a parsed OCI image reference.
func ParseImageRef ¶
ParseImageRef parses repo[:tag][@digest] with an optional registry host.
type Manifest ¶
type Manifest struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
// Version is the platform release version (semver).
Version string `json:"version"`
// Registry optionally resolves relative component repositories. When
// empty, relative repositories resolve against the registry host of the
// image currently running in the cluster.
Registry string `json:"registry,omitempty"`
// RequiresAudienceExchange blocks updates until supported setup installs
// split ingress routes and trusted token-exchange middleware.
RequiresAudienceExchange bool `json:"requiresAudienceExchange,omitempty"`
// RequiresAnalyticsTLS refuses image updates behind legacy plaintext
// analytics wiring. Explicit local test-mode installations are exempt.
RequiresAnalyticsTLS bool `json:"requiresAnalyticsTLS,omitempty"`
// CRDChange reports that this release changes CustomResourceDefinitions.
// When true, update applies CRDs from CRDs (or --crds / platform-crds.yaml)
// before patching component images.
CRDChange bool `json:"crdChange,omitempty"`
// CRDs is a multi-document YAML of CustomResourceDefinitions embedded in
// the release manifest so `mcp-runtime update --to` can apply schema
// changes without a separate setup run.
CRDs string `json:"crds,omitempty"`
// PlatformObjects is a multi-document YAML of the ServiceAccounts, Roles
// and bindings the release's workloads need (see ParsePlatformObjects for
// what a release may contain). update creates or corrects only the
// objects whose live spec differs.
PlatformObjects string `json:"platformObjects,omitempty"`
// ConfigMaps are platform ConfigMap keys the release owns. update writes
// only the declared keys and restarts the listed dependents when they change.
ConfigMaps []ManifestConfigMap `json:"configMaps,omitempty"`
Components []ManifestComponent `json:"components"`
}
Manifest is the authoritative per-release component version list.
func GenerateManifest ¶
GenerateManifest builds the default release manifest for version: every MCP Runtime-built component, relative repositories, tag = version. When crdChange is true, crdsYAML (multi-document CustomResourceDefinition YAML) is embedded so update can apply schema changes from the release JSON alone.
func GenerateManifestForCommit ¶
func GenerateManifestForCommit(version, commit string, crdChange bool, crdsYAML string) (*Manifest, error)
GenerateManifestForCommit gives built images a tag tied to the checked-out release commit. A tag from another source revision can no longer be reused merely because it has the same release version.
func GenerateReleaseManifest ¶
func GenerateReleaseManifest(opts ReleaseOptions) (*Manifest, error)
GenerateReleaseManifest builds the complete platform-manifest.json for a release exactly as the release workflow publishes it: built images tagged to the commit, third-party image pins from k8s/, config-only components, and the declared ServiceAccount/RBAC objects, ConfigMaps and wiring. The result has been verified with VerifyRelease and parses with the strict decoder update uses.
func ParseManifest ¶
ParseManifest decodes (JSON or YAML) and validates a release manifest.
func (*Manifest) ApplyReleaseExtras ¶
func (m *Manifest) ApplyReleaseExtras(extras ReleaseExtras) error
ApplyReleaseExtras embeds the platform bundle, ConfigMaps and per-component wiring in a generated manifest and re-validates it.
func (*Manifest) Component ¶
func (m *Manifest) Component(name string) (ManifestComponent, bool)
Component returns the manifest entry for name.
func (*Manifest) TargetRef ¶
func (m *Manifest) TargetRef(c ManifestComponent, fallbackRegistry string) (ImageRef, error)
TargetRef resolves the manifest entry into an image reference. Relative repositories resolve against m.Registry, then fallbackRegistry.
func (*Manifest) Validate ¶
Validate checks manifest shape, versions, references, and component names.
func (*Manifest) VerifyRelease ¶
VerifyRelease checks the invariants a published release manifest must hold, so a release cannot discover a broken manifest at tag time:
- every component MCP Runtime builds is present and tagged to the commit;
- third-party pins carry an explicit upstream tag, never the commit tag or latest;
- config-only components carry no image coordinates;
- the manifest round-trips through the strict decoder `update` uses.
type ManifestComponent ¶
type ManifestComponent struct {
Name string `json:"name"`
Repository string `json:"repository"`
Tag string `json:"tag"`
Digest string `json:"digest,omitempty"`
// Wiring is the non-image Deployment configuration the release requires.
Wiring *ComponentWiring `json:"wiring,omitempty"`
// ConfigOnly components keep their running image: update applies only
// wiring and config-driven restarts. Repository and tag are not required.
ConfigOnly bool `json:"configOnly,omitempty"`
}
ManifestComponent pins one component image.
type ManifestConfigMap ¶
type ManifestConfigMap struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Data map[string]string `json:"data"`
// Restart lists components whose Deployments read this ConfigMap only at
// start, so a change must roll them.
Restart []string `json:"restart,omitempty"`
}
ManifestConfigMap declares ConfigMap data a release owns.
func BundleConfigMaps ¶
func BundleConfigMaps(dir string, specs []ConfigMapSpec) ([]ManifestConfigMap, error)
BundleConfigMaps reads the named ConfigMaps (all string data keys) from the repository's k8s/ manifests.
func (ManifestConfigMap) Key ¶
func (c ManifestConfigMap) Key() string
Key identifies the ConfigMap in plans and logs.
type OptIn ¶
type OptIn string
OptIn classifies components that update only touches when explicitly selected.
type PlatformObject ¶
type PlatformObject struct {
Kind string
Namespace string // empty for cluster-scoped kinds
Name string
Object map[string]any
}
PlatformObject identifies one object in a release's platform bundle.
func ParsePlatformObjects ¶
func ParsePlatformObjects(bundle string) ([]PlatformObject, error)
ParsePlatformObjects decodes a release's platform bundle and enforces what a remote manifest may ask of the cluster: RBAC, ServiceAccounts and explicitly supported platform NetworkPolicies only, platform-owned names and namespaces, no wildcard or privilege-escalating rules, and bindings only to roles defined in the same bundle and subjects that are platform ServiceAccounts. A release can therefore never bind an existing powerful role (cluster-admin) or grant itself wildcard access.
func (PlatformObject) Key ¶
func (o PlatformObject) Key() string
Key is a stable identifier for logs and plans.
type ReleaseExtras ¶
type ReleaseExtras struct {
RequiresAudienceExchange bool
RequiresAnalyticsTLS bool
PlatformObjects string
ConfigMaps []ManifestConfigMap
Wiring map[string]*ComponentWiring
ConfigOnly []string
}
ReleaseExtras is everything a release declares beyond images.
type ReleaseOptions ¶
type ReleaseOptions struct {
// Version is the release version (for example v0.8.0) and Commit the full
// lowercase Git SHA of the release source.
Version string
Commit string
// CRDChange and CRDsYAML embed the CRD bundle when the release changes CRDs.
CRDChange bool
CRDsYAML string
// K8sDir is the directory of platform manifests (k8s/). WiringPath is
// config/release/wiring.yaml; empty skips release-declared extras.
K8sDir string
WiringPath string
}
ReleaseOptions selects what GenerateReleaseManifest reads from the repository.
type ReleaseWiring ¶
type ReleaseWiring struct {
RequiresAudienceExchange bool `json:"requiresAudienceExchange"`
RequiresAnalyticsTLS bool `json:"requiresAnalyticsTLS"`
// PlatformObjects are keys of the k8s/ objects update manages.
PlatformObjects []string `json:"platformObjects"`
ConfigMaps []ConfigMapSpec `json:"configMaps"`
Components map[string]*ComponentWiring `json:"components"`
// ConfigOnly names components whose image the release does not manage but
// whose wiring or config-driven restarts update applies.
ConfigOnly []string `json:"configOnly"`
// ThirdPartyImages names components whose image pin is taken from their
// Deployment in k8s/ (for example the platform gateway's Traefik).
ThirdPartyImages []string `json:"thirdPartyImages"`
}
ReleaseWiring is what a release asks update to apply beyond images; it is the format of config/release/wiring.yaml.
func LoadWiring ¶
func LoadWiring(path string) (ReleaseWiring, error)
LoadWiring reads config/release/wiring.yaml.
type SecretEnvRef ¶
type SecretEnvRef struct {
Name string `json:"name"`
Secret string `json:"secret"`
Key string `json:"key"`
Optional bool `json:"optional,omitempty"`
}
SecretEnvRef is one env var read from a Secret key (a secretKeyRef).
type Version ¶
type Version struct {
Major, Minor, Patch int
Pre string
// contains filtered or unexported fields
}
Version is a parsed semantic version (vMAJOR.MINOR.PATCH[-PRERELEASE]).
func ParseVersion ¶
ParseVersion parses a semantic version with an optional leading "v".