Documentation
¶
Overview ¶
Package update owns the `mcp-runtime update` command, which moves an installed MCP Runtime platform to a release through declared images, wiring, configuration and additive platform resources.
Index ¶
Constants ¶
const ( StatusUpdated = "updated" StatusSkipped = "skipped" StatusFailed = "failed" StatusRolledBack = "rolled-back" StatusRollbackFailed = "rollback-failed" StatusNotAttempted = "not-attempted" )
Workload outcome states.
const ( ImageActionBuild = "build" ImageActionReuse = "reuse" )
const ( ObjectActionCreate = "create" ObjectActionUpdate = "update" ObjectActionSkipped = "skipped" )
Platform object actions.
const ( ActionUpdate = "update" ActionUnchanged = "unchanged" ActionSkip = "skip" ActionBlocked = "blocked" )
Plan actions.
const (
CRDActionSkipped = "skipped"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplyOptions ¶
type ApplyOptions struct {
Timeout time.Duration
RollbackOnFailure bool
Waiter RolloutWaiter
// Clients applies CRD YAML when the plan sets ApplyCRDs. Required only then.
Clients *k8sclient.Clients
// Progress receives human-readable progress lines (may be nil).
Progress func(string)
}
ApplyOptions controls rollout behaviour.
type BuildOptions ¶
type BuildOptions struct {
RegistryClient kubernetes.Interface
Kubeconfig string
Context string
Enabled bool
Source string
ImagePlatform string
Parallelism int
Retries int // extra attempts after the first failure (default 1)
// SkipRegistryProbe forces every Built candidate to Action=build without
// contacting the registry (used for --dry-run without Docker).
SkipRegistryProbe bool
// Progress receives human-readable lines (may be nil).
Progress func(string)
// Out receives docker/make stdout/stderr (may be nil).
Out io.Writer
// Injectable for tests.
RegistryHasImage func(ctx context.Context, image string) (bool, error)
BuildImage func(ctx context.Context, source, platform string, spec imageBuildSpec, image string) error
PushImage func(ctx context.Context, image string) error
}
BuildOptions controls optional local image build/push during update.
type CRDResult ¶
type CRDResult struct {
Name string `json:"name"`
Action string `json:"action,omitempty"`
Error string `json:"error,omitempty"`
}
CRDResult reports one CustomResourceDefinition apply outcome.
type ClusterInfo ¶
type ClusterInfo struct {
Context string `json:"context"`
Server string `json:"server"`
ClusterID string `json:"clusterID"`
}
ClusterInfo identifies the target cluster shown before any change.
type ImageBuildAction ¶
type ImageBuildAction struct {
Component string `json:"component"`
Image string `json:"image"`
Action string `json:"action"` // build | reuse
Reason string `json:"reason,omitempty"`
}
ImageBuildAction is one unique image the update may build or reuse.
type ObjectResult ¶
type ObjectResult struct {
Key string `json:"key"`
Action string `json:"action,omitempty"`
Error string `json:"error,omitempty"`
}
ObjectResult reports one release-declared platform object.
type Options ¶
type Options struct {
To string
ReleaseManifest string
CRDs string
ExpectClusterID string
DryRun bool
Yes bool
Only []string
IncludeAuth bool
IncludeCertManager bool
AllowDowngrade bool
RollbackOnFailure bool
Timeout time.Duration
Output string
Kubeconfig string
Context string
Build bool
Source string
ImagePlatform string
BuildParallelism int
PlatformMode string
}
Options holds parsed update flags.
type Plan ¶
type Plan struct {
Cluster ClusterInfo `json:"cluster"`
ManifestSource string `json:"manifestSource"`
TargetVersion string `json:"targetVersion"`
InstalledVersion string `json:"installedVersion,omitempty"`
// ApplyCRDs is true when this release embeds CustomResourceDefinitions
// that must be applied before image rollouts.
ApplyCRDs bool `json:"applyCRDs,omitempty"`
// CRDNames lists CustomResourceDefinition metadata.name values to apply.
CRDNames []string `json:"crdNames,omitempty"`
// CRDPreview lists per-CRD create/update/skipped intents after live compare.
CRDPreview []CRDResult `json:"crdPreview,omitempty"`
// ImageBuilds lists unique Built images to build or reuse when --build is set.
ImageBuilds []ImageBuildAction `json:"imageBuilds,omitempty"`
// PlatformObjects previews the ServiceAccount/RBAC/NetworkPolicy objects the release
// manages: create, update, or skipped when they already match.
PlatformObjects []ObjectResult `json:"platformObjects,omitempty"`
// ConfigMaps previews the declared ConfigMap keys the release owns.
ConfigMaps []ObjectResult `json:"configMaps,omitempty"`
CatalogNamespaces []ObjectResult `json:"catalogNamespaces,omitempty"`
// TokenKeys previews the platform token key pair provisioning (no key material).
TokenKeys *TokenKeyPlan `json:"tokenKeys,omitempty"`
Rows []Row `json:"components"`
Preserved []string `json:"preservedResources"`
Warnings []string `json:"warnings,omitempty"`
// contains filtered or unexported fields
}
Plan is the full update plan.
func BuildPlan ¶
func BuildPlan(ctx context.Context, cs kubernetes.Interface, m *platformrelease.Manifest, sel Selection) (*Plan, error)
BuildPlan reads the installed inventory and diffs it with the manifest. It only reads: namespaces, deployments, and pods. When the manifest marks a CRD change, CRD YAML must already be present on the Manifest (embedded, --crds, or fetched platform-crds.yaml).
func (*Plan) NeedsApply ¶
NeedsApply reports whether the plan would mutate the cluster (CRDs and/or images).
type Result ¶
type Result struct {
CRDs []CRDResult `json:"crds,omitempty"`
PlatformObjects []ObjectResult `json:"platformObjects,omitempty"`
ConfigMaps []ObjectResult `json:"configMaps,omitempty"`
CatalogNamespaces []ObjectResult `json:"catalogNamespaces,omitempty"`
Workloads []WorkloadResult `json:"workloads"`
Failed bool `json:"failed"`
}
Result is the outcome of applying a plan.
func Apply ¶
func Apply(ctx context.Context, cs kubernetes.Interface, plan *Plan, opts ApplyOptions) *Result
Apply applies release CRDs (when planned) then patches only the changed workloads, one at a time, waiting for each rollout. On image-rollout failure it stops and, when enabled, restores previous images of every workload touched in this run in reverse order. CRD applies are not rolled back (Kubernetes CRD downgrades are unsafe).
type RolloutWaiter ¶
RolloutWaiter waits for a Deployment rollout to complete.
func DefaultWaiter ¶
func DefaultWaiter(cs kubernetes.Interface) RolloutWaiter
DefaultWaiter waits using k8sclient rollout semantics.
type Row ¶
type Row struct {
Component string `json:"component"`
Namespace string `json:"namespace,omitempty"`
Deployment string `json:"deployment,omitempty"`
Container string `json:"container,omitempty"`
EnvVar string `json:"envVar,omitempty"`
CurrentImage string `json:"currentImage,omitempty"`
CurrentDigest string `json:"currentDigest,omitempty"`
TargetImage string `json:"targetImage,omitempty"`
CurrentVersion string `json:"currentVersion,omitempty"`
TargetVersion string `json:"targetVersion,omitempty"`
Action string `json:"action"`
Reason string `json:"reason,omitempty"`
Notes []string `json:"notes,omitempty"`
// Wiring lists the non-image Deployment settings this update corrects
// (ServiceAccount, token mount, required env).
Wiring []string `json:"wiring,omitempty"`
// contains filtered or unexported fields
}
Row is one component line in the plan.
type Selection ¶
type Selection struct {
Only []string
IncludeAuth bool
IncludeCertManager bool
AllowDowngrade bool
}
Selection controls which components are considered.
type TokenKeyPlan ¶
type TokenKeyPlan struct {
// Action is generate (no signing key yet), extend (add the signing key's
// public key to the verification set), sync (copy the verification set to
// verifier Secrets that lack it) or keep (nothing to write).
Action string `json:"action"`
// Secrets lists the Secrets (namespace/name) that would be written.
Secrets []string `json:"secrets,omitempty"`
// contains filtered or unexported fields
}
TokenKeyPlan summarizes platform token key provisioning. It never carries key material.
func (*TokenKeyPlan) Needed ¶
func (p *TokenKeyPlan) Needed() bool
Needed reports whether provisioning writes anything.
type WorkloadResult ¶
type WorkloadResult struct {
Namespace string `json:"namespace"`
Deployment string `json:"deployment"`
Components []string `json:"components"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
// Recovery lists manual commands to restore the previous images.
Recovery []string `json:"recovery,omitempty"`
// contains filtered or unexported fields
}
WorkloadResult reports what happened to one Deployment.