types

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package types provides common type definitions used across the GitOps Reverser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceIdentifier

type ResourceIdentifier struct {
	Group     string // e.g., "apps", "" for core resources
	Version   string // e.g., "v1"
	Resource  string // Plural form, e.g., "deployments", "pods"
	Namespace string // Empty string for cluster-scoped resources
	Name      string // Resource name
}

ResourceIdentifier encapsulates all information needed to uniquely identify a Kubernetes resource. Its Key() is the fully-qualified REST-style identity ({group}/{version}/{resource}/{namespace}/{name}); its ToGitPath() is the versionless, namespace-first Git storage path (see that method).

func NewResourceIdentifier

func NewResourceIdentifier(group, version, resource, namespace, name string) ResourceIdentifier

NewResourceIdentifier creates a ResourceIdentifier from explicit parts. Useful for watch-based ingestion where we know group/version/resource.

func (ResourceIdentifier) IsClusterScoped

func (r ResourceIdentifier) IsClusterScoped() bool

IsClusterScoped returns true if the resource is cluster-scoped.

func (ResourceIdentifier) Key

func (r ResourceIdentifier) Key() string

Key returns a stable, fully-qualified identifier suitable for map keys and deduplication.

Format (namespaced): "group/version/resource/namespace/name" Format (cluster-scoped): "group/version/resource/name"

For core resources, Group is empty and the key begins with "/" (e.g., "/v1/secrets/ns/name").

func (ResourceIdentifier) String

func (r ResourceIdentifier) String() string

String returns a human-readable representation.

func (ResourceIdentifier) ToGitPath

func (r ResourceIdentifier) ToGitPath() string

ToGitPath generates the canonical Git file path for a new resource: {namespace-or-cluster}/{group}/{resource}/{name}.yaml. The scope segment leads (a real namespace, or the literal "_cluster" for a cluster-scoped resource) so a repository reads namespace-first, the way a human browses it; the API group is omitted for core resources, and the API version is deliberately left out — the operator writes one version per object, so a version segment adds noise and would churn the path on a preferred-version bump. This is only the cold-start fallback: once any layout exists in the target, sibling inference follows it, and an existing document is always edited in place at its current location (match-first), so changing this shape never moves a file that is already in Git. See docs/spec/gittarget-new-file-placement-rules.md.

type ResourceReference

type ResourceReference struct {
	Name      string
	Namespace string
	UID       string
}

ResourceReference references a Kubernetes resource by name and namespace. Provides a clean, reusable type for referencing GitDestinations and other resources.

UID, when set, identifies the specific object generation. It is deliberately excluded from String/Key/Equal so in-memory bookkeeping stays keyed by namespace/name; it scopes durable Redis keys (e.g. watch cursors) so a recreated GitTarget never inherits a deleted predecessor's state.

func NewResourceReference

func NewResourceReference(name, namespace string) ResourceReference

NewResourceReference creates a new resource reference.

func (ResourceReference) Equal

func (r ResourceReference) Equal(other ResourceReference) bool

Equal checks if two references are equal.

func (ResourceReference) IsZero

func (r ResourceReference) IsZero() bool

IsZero returns true if this is an empty reference.

func (ResourceReference) Key

func (r ResourceReference) Key() string

Key returns a string key suitable for map lookups.

func (ResourceReference) String

func (r ResourceReference) String() string

String returns "namespace/name" format.

func (ResourceReference) WithUID

WithUID returns a copy of the reference carrying the given object UID.

type SensitiveResourcePolicy

type SensitiveResourcePolicy struct {
	// contains filtered or unexported fields
}

SensitiveResourcePolicy classifies resource types that must use the encrypted Git write path. Core Kubernetes Secrets are always sensitive.

func ParseSensitiveResourcePolicy

func ParseSensitiveResourcePolicy(additional string) (SensitiveResourcePolicy, error)

ParseSensitiveResourcePolicy builds a policy from comma-separated additional entries in resource or group/resource form.

func (SensitiveResourcePolicy) Entries

func (p SensitiveResourcePolicy) Entries() []string

Entries returns the built-in and additional sensitive resource types in flag form.

func (SensitiveResourcePolicy) IsSensitive

func (p SensitiveResourcePolicy) IsSensitive(group, resource string) bool

IsSensitive reports whether group/resource must use the encrypted Git write path.

Jump to

Keyboard shortcuts

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