coverage

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package coverage builds the disco-vs-upstream type coverage matrix for every registered cloud provider. Each provider implements Provider and registers itself via init() — see internal/providers/<p>/coverage.go.

Coverage truth source = the emits []TypeDecl declared on each scanner's serviceEntry, aggregated through the provider's Emits() method. Upstream truth source = a live registry call (CFN ListTypes / ARM Providers/List / GCP Discovery API) executed at command time. The matching engine reconciles the two sets via per-provider alias maps to produce the final matrix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlgorithmicUpstreamKey

func AlgorithmicUpstreamKey(discoType string) string

AlgorithmicUpstreamKey is the fallback mapping used when no alias is registered for a given disco-type. Today this is just the lowercased disco-type itself — alias maps are the source of truth for accurate matching, and the fallback exists only so that providers whose upstream-key shape happens to equal the disco-type can omit alias entries.

Per-provider algorithmic conversions (CFN PascalCase, ARM camelCase, GCP resource-collection forms) live in the provider's coverage.go alias-map builder, where the disco<->upstream rules are visible alongside the provider's other quirks.

func Names

func Names() []string

Names returns the sorted names of every registered provider.

func PascalToKebab

func PascalToKebab(s string) string

PascalToKebab converts a PascalCase or mixed-case identifier to kebab-case. Lifted from cmd/types_aws.go so per-provider alias-map builders can reuse it. Inserts '-' at lower→upper transitions and before the trailing capital of an acronym run (e.g. "DBInstance" → "db-instance").

func Register

func Register(p Provider)

Register adds a Provider to the global registry. Called from each provider package's init().

func RenderJSON

func RenderJSON(w io.Writer, matrices []Matrix) error

RenderJSON emits a structured matrix slice for tooling. Shape mirrors the in-memory Matrix/Row types directly so consumers can decode into the same structs.

func RenderMarkdown

func RenderMarkdown(w io.Writer, matrices []Matrix) error

RenderMarkdown writes a per-provider markdown matrix (covered / uncovered / synthetic / upstream-missing). Suitable for `disco coverage -o markdown` piped into docs/coverage.md or pasted into the README.

func RenderTable

func RenderTable(w io.Writer, matrices []Matrix) error

RenderTable writes a tabwriter-aligned plain-text matrix. Bucket column makes filtering by `awk '$4 == "covered"'` etc. straightforward at the shell.

Types

type Bucket

type Bucket string

Bucket classifies a single matrix row.

const (
	BucketCovered         Bucket = "covered"
	BucketUncovered       Bucket = "uncovered"
	BucketSynthetic       Bucket = "synthetic"
	BucketUpstreamMissing Bucket = "upstream-missing"
)

Bucket values; semantics documented in internal/coverage/CLAUDE.md.

type FetchOptions

type FetchOptions struct {
	Region       string
	Profile      string
	Subscription string
}

FetchOptions carry per-invocation knobs from the cmd. Each provider reads only the fields it cares about — AWS uses Region/Profile, Azure uses Subscription, GCP ignores all three.

type Matrix

type Matrix struct {
	Provider string `json:"provider"`
	Rows     []Row  `json:"rows"`
}

Matrix groups rows by provider for rendering.

func Build

func Build(providerName string, emits []TypeDecl, aliases map[string]string, algorithmic func(string) string, upstream []UpstreamType) Matrix

Build assembles the coverage matrix for one provider. emits and upstream are deduped by their canonical keys (DiscoType / UpstreamKey) before matching. A disco-type marked Synthetic short-circuits to BucketSynthetic regardless of upstream presence; a non-synthetic disco-type whose alias resolves to an upstream key not in the live registry produces BucketUpstreamMissing — the drift signal called out in ROADMAP G5.

type Provider

type Provider interface {
	Name() string
	Fetch(ctx context.Context, opts FetchOptions) ([]UpstreamType, error)
	Emits() []TypeDecl
	Aliases() map[string]string             // disco-type -> upstream key (overrides)
	AlgorithmicKey(discoType string) string // fallback when no alias entry exists
}

Provider is implemented by each cloud provider package. Aggregates emits from registeredServices, exposes the live Fetch, and supplies the alias map + an algorithmic fallback used when a disco-type has no explicit alias.

func All

func All() []Provider

All returns every registered Provider, sorted by Name.

func Get

func Get(name string) (Provider, bool)

Get returns the registered Provider by name.

type Row

type Row struct {
	Provider    string `json:"provider"`
	Service     string `json:"service"`
	DiscoType   string `json:"disco_type,omitempty"`   // empty when row is upstream-only (uncovered)
	UpstreamKey string `json:"upstream_key,omitempty"` // empty when row is synthetic
	Bucket      Bucket `json:"bucket"`
}

Row is one entry in the coverage matrix.

type TypeDecl

type TypeDecl struct {
	Service   string // disco's service segment (e.g. "ec2", "compute", "microsoft.compute")
	DiscoType string // canonical disco type, e.g. "aws:ec2:instance"
	Synthetic bool   // true = no upstream registry entry expected (disco-only)
}

TypeDecl is one disco resource type declared by a scanner's emits field.

type UpstreamType

type UpstreamType struct {
	Key     string // canonical upstream identifier, provider-specific shape
	Service string // grouping bucket for matrix rendering
}

UpstreamType is one entry returned by a provider's live registry Fetch.

Jump to

Keyboard shortcuts

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