plan

package
v0.0.0-...-56f0874 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadObjectsFromFilesystem

func LoadObjectsFromFilesystem(p string) ([]*unstructured.Unstructured, error)

LoadObjectsFromFilesystem parses yaml objects from the provided directory or file path.

func ParseObjects

func ParseObjects(r io.Reader) ([]*unstructured.Unstructured, error)

ParseObjects parses yaml objects from the provided reader.

func RunPlan

func RunPlan(ctx context.Context, opt *PlanOptions) error

RunPlan executes a plan operation.

Types

type Action

type Action struct {
	Type       ActionType                 `json:"action,omitempty"`
	APIVersion string                     `json:"apiVersion,omitempty"`
	Kind       string                     `json:"kind,omitempty"`
	Name       string                     `json:"name,omitempty"`
	Namespace  string                     `json:"namespace,omitempty"`
	Object     *unstructured.Unstructured `json:"object,omitempty"`
	Diff       *ObjectDiff                `json:"diff,omitempty"`
}

Action represents an individual object change.

type ActionType

type ActionType string

ActionType is an enum type for the type of change (no-change/create/update etc).

const (
	ActionTypeUnchanged    ActionType = "Unchanged"
	ActionTypeCreate       ActionType = "Create"
	ActionTypeApplyChanges ActionType = "ApplyChanges"
	ActionTypeError        ActionType = "Error"
)

type ClusterTarget

type ClusterTarget struct {
	// contains filtered or unexported fields
}

ClusterTarget supports actions against a running kubernetes cluster.

func NewClusterTarget

func NewClusterTarget(restConfig *rest.Config, httpClient *http.Client) (*ClusterTarget, error)

func (*ClusterTarget) ResourceForGVK

func (c *ClusterTarget) ResourceForGVK(ctx context.Context, gvk schema.GroupVersionKind) (*clusterResourceTarget, error)

ResourceForGVK gets the GVR / Scope for the specified object.

type FieldDiff

type FieldDiff struct {
	Path     string `json:"path"`
	OldValue any    `json:"oldValue,omitempty"`
	NewValue any    `json:"newValue,omitempty"`
}

type FieldPath

type FieldPath struct {
	// contains filtered or unexported fields
}

func (*FieldPath) String

func (f *FieldPath) String() string

func (*FieldPath) With

func (f *FieldPath) With(part string) *FieldPath

type ObjectDiff

type ObjectDiff struct {
	OldObject *unstructured.Unstructured `json:"oldObject,omitempty"`

	Fields []FieldDiff `json:"fields,omitempty"`
}

func BuildObjectDiff

func BuildObjectDiff(oldObj, newObj *unstructured.Unstructured) (*ObjectDiff, error)

func (*ObjectDiff) PrettyPrintTo

func (d *ObjectDiff) PrettyPrintTo(newObject *unstructured.Unstructured, options PrettyPrintOptions, out io.Writer) error

func (*ObjectDiff) PrintStructuredTo

func (d *ObjectDiff) PrintStructuredTo(out io.Writer)

type Plan

type Plan struct {
	metav1.TypeMeta

	Spec PlanSpec `json:"spec,omitempty"`
}

Plan stores the expected changes when applying changes to a cluster. For consistency, we represent it as a KRM object, but we don't expect it to be applied to a cluster.

type PlanOptions

type PlanOptions struct {
	Out     io.Writer
	Objects []*unstructured.Unstructured

	RESTConfig *rest.Config
	HTTPClient *http.Client
}

PlanOptions holds options for a plan operation.

type PlanSpec

type PlanSpec struct {
	Actions []Action `json:"actions,omitempty"`
}

PlanSpec is the Spec for a Plan object.

type Planner

type Planner struct {
}

Planner holds the core planning logic and state.

func (*Planner) BuildPlan

func (r *Planner) BuildPlan(ctx context.Context, objects []*unstructured.Unstructured, target *ClusterTarget) (*Plan, error)

BuildPlan is the entry point for building a plan.

type PrettyPrintOptions

type PrettyPrintOptions struct {
	PrintObjectInfo bool
	Indent          string
}

Jump to

Keyboard shortcuts

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