discovery

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package discovery derives the consumer inventory automatically from cluster and config sources. No source ever requires the user to author a model file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(sets ...[]model.Consumer) []model.Consumer

Merge combines consumer sets by identity, unioning expectations, endpoints, provenance and confidence. Two consumers merge when their identity sets — {StableID} ∪ Aliases — intersect, so the same workload discovered by two sources under different primary keys (Istio by service name, Kubernetes by service account) becomes one record (KI-28). The first-seen consumer's StableID is canonical, so ordering discoverers service-name-first yields the more readable identity.

func Run

func Run(ctx context.Context, scope Scope, discoverers ...Discoverer) ([]model.Consumer, error)

Run executes every discoverer over the scope and merges the results by StableID, so a consumer seen by both Istio (issuer/audience) and Kubernetes (endpoints, owner) becomes one enriched record. Errors from individual discoverers are returned joined so a single bad source does not lose the rest.

func StableID

func StableID(p IDParts) string

StableID derives a consumer's stable identity (PRD §4.2), first match wins:

  1. k8s://{cluster}/{namespace}/{service-account-name}
  2. k8s://{cluster}/{namespace}/{service-name}
  3. route://{gateway-name}/{route-name}
  4. url://{normalized-host}{path-prefix}

The result must survive redeploys and IP changes.

func WalkYAML

func WalkYAML(paths []string, fn func(path string, doc []byte) error) error

WalkYAML invokes fn for each YAML document found under the given paths. A path may be a file or a directory; directories are walked recursively for .yaml/.yml/.json files. Multi-document YAML files (--- separated) yield one call per document.

Types

type Discoverer

type Discoverer interface {
	// Name is a stable identifier used in provenance records, e.g. "istio".
	Name() string
	// Discover returns the consumers this source can see within scope.
	Discover(ctx context.Context, scope Scope) ([]model.Consumer, error)
}

Discoverer is one source of consumers (Istio, Envoy, K8s, OIDC client registry).

type IDParts

type IDParts struct {
	Cluster        string
	Namespace      string
	ServiceAccount string
	ServiceName    string
	Gateway        string
	Route          string
	Host           string
	PathPrefix     string
}

IDParts carries the identifiers used to derive a consumer StableID.

type Scope

type Scope struct {
	KubeContext string
	Namespaces  []string
	ConfigPaths []string
	IssuerURLs  []string
}

Scope bounds a discovery run.

Directories

Path Synopsis
Package envoy discovers consumers from Envoy jwt_authn provider configuration.
Package envoy discovers consumers from Envoy jwt_authn provider configuration.
Package istio discovers consumers from Istio RequestAuthentication resources (confidence 1.0 — declarative and unambiguous).
Package istio discovers consumers from Istio RequestAuthentication resources (confidence 1.0 — declarative and unambiguous).
Package k8s discovers consumers from Kubernetes Services, their backing workloads, and projected service-account token volumes (PRD §7.3).
Package k8s discovers consumers from Kubernetes Services, their backing workloads, and projected service-account token volumes (PRD §7.3).
Package kube builds Kubernetes API clients for the in-cluster discovery path.
Package kube builds Kubernetes API clients for the in-cluster discovery path.
Package oidcclient discovers consumers from an OIDC provider's client registry (Keycloak).
Package oidcclient discovers consumers from an OIDC provider's client registry (Keycloak).

Jump to

Keyboard shortcuts

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