platformrelease

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

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

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

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

This section is empty.

Functions

func BundleCRDs

func BundleCRDs(dir string) (string, error)

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 CRDObjectNames

func CRDObjectNames(crdsYAML string) ([]string, error)

CRDObjectNames returns metadata.name values for CustomResourceDefinition documents in a multi-document YAML bundle.

func CompareVersionStrings

func CompareVersionStrings(a, b string) (cmp int, ok bool)

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

func DigestFromImageID(imageID string) string

DigestFromImageID extracts the sha256 digest from a container status imageID such as "docker-pullable://repo@sha256:..." or "repo@sha256:...".

func FilterCRDBundle

func FilterCRDBundle(crdsYAML string) (filtered string, names []string, err error)

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 LoadManifest

func LoadManifest(ctx context.Context, source string, client *http.Client) ([]byte, error)

LoadManifest reads a manifest from a local path or an https:// URL.

func MetadataPatch

func MetadataPatch(c Component, version string) map[string]any

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

func PreviousImageAnnotation(component string) string

PreviousImageAnnotation returns the annotation key update uses to record the image a component ran before the most recent update, for manual recovery.

func ReleaseCRDsURL

func ReleaseCRDsURL(version string) string

ReleaseCRDsURL returns the GitHub release asset URL for the CRD bundle.

func ReleaseManifestURL

func ReleaseManifestURL(version string) string

ReleaseManifestURL returns the GitHub release asset URL for a version.

func StampInstalledVersion

func StampInstalledVersion(ctx context.Context, cs kubernetes.Interface, version string) error

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

func ValidDigest(s string) bool

ValidDigest reports whether s is a sha256 digest.

func ValidTag

func ValidTag(s string) bool

ValidTag reports whether s is a valid OCI tag.

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 Lookup

func Lookup(name string) (Component, bool)

Lookup returns the catalog component with the given name.

func (Component) HasWorkload

func (c Component) HasWorkload() bool

HasWorkload reports whether the component is backed by a Deployment.

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

func ParseImageRef(s string) (ImageRef, error)

ParseImageRef parses repo[:tag][@digest] with an optional registry host.

func (ImageRef) Name

func (r ImageRef) Name() string

Name returns registry/path (or just path for relative references).

func (ImageRef) String

func (r ImageRef) String() string

String renders the full reference.

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"`
	// 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"`
	Components []ManifestComponent `json:"components"`
}

Manifest is the authoritative per-release component version list.

func GenerateManifest

func GenerateManifest(version string, crdChange bool, crdsYAML string) (*Manifest, error)

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 ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

ParseManifest decodes (JSON or YAML) and validates a release manifest.

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

func (m *Manifest) Validate() error

Validate checks manifest shape, versions, references, and component names.

type ManifestComponent

type ManifestComponent struct {
	Name       string `json:"name"`
	Repository string `json:"repository"`
	Tag        string `json:"tag"`
	Digest     string `json:"digest,omitempty"`
}

ManifestComponent pins one component image.

type OptIn

type OptIn string

OptIn classifies components that update only touches when explicitly selected.

const (
	// OptInNone components are updated by default.
	OptInNone OptIn = ""
	// OptInAuth covers the optional mcp-auth authorization server.
	OptInAuth OptIn = "auth"
	// OptInCertManager covers upstream cert-manager workloads.
	OptInCertManager OptIn = "cert-manager"
)

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

func ParseVersion(s string) (Version, error)

ParseVersion parses a semantic version with an optional leading "v".

func (Version) Compare

func (v Version) Compare(o Version) int

Compare returns -1, 0, or 1 following semver precedence rules.

func (Version) SameMinor

func (v Version) SameMinor(o Version) bool

SameMinor reports whether both versions share major and minor numbers.

func (Version) String

func (v Version) String() string

String returns the original version text.

Jump to

Keyboard shortcuts

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