content

package
v1.78.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package content compares Kubernetes objects by content, in the one form the AUDIT-4 ruling defines (snowplow, 2026-11-11): what an object grants or holds, not how it happens to be written.

It is shared so every writer that records "this write changed content" (plumbing's helm verdicts, a controller recording objectclient writes) answers the same way for the same two objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonical

func Canonical(obj runtime.Object, contentAnnotations []string) (map[string]interface{}, error)

Canonical is obj's content in the form the AUDIT-4 ruling compares (snowplow, 2026-11-11):

DELIBERATE, not a shortcut: krateo-platformops/installer#413 condition 2 says ".spec changed", and the AUDIT-4 lead ruled (2026-11-11, recorded on installer#410) that this means every top-level field other than apiVersion, kind, metadata and status. Many kinds keep their desired state outside .spec (ConfigMap and Secret data, RBAC rules and subjects, admission webhooks), and reading the condition literally would make a change to them never count.

  • every top-level field except apiVersion, kind, metadata and status. That is .spec where there is one; data and type for a Secret or ConfigMap; webhooks for an admission configuration.

  • a Secret's stringData folded into data, as the apiserver does, so the same value written either way is the same content. A changed type is a change.

  • RBAC: a Role's or ClusterRole's rules, and a binding's subjects, as sets: order and duplicates don't matter, and within a rule neither do the order or duplicates of its verbs, apiGroups, resources, resourceNames and nonResourceURLs. A ClusterRole's aggregationRule.clusterRoleSelectors compare as a set too. roleRef compares as it is.

  • an object member whose value is null left out, at every depth, as audit's c1 form does (a null list element is kept, and a map left empty stays an empty map).

  • the annotations listed in contentAnnotations (UpgradeConfig.ContentAnnotations: the audit schema's authorization annotations, audit.AuthorizationAnnotations), under metadata.annotations: each one present with a non-null value, the rest dropped. This is the verdict's form, NOT audit.ContentSHA256's: the c1 hash form is fixed, so its key set stays the two annotations v0.12.0 declared, while the schema's list may grow (v0.13.0 added authn.krateo.io/username). A key outside c1's set is content here and not to the hash: a deliberate disagreement, pinned in TestContentAnnotationsAgreeWithTheAuditHash.

Labels and every other annotation are metadata, so they never count here (CanonicalWith counts declared labels).

func CanonicalWith added in v1.59.0

func CanonicalWith(obj runtime.Object, keys Keys) (map[string]interface{}, error)

CanonicalWith is Canonical keeping keys.Labels too, under metadata.labels, each one present with a non-null value, the rest dropped. With no labels declared it is exactly Canonical's form.

func Differs

func Differs(before, after runtime.Object, contentAnnotations []string) (bool, error)

Differs reports whether before and after differ in content: every top-level field other than apiVersion, kind, metadata and status, and the annotations listed in contentAnnotations, compared canonically (see Canonical). It is DiffersWith with no content labels.

func DiffersWith added in v1.59.0

func DiffersWith(before, after runtime.Object, keys Keys) (bool, error)

DiffersWith is Differs counting keys.Labels as content too: a declared label changed, added or removed is a change; an undeclared one is not (snowplow, 2026-11-12: authn's session Secrets carry authorization-bearing labels that tenant onboarding selects on).

Types

type Keys added in v1.59.0

type Keys struct {
	Annotations []string
	Labels      []string
}

Keys are the metadata keys that count as content: the annotations and labels authorization reads (audit.AuthorizationAnnotations, audit.AuthorizationLabels). Every other annotation and label is metadata.

Jump to

Keyboard shortcuts

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