gitopsownership

package
v0.1.0-c02.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitopsownership defines a provider-neutral, fail-closed contract for proving that an accepted Flux source artifact and its exact Kustomization roots uniquely own the declared critical resource families.

Version 2 is closed-world only inside each explicitly declared API-resource-and-namespace scope. Collectors list those scopes without label selectors and prove bounded pagination completeness. This does not claim whole-cluster ownership: unrelated kinds and namespaces remain outside the contract. Reviewed non-CloudRING occupants of a shared scope must be declared as externalObjects and must not be Flux-owned by a selected root.

The package validates evidence and provides provider-neutral collection mechanics. Provider credentials, live bindings, and all mutations remain the responsibility of downstream installations.

Index

Constants

View Source
const (
	CollectionPageLimit       = 500
	FluxKustomizationVersion  = "kustomize.toolkit.fluxcd.io/v1"
	FluxKustomizationKind     = "Kustomization"
	FluxKustomizationResource = "kustomizations"
)
View Source
const (
	ContractAPIVersion       = "cloudring.io/v1alpha2"
	ContractKind             = "GitOpsOwnershipContract"
	ReportAPIVersion         = "cloudring.gitops.ownership/v2"
	DiscoveryModeClosedWorld = "closed-world"
)

Variables

This section is empty.

Functions

func ValidateAcceptedSource

func ValidateAcceptedSource(revision, digest string) error

func ValidateContract

func ValidateContract(contract Contract) error

Types

type Blocker

type Blocker struct {
	ID      string `json:"id"`
	Message string `json:"message"`
	Family  string `json:"family,omitempty"`
	Object  string `json:"object,omitempty"`
}

type CollectionPageReader

type CollectionPageReader interface {
	ReadCollectionPage(context.Context, CollectionRequest) ([]byte, error)
}

CollectionPageReader is implemented downstream using a read-only Kubernetes API client. It must not add label or field selectors.

type CollectionRequest

type CollectionRequest struct {
	APIVersion      string
	Resource        string
	Namespace       string
	AllNamespaces   bool
	Limit           int
	ResourceVersion string
	Continue        string
}

CollectionRequest describes one read-only Kubernetes List request. The first request in each scope always has ResourceVersion "0" and no Continue token. Follow-up requests use only the opaque Continue token returned by the API.

type CollectionStatusError

type CollectionStatusError struct {
	Code int
	Err  error
}

CollectionStatusError lets a downstream reader preserve an HTTP status without exposing response bodies. HTTP 410 triggers a clean full restart of the affected collection scope.

func (CollectionStatusError) Error

func (err CollectionStatusError) Error() string

func (CollectionStatusError) StatusCode

func (err CollectionStatusError) StatusCode() int

func (CollectionStatusError) Unwrap

func (err CollectionStatusError) Unwrap() error

type Contract

type Contract struct {
	APIVersion string       `json:"apiVersion"`
	Kind       string       `json:"kind"`
	Metadata   Metadata     `json:"metadata"`
	Spec       ContractSpec `json:"spec"`
}

Contract defines the exact live resource families that must be owned by the selected Flux Kustomizations before prune may be considered for a later, separately approved change.

func DecodeContract

func DecodeContract(reader io.Reader) (Contract, error)

type ContractSpec

type ContractSpec struct {
	// KustomizationSelector is retained as non-authoritative diagnostic
	// metadata for v1 contracts. Closed-world collection never uses it.
	KustomizationSelector string                 `json:"kustomizationSelector"`
	Scope                 ScopeContract          `json:"scope"`
	SourceArtifact        SourceArtifactContract `json:"sourceArtifact"`
	RootSpecs             []RootSpecContract     `json:"rootSpecs"`
	RequiredFamilies      []ResourceFamily       `json:"requiredFamilies"`
	AllowUnmanaged        []ResourceRef          `json:"allowUnmanaged,omitempty"`
	PruneGate             PruneGate              `json:"pruneGate"`
	DriftProof            DriftProof             `json:"driftProof"`
}

type Discovery

type Discovery struct {
	Mode            string        `json:"mode"`
	Namespaces      []string      `json:"namespaces,omitempty"`
	ExternalObjects []ResourceRef `json:"externalObjects,omitempty"`
}

