deployplan

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package deployplan contains shared apply-plan manifest rendering helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildLiveManifestBlobs

func BuildLiveManifestBlobs(live map[ResourceKey]*unstructured.Unstructured) map[string]string

BuildLiveManifestBlobs returns live object YAML keyed by graph node id.

func BuildManifestBlobs

func BuildManifestBlobs(desired map[ResourceKey]ManifestDoc) map[string]string

BuildManifestBlobs returns rendered manifest YAML keyed by graph node id.

func BuildManifestDiffs

func BuildManifestDiffs(live, rendered map[string]string) map[string]string

BuildManifestDiffs returns unified diffs between live and rendered manifest blobs.

func BuildManifestTemplateIndex

func BuildManifestTemplateIndex(desired map[ResourceKey]ManifestDoc) map[string]string

BuildManifestTemplateIndex returns Helm template source paths keyed by graph node id.

func DesiredQuotaAsMap

func DesiredQuotaAsMap(t QuotaUsageTotals) map[string]resource.Quantity

DesiredQuotaAsMap converts desired usage totals to ResourceQuota resource keys.

func DiffStrings

func DiffStrings(current, desired string) string

DiffStrings renders a unified diff from live/current YAML to desired YAML.

func DocsToMap

func DocsToMap(docs []ManifestDoc) map[ResourceKey]ManifestDoc

DocsToMap indexes parsed manifest docs by resource key.

func GraphNodeID

func GraphNodeID(key ResourceKey) string

GraphNodeID returns the stable UI/data id for a resource key.

func HeadroomStatus

func HeadroomStatus(hard, headroom resource.Quantity) string

HeadroomStatus classifies quota headroom.

func ObjectYAML

func ObjectYAML(obj *unstructured.Unstructured) string

ObjectYAML serializes an object after stripping runtime-only fields.

func PickTemplateSource

func PickTemplateSource(manifestBody, fallback string) string

PickTemplateSource returns Helm's "# Source:" path when present.

func PopulateQuotaLive

func PopulateQuotaLive(ctx context.Context, client kubernetes.Interface, report *QuotaReport) error

PopulateQuotaLive fills live quota snapshots and headroom rows.

func QuantityFromMap

func QuantityFromMap(m map[string]string, key string) (resource.Quantity, bool)

QuantityFromMap parses a quantity from a string map.

func TrimUnstructured

func TrimUnstructured(obj *unstructured.Unstructured) *unstructured.Unstructured

TrimUnstructured strips runtime-only metadata before diffing.

Types

type ManifestDoc

type ManifestDoc struct {
	Key            ResourceKey
	Body           string
	Obj            *unstructured.Unstructured
	TemplateSource string
}

ManifestDoc is a parsed Helm manifest document with source metadata.

func ParseManifestDocs

func ParseManifestDocs(manifest string) []ManifestDoc

ParseManifestDocs converts a Helm manifest blob into structured entries.

type QuotaHeadroom

type QuotaHeadroom struct {
	Quota    string `json:"quota"`
	Resource string `json:"resource"`
	Hard     string `json:"hard,omitempty"`
	Used     string `json:"used,omitempty"`
	Desired  string `json:"desired,omitempty"`
	After    string `json:"after,omitempty"`
	Headroom string `json:"headroom,omitempty"`
	Status   string `json:"status"` // pass|warn|fail|unknown
}

QuotaHeadroom describes the effect of desired usage on one quota resource.

type QuotaQuantity

type QuotaQuantity struct {
	Value string `json:"value"`
}

QuotaQuantity is a JSON-stable quantity wrapper used in plan artifacts.

type QuotaReport

type QuotaReport struct {
	Namespace string           `json:"namespace"`
	Desired   QuotaUsageTotals `json:"desired"`
	Live      []QuotaSnapshot  `json:"live,omitempty"`
	Headroom  []QuotaHeadroom  `json:"headroom,omitempty"`
	Warnings  []string         `json:"warnings,omitempty"`
}

QuotaReport combines desired usage with optional live quota headroom.

func BuildDesiredQuotaReport

func BuildDesiredQuotaReport(desired map[ResourceKey]ManifestDoc, targetNamespace string) *QuotaReport

BuildDesiredQuotaReport builds the desired usage portion of a quota report.

type QuotaSnapshot

type QuotaSnapshot struct {
	Name string            `json:"name"`
	Hard map[string]string `json:"hard,omitempty"`
	Used map[string]string `json:"used,omitempty"`
}

QuotaSnapshot captures a live ResourceQuota status snapshot.

type QuotaUsageTotals

type QuotaUsageTotals struct {
	CPURequests    QuotaQuantity `json:"cpuRequests"`
	CPULimits      QuotaQuantity `json:"cpuLimits"`
	MemoryRequests QuotaQuantity `json:"memoryRequests"`
	MemoryLimits   QuotaQuantity `json:"memoryLimits"`
	Storage        QuotaQuantity `json:"storage"`
	Pods           int64         `json:"pods"`
	Services       int64         `json:"services"`
	ConfigMaps     int64         `json:"configmaps"`
	Secrets        int64         `json:"secrets"`
	PVCs           int64         `json:"pvcs"`
}

QuotaUsageTotals summarizes desired ResourceQuota-relevant resources.

func ComputeDesiredQuotaTotals

func ComputeDesiredQuotaTotals(desired map[ResourceKey]ManifestDoc, targetNamespace string) (*QuotaUsageTotals, []string)

ComputeDesiredQuotaTotals estimates quota usage from rendered manifests.

type ResourceKey

type ResourceKey struct {
	Group     string `json:"group,omitempty"`
	Version   string `json:"version,omitempty"`
	Kind      string `json:"kind"`
	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name"`
}

ResourceKey identifies a rendered Kubernetes object in plan artifacts.

func ToResourceKey

func ToResourceKey(obj *unstructured.Unstructured) ResourceKey

ToResourceKey converts an unstructured object into a stable plan key.

func (ResourceKey) String

func (k ResourceKey) String() string

Jump to

Keyboard shortcuts

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