inventory

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIUsage

type APIUsage struct {
	Group      string         `json:"group"` // "" for core
	Version    string         `json:"version"`
	Kind       string         `json:"kind"`
	Count      int            `json:"count"`
	Namespaces map[string]int `json:"namespaces,omitempty"` // ns → count; cluster-scoped key ""
}

type AddOnInstance

type AddOnInstance struct {
	ID         string   `json:"id"`      // registry id, e.g. "ingress-nginx"
	Version    string   `json:"version"` // semver as detected, may be ""
	Namespaces []string `json:"namespaces"`
	Source     string   `json:"source"` // "image" | "chart"
}

type Capability

type Capability string
const (
	CapAPIUsage        Capability = "api-usage"
	CapDeprecatedCalls Capability = "deprecated-calls"
	CapHelm            Capability = "helm"
	CapAddOns          Capability = "addons"
	CapVersions        Capability = "versions"
)

type CapabilityStatus

type CapabilityStatus struct {
	Available bool   `json:"available"`
	Reason    string `json:"reason,omitempty"` // e.g. `nodes list forbidden`
}

type ComponentVersion

type ComponentVersion struct {
	Component string `json:"component"` // e.g. "kube-apiserver"
	Version   string `json:"version"`   // raw image tag, e.g. "v1.34.2"; always ParseVersion-able
}

ComponentVersion is one observed control-plane component version, detected from kube-system pod image tags (kube-apiserver, kube-controller-manager, kube-scheduler, kube-proxy). The list is (Component, Version)-deduped and sorted; managed control planes (EKS/GKE) expose no such pods, so the slice is empty there.

type DeprecatedCall

type DeprecatedCall struct {
	Group          string `json:"group"`
	Version        string `json:"version"`
	Resource       string `json:"resource"`
	Subresource    string `json:"subresource,omitempty"`
	RemovedRelease string `json:"removedRelease,omitempty"` // "1.32" (may be empty)
}

type HelmRelease

type HelmRelease struct {
	Name         string `json:"name"`
	Namespace    string `json:"namespace"`
	ChartName    string `json:"chartName"`
	ChartVersion string `json:"chartVersion"`
	AppVersion   string `json:"appVersion,omitempty"`
	Status       string `json:"status"` // deployed, superseded, failed…
}

type Inventory

type Inventory struct {
	SchemaVersion      int                             `json:"schemaVersion"` // 1
	ClusterID          string                          `json:"clusterId"`     // kube-system ns UID, or "files"
	CollectedAt        time.Time                       `json:"collectedAt"`
	ServerVersion      string                          `json:"serverVersion,omitempty"` // raw, e.g. "v1.34.2"
	Capabilities       map[Capability]CapabilityStatus `json:"capabilities"`
	APIUsage           []APIUsage                      `json:"apiUsage,omitempty"`
	DeprecatedCalls    []DeprecatedCall                `json:"deprecatedCalls,omitempty"`
	HelmReleases       []HelmRelease                   `json:"helmReleases,omitempty"`
	AddOns             []AddOnInstance                 `json:"addOns,omitempty"`
	Nodes              []NodeInfo                      `json:"nodes,omitempty"`
	ControlPlane       []ComponentVersion              `json:"controlPlane,omitempty"`
	Namespaces         []NamespaceInfo                 `json:"namespaces,omitempty"`
	UnrecognizedImages []string                        `json:"unrecognizedImages,omitempty"` // deduped, sorted, cap 200
}

type NamespaceInfo

type NamespaceInfo struct {
	Name string `json:"name"`
	Team string `json:"team,omitempty"` // from --team-label (default "team")
}

type NodeInfo

type NodeInfo struct {
	Name           string `json:"name"`
	KubeletVersion string `json:"kubeletVersion"` // raw "v1.33.1"
}

type Version

type Version struct{ Major, Minor int }

Version is a Kubernetes minor version (e.g. 1.34). Patch is ignored for evaluation.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a Kubernetes version string. Accepted forms: "1.34", "v1.34", "v1.34.2", "1.34.2". The patch component is validated but discarded — evaluation only cares about minors.

func (Version) Compare

func (v Version) Compare(o Version) int

Compare returns -1 if v < o, 0 if equal, 1 if v > o.

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

MarshalJSON emits the canonical wire form, a string like "1.38" — matching String() and the camelCase report contract.

func (Version) Next

func (v Version) Next() Version

Next returns the following minor version: 1.34 → 1.35.

func (Version) String

func (v Version) String() string

String renders the minor version, e.g. "1.34". Never includes a "v" prefix.

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the canonical string form ("1.38", anything ParseVersion takes) and, for back-compat with datasets written before the string form existed, the legacy object form {"Major":1,"Minor":38} (strict: unknown keys rejected).

Jump to

Keyboard shortcuts

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