Discovery declares the exact Kubernetes collection scopes that must be read without label selectors. ExternalObjects are reviewed occupants of a shared scope; they are not unmanaged CloudRING resources.

type DriftProof

type DriftProof struct {
	Mode                  string         `json:"mode"`
	Target                ResourceRef    `json:"target"`
	ExpectedOwner         NamespacedName `json:"expectedOwner"`
	RequiredObservations  []string       `json:"requiredObservations"`
	MutationAuthorization string         `json:"mutationAuthorization"`
}

type DriftReport

type DriftReport struct {
	Mode                  string   `json:"mode"`
	Target                string   `json:"target"`
	ExpectedOwner         string   `json:"expectedOwner"`
	TargetInventoryOwned  bool     `json:"targetInventoryOwned"`
	LiveMutationPerformed bool     `json:"liveMutationPerformed"`
	RequiredObservations  []string `json:"requiredObservations"`
	NextAction            string   `json:"nextAction"`
}

type FamilyCollection

type FamilyCollection struct {
	Complete              bool          `json:"complete"`
	ResourceVersionSHA256 string        `json:"resourceVersionSHA256"`
	PageCount             int           `json:"pageCount"`
	ItemCount             int           `json:"itemCount"`
	Objects               []ResourceRef `json:"objects"`
}

FamilyCollection is a complete, unfiltered list result for one contracted resource family. ResourceVersionSHA256 is a domain-separated digest of the Kubernetes resourceVersion values and never exposes those opaque values.

func CollectFamily

func CollectFamily(ctx context.Context, family ResourceFamily, reader CollectionPageReader) (FamilyCollection, error)

CollectFamily performs a bounded, unfiltered, closed-world List over every namespace declared by a sourced family (or once for a cluster-scoped family). A 410 response discards all pages from that scope and restarts from page one.

type FamilyReport

type FamilyReport struct {
	ID                    string `json:"id"`
	Critical              bool   `json:"critical"`
	SourceState           string `json:"sourceState"`
	ExpectedCount         int    `json:"expectedCount"`
	ExpectedOwner         string `json:"expectedOwner"`
	ObservedCount         int    `json:"observedCount"`
	ManagedCount          int    `json:"managedCount"`
	AllowlistedCount      int    `json:"allowlistedCount"`
	ExternalCount         int    `json:"externalCount"`
	UnexpectedCount       int    `json:"unexpectedCount"`
	UnmanagedCount        int    `json:"unmanagedCount"`
	DiscoveryMode         string `json:"discoveryMode"`
	DiscoveryScopes       int    `json:"discoveryScopes"`
	CollectionComplete    bool   `json:"collectionComplete"`
	ResourceVersionSHA256 string `json:"resourceVersionSHA256"`
	PageCount             int    `json:"pageCount"`
	ItemCount             int    `json:"itemCount"`
	ClosedWorldComplete   bool   `json:"closedWorldComplete"`
	OwnershipComplete     bool   `json:"ownershipComplete"`
}

type FluxObjectReference

type FluxObjectReference struct {
	Kind      string `json:"kind"`
	Namespace string `json:"namespace,omitempty"`
	Name      string `json:"name"`
}

type InventoryEntry

type InventoryEntry struct {
	ID      string `json:"id"`
	Version string `json:"version"`
}

func InventoryID

func InventoryID(ref ResourceRef) (InventoryEntry, error)

type KustomizationCollection

type KustomizationCollection struct {
	Complete              bool                    `json:"complete"`
	ResourceVersionSHA256 string                  `json:"resourceVersionSHA256"`
	PageCount             int                     `json:"pageCount"`
	ItemCount             int                     `json:"itemCount"`
	Kustomizations        []KustomizationSnapshot `json:"kustomizations"`
}

KustomizationCollection is the canonical result of one complete, unfiltered all-namespace Flux Kustomization List. ResourceVersionSHA256 binds the opaque Kubernetes snapshot without exposing resourceVersion itself.

func CollectKustomizations

func CollectKustomizations(ctx context.Context, reader CollectionPageReader) (KustomizationCollection, error)

CollectKustomizations performs the canonical bounded, unfiltered, all-namespace Flux Kustomization List used by Verify. A 410 response discards every page and restarts at resourceVersion=0; no label or field selector is representable in CollectionRequest.

type KustomizationSnapshot

