sanitize

package
v0.41.1 Latest Latest
Warning

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

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

Documentation

Overview

Package sanitize removes server-generated fields from Kubernetes objects. It preserves only the desired state for Git commit operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalToOrderedYAML

func MarshalToOrderedYAML(obj *unstructured.Unstructured) ([]byte, error)

MarshalToOrderedYAML converts an unstructured object to YAML with guaranteed field order. Field order: apiVersion, kind, metadata, then payload (spec, data, rules, etc.)

It encodes through yamlstyle, which is the same encoder that re-serializes a document edited in place. That is not an implementation detail: this function produces the bytes a CREATE commits, manifestedit produces the bytes an UPDATE commits, and when the two styles differ the first update after a create rewrites every sequence line in the file to carry one changed field. TestCreateAndUpdateAgreeByteForByte pins them together.

func Sanitize

Sanitize removes server-side fields from a Kubernetes object, leaving only the desired state.

Types

type PartialObjectMeta

type PartialObjectMeta struct {
	Name        string            `json:"name,omitempty"        yaml:"name,omitempty"`
	Namespace   string            `json:"namespace,omitempty"   yaml:"namespace,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"      yaml:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
}

PartialObjectMeta defines the subset of ObjectMeta fields we preserve in GitOps storage. This explicitly documents our sanitization policy.

func (*PartialObjectMeta) FromUnstructured

func (p *PartialObjectMeta) FromUnstructured(obj *unstructured.Unstructured)

FromUnstructured extracts PartialObjectMeta from an unstructured object.

Jump to

Keyboard shortcuts

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