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 ¶
func Sanitize(obj *unstructured.Unstructured) *unstructured.Unstructured
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.