rollback

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package rollback defines the rollback ConfigMap contract shared between the controller and the recover CLI.

Index

Constants

View Source
const MetaKey = "_meta"

MetaKey is the ConfigMap data key that holds transaction-level metadata.

Variables

This section is empty.

Functions

func CleanForRestore

func CleanForRestore(obj *unstructured.Unstructured, targetNS string)

CleanForRestore strips server-managed fields from an Unstructured object so it can be used for a restore (Update or Create). If targetNS is non-empty, the object's namespace is overridden.

func Key

func Key(kind, namespace, name string) string

Key returns the ConfigMap data key for a resource identified by kind, namespace, and name.

Types

type Envelope

type Envelope struct {
	// ResourceVersion of the resource at the time it was captured.
	ResourceVersion string `json:"resourceVersion,omitempty"`
	// ChangeType that produced this envelope (Create, Patch, Delete, Update).
	ChangeType string `json:"changeType"`
	// PriorState is the raw JSON of the resource before the change.
	// Nil for Create when the resource did not exist (rollback = delete).
	// Present for Create when the resource existed (rollback = restore via SSA).
	PriorState json.RawMessage `json:"priorState,omitempty"`
}

Envelope wraps a single resource's rollback state in the ConfigMap.

type Meta

type Meta struct {
	// Version of the rollback format. Currently 2.
	Version int `json:"version"`
	// TransactionName is the name of the owning Transaction.
	TransactionName string `json:"transactionName"`
	// TransactionNamespace is the namespace of the owning Transaction.
	TransactionNamespace string `json:"transactionNamespace"`
	// Changes lists each item in the transaction with its rollback key.
	Changes []MetaChange `json:"changes"`
}

Meta is stored under MetaKey and describes the transaction as a whole.

type MetaChange

type MetaChange struct {
	// Name of the ResourceChange CR.
	Name string `json:"name"`
	// Target identifies the resource being changed.
	Target MetaTarget `json:"target"`
	// ChangeType that was applied (Create, Patch, Delete, Update).
	ChangeType string `json:"changeType"`
	// RollbackKey is the ConfigMap data key holding this item's Envelope.
	RollbackKey string `json:"rollbackKey"`
}

MetaChange records one transaction item's rollback location.

type MetaTarget

type MetaTarget struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace,omitempty"`
}

MetaTarget identifies a Kubernetes resource. It mirrors api/v1alpha1.ResourceRef without importing it, so that the rollback package stays free of API dependencies.

Jump to

Keyboard shortcuts

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