type KustomizationSnapshot struct {
	Namespace           string                `json:"namespace"`
	Name                string                `json:"name"`
	Generation          int64                 `json:"generation"`
	ObservedGeneration  int64                 `json:"observedGeneration"`
	Ready               bool                  `json:"ready"`
	Suspend             *bool                 `json:"suspend"`
	Prune               *bool                 `json:"prune"`
	DeletionPolicy      string                `json:"deletionPolicy"`
	Wait                *bool                 `json:"wait"`
	SourceRef           FluxObjectReference   `json:"sourceRef"`
	Path                string                `json:"path"`
	DependsOn           []FluxObjectReference `json:"dependsOn"`
	LastAppliedRevision string                `json:"lastAppliedRevision"`
	Inventory           []InventoryEntry      `json:"inventory"`
}

type Metadata

type Metadata struct {
	Name string `json:"name"`
}

type NamespacedName

type NamespacedName struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

type PruneGate

type PruneGate struct {
	Kustomizations []NamespacedName `json:"kustomizations"`
}

type Report

type Report struct {
	APIVersion               string               `json:"apiVersion"`
	Kind                     string               `json:"kind"`
	Contract                 string               `json:"contract"`
	Status                   string               `json:"status"`
	RequiredFamilyCount      int                  `json:"requiredFamilyCount"`
	ObservedResourceCount    int                  `json:"observedResourceCount"`
	ManagedResourceCount     int                  `json:"managedResourceCount"`
	AllowlistedResourceCount int                  `json:"allowlistedResourceCount"`
	ExternalResourceCount    int                  `json:"externalResourceCount"`
	UnexpectedResourceCount  int                  `json:"unexpectedResourceCount"`
	UnmanagedResourceCount   int                  `json:"unmanagedResourceCount"`
	ClosedWorldComplete      bool                 `json:"closedWorldComplete"`
	PruneEligible            bool                 `json:"pruneEligible"`
	PruneChanged             bool                 `json:"pruneChanged"`
	LiveMutationPerformed    bool                 `json:"liveMutationPerformed"`
	Families                 []FamilyReport       `json:"families"`
	DriftProof               DriftReport          `json:"driftProof"`
	Blockers                 []Blocker            `json:"blockers,omitempty"`
	Scope                    ScopeReport          `json:"scope"`
	Roots                    []RootReport         `json:"roots"`
	NonClaims                []string             `json:"nonClaims"`
	SourceArtifact           SourceArtifactReport `json:"sourceArtifact"`
}

func Verify

func Verify(contract Contract, snapshot Snapshot) (Report, int, error)

type ResourceFamily

type ResourceFamily struct {
	ID         string `json:"id"`
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Resource   string `json:"resource"`
	Namespaced bool   `json:"namespaced"`
	// LabelSelector is retained as non-authoritative diagnostic metadata for
	// installations migrating from v1. Closed-world collection never uses it.
	LabelSelector        string         `json:"labelSelector,omitempty"`
	Discovery            Discovery      `json:"discovery"`
	MinimumCount         int            `json:"minimumCount"`
	Critical             bool           `json:"critical"`
	SourceState          string         `json:"sourceState"`
	ExpectedOwner        NamespacedName `json:"expectedOwner"`
	ExpectedObjects      []ResourceRef  `json:"expectedObjects,omitempty"`
	MissingSourceBlocker string         `json:"missingSourceBlocker,omitempty"`
}

type ResourceRef

type ResourceRef struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Namespace  string `json:"namespace,omitempty"`
	Name       string `json:"name"`
}

type RootReport

type RootReport struct {
	Namespace           string `json:"namespace"`
	Name                string `json:"name"`
	Observed            bool   `json:"observed"`
	Ready               bool   `json:"ready"`
	Prune               bool   `json:"prune"`
	Suspend             bool   `json:"suspend"`
	LastAppliedRevision string `json:"lastAppliedRevision"`
	SpecSHA256          string `json:"specSHA256"`
	SpecExact           bool   `json:"specExact"`
	InventoryCount      int    `json:"inventoryCount"`
}

type RootSpecContract

type RootSpecContract struct {
	Namespace      string                `json:"namespace"`
	Name           string                `json:"name"`
	Suspend        *bool                 `json:"suspend"`
	Prune          *bool                 `json:"prune"`
	DeletionPolicy string                `json:"deletionPolicy"`
	Wait           *bool                 `json:"wait"`
	SourceRef      FluxObjectReference   `json:"sourceRef"`
	Path           string                `json:"path"`
	DependsOn      []FluxObjectReference `json:"dependsOn"`
}

type ScopeContract

type ScopeContract struct {
	Name              string           `json:"name"`
	Complete          bool             `json:"complete"`
	NonClaim          string           `json:"nonClaim"`
	CriticalFamilyIDs []string         `json:"criticalFamilyIds"`
	SelectedRoots     []NamespacedName `json:"selectedRoots"`
}

type ScopeReport

type ScopeReport struct {
	Name                        string   `json:"name"`
	Complete                    bool     `json:"complete"`
	AllCriticalFamiliesDeclared bool     `json:"allCriticalFamiliesDeclared"`
	AllSelectedRootsDeclared    bool     `json:"allSelectedRootsDeclared"`
	CriticalFamilyCount         int      `json:"criticalFamilyCount"`
	DeclaredFamilyCount         int      `json:"declaredFamilyCount"`
	SelectedRootCount           int      `json:"selectedRootCount"`
	ObservedRootCount           int      `json:"observedRootCount"`
	AllSelectedRootsObserved    bool     `json:"allSelectedRootsObserved"`
	ClosedWorldComplete         bool     `json:"closedWorldComplete"`
	NonClaim                    string   `json:"nonClaim"`
	SourceMissingFamilies       []string `json:"sourceMissingFamilies,omitempty"`
}

type Snapshot

type Snapshot struct {
	Kustomizations          []KustomizationSnapshot     `json:"kustomizations"`
	KustomizationsComplete  bool                        `json:"kustomizationsComplete"`
	KustomizationsRVHash    string                      `json:"kustomizationsResourceVersionSHA256"`
	KustomizationsPageCount int                         `json:"kustomizationsPageCount"`
	KustomizationsItemCount int                         `json:"kustomizationsItemCount"`
	Collections             map[string]FamilyCollection `json:"collections"`
	// Resources is retained only so a v1 producer fails closed instead of
	// failing to decode. Verify never uses selector-derived resources.
	Resources                map[string][]ResourceRef `json:"resources,omitempty"`
	SourceArtifact           SourceArtifactSnapshot   `json:"sourceArtifact"`
	AcceptedSourceRevision   string                   `json:"acceptedSourceRevision"`
	AcceptedArtifactDigest   string                   `json:"acceptedArtifactDigest"`
	AcceptedPublicGitlinkSHA string                   `json:"acceptedPublicGitlinkSHA"`
	ObservedPublicGitlinkSHA string                   `json:"observedPublicGitlinkSHA"`
}

type SourceArtifactContract

type SourceArtifactContract struct {
	Kind             string `json:"kind"`
	Namespace        string `json:"namespace"`
	Name             string `json:"name"`
	PublicGitlinkSHA string `json:"publicGitlinkSHA"`
}

type SourceArtifactReport

type SourceArtifactReport struct {
	Kind                     string `json:"kind"`
	Namespace                string `json:"namespace"`
	Name                     string `json:"name"`
	Ready                    bool   `json:"ready"`
	Revision                 string `json:"revision"`
	Digest                   string `json:"digest"`
	AcceptedRevision         string `json:"acceptedRevision"`
	AcceptedDigest           string `json:"acceptedDigest"`
	ExpectedPublicGitlinkSHA string `json:"expectedPublicGitlinkSHA"`
	AcceptedPublicGitlinkSHA string `json:"acceptedPublicGitlinkSHA"`
	ObservedPublicGitlinkSHA string `json:"observedPublicGitlinkSHA"`
	PublicGitlinkExact       bool   `json:"publicGitlinkExact"`
	Exact                    bool   `json:"exact"`
}

type SourceArtifactSnapshot

type SourceArtifactSnapshot struct {
	Kind               string `json:"kind"`
	Namespace          string `json:"namespace"`
	Name               string `json:"name"`
	Generation         int64  `json:"generation"`
	ObservedGeneration int64  `json:"observedGeneration"`
	Ready              bool   `json:"ready"`
	Revision           string `json:"revision"`
	Digest             string `json:"digest"`
}

Jump to

Keyboard shortcuts

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