catalog

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package catalog hosts the host-side FieldSpec catalog (covers all 13 typed `infra.*` Configs from workflow-plugin-infra), the region catalog, and the engine catalog. The catalog drives the new-resource form-builder UI and feeds the typed AdminFieldSpec entries returned by InfraAdminService.ListResourceTypes (handler library T5/T6).

Design: docs/plans/2026-05-27-infra-admin-dynamic-design.md §FieldSpec Catalog Plan: docs/plans/2026-05-27-infra-admin-dynamic.md (Task 7a skeleton; T7b entries; T8 region/engine)

This file (T7a) provides the package skeleton: types, the FieldSpecCatalog struct, the New() constructor returning an empty catalog, and the Get / AllTypes / FreeformReason accessors. T7b fills the 13 typed-Config entries in catalog/fields.go in parallel after T7a lands.

The skeleton was split out of T7 per plan-adversarial C1: Lane A's T5 handler library imports *catalog.FieldSpecCatalog as a typed parameter, so the package + type + New() must exist before T5 compiles. Splitting T7a → T7b resolves the hidden serial dependency.

Index

Constants

View Source
const ConfigProtoPackage = "workflow.plugins.infra.v1"

ConfigProtoPackage is the fully-qualified proto package the vendored workflow-plugin-infra/internal/contracts/infra.proto declares. Used to build `config_message_fqn` references in AdminResourceTypeMetadata responses so cross-language consumers can correlate against the vendored proto descriptor.

Note the **plural** "plugins" — earlier draft code (T6 commit 1ea231fdd) used the singular "plugin" which produced FQNs that nothing on the wire matched. Per spec-reviewer T6 F2 (commit 1ea231fdd). The vendored proto at iac/admin/testdata/infra.proto:8 is authoritative for this string.

Variables

This section is empty.

Functions

func ConfigMessageFQN

func ConfigMessageFQN(typeName string) string

ConfigMessageFQN returns the fully-qualified proto message name for a given catalog type. Composition of ConfigProtoPackage + "." + ConfigMessageShortName so both halves can be tested independently and the FQN is always consistent between catalog handler usage and the vendored-proto parity test.

Returns the empty string when typeName lacks the "infra." prefix — callers treat empty as "no FQN known" rather than emitting a malformed reference.

func ConfigMessageShortName

func ConfigMessageShortName(typeName string) string

ConfigMessageShortName maps an "infra.<snake>" type name to its proto CamelCase Config message short name (e.g. "infra.vpc" → "VPCConfig"). Single-sourced here so the T9 vendored-proto parity test and the T6 handler library cannot drift on acronym preservation — earlier T6 code reimplemented snake→PascalCase without the acronym table and produced "VpcConfig", which doesn't exist in the proto. Per spec-reviewer T6 F2.

Special-case acronym preservations (VPC, K8S, DNS, IAM, API) avoid degenerate `Vpc` ⇆ `VPC` toggling. The set is closed at 13 entries today (the design's typed-Config inventory); new acronyms in future Configs require both extending this switch AND updating the catalog. The vendored-proto parity test detects misses.

func FreeformReason

func FreeformReason(typeName, fieldName string) (string, bool)

FreeformReason returns the FREEFORM_OK annotation reason for a catalog field whose Kind is "string" or "array_string". Returns ("", false) when no entry exists for {typeName, fieldName}.

The plan §Task 7b audit test enumerates every catalog entry and asserts that every Kind ∈ {"string", "array_string"} field has a non-empty reason here. The reasons table is a parallel map[typeName]map[fieldName]string populated by hand alongside the catalog entries in T7b's fields.go. Skeleton ships with an empty map so the audit test runs (and trivially passes — there are no string-kind entries yet).

Types

type EngineCatalog

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

EngineCatalog maps provider-type strings to their supported database engines. Cache engines are handled separately via a fixed catalog entry (Kind="enum" with EnumValues=[redis, memcached, valkey]) — see fields.go infra.cache.engine — because the engine matrix there is uniform across providers in v1.

The provider-type string convention matches RegionCatalog: comes from the iac.provider module's `provider:` config field ("digitalocean", "aws", "gcp", "azure", "stub").

func NewEngineCatalog

func NewEngineCatalog() *EngineCatalog

NewEngineCatalog returns the v1 local engine catalog. Coverage reflects the typed drivers shipped by each cloud provider plugin as of 2026-05-27. AWS adds dynamodb + aurora atop the common postgres/mysql/mongodb/redis set per the design table.

func (*EngineCatalog) For

func (e *EngineCatalog) For(providerType string) []string

For returns a defensive copy of catalogued engines for the given provider type, or nil when uncatalogued. Defensive copy parallels RegionCatalog.For semantics.

func (*EngineCatalog) Providers

func (e *EngineCatalog) Providers() []string

Providers returns the sorted list of catalogued provider-type keys. Symmetric with RegionCatalog.Providers.

type FieldSpec

type FieldSpec struct {
	// Name is the YAML key the form-builder submits and the typed
	// Config message field name (lower_snake_case to match proto).
	Name string

	// Label is the human-readable form-field label.
	Label string

	// Kind is one of {"enum", "enum_dynamic", "string", "number",
	// "bool", "array_string", "array_object", "object"}. The
	// freeform-audit test (T7b) enforces that every "string" /
	// "array_string" entry carries a FREEFORM_OK reason via the
	// package-level reasons map.
	Kind string

	// Required indicates whether the form must collect a value.
	Required bool

	// EnumValues is the fixed option list for Kind=="enum".
	EnumValues []string

	// EnumSource is the dynamic-options provider for
	// Kind=="enum_dynamic": one of {"providers", "regions", "sizes",
	// "engines", "resource_types", "app_contexts", "k8s-versions"}.
	// The form-builder fetches the options at render time.
	EnumSource string

	// Description is the form-field help text (shown as tooltip or
	// inline help in the new-resource UI).
	Description string

	// DefaultValue is the initial form value (string-encoded per the
	// proto's map<string, string> field_values contract).
	DefaultValue string

	// Sensitive indicates the form should render a masked input AND
	// the value MUST be excluded from any rendered preview or audit
	// log entry.
	Sensitive bool

	// ElementKind is the per-element Kind for array_* entries.
	ElementKind string

	// MinCount + MaxCount bound array_* entry counts.
	MinCount int32
	MaxCount int32

	// DependsOnField filters this field's enum_dynamic options by the
	// value picked for another field (e.g. region options depend on
	// the chosen provider).
	DependsOnField string
}

FieldSpec describes one field of a typed `infra.*` Config so the new-resource form-builder UI can render the right input control. Mirrors workflow.iac.v1.AdminFieldSpec in iac/admin/proto/ infra_admin.proto field-for-field so the handler library (T5/T6) can copy between the two without coercion. See the proto file for the per-field semantics documentation; this struct's tags double as the wire-rename contract for any future protojson-friendly serialization.

type FieldSpecCatalog

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

FieldSpecCatalog is the hand-maintained registry mapping resource type names (e.g. "infra.vpc") to their per-field specs. The handler library (T5/T6) holds one instance for the lifetime of the host-side infra.admin module; the catalog is read-only after New() returns.

T7a ships the catalog skeleton with an empty entries map; T7b populates the map alongside the parallel freeformReasons table.

func New

func New() *FieldSpecCatalog

New returns an empty FieldSpecCatalog. Per plan §Task 7a the skeleton catalog has zero entries so T5/T6 handler library can compile against the typed parameter while T7b fills the 13 typed-Config entries in parallel.

The returned catalog is safe for concurrent reads (Get / AllTypes never mutate state). T7b's filled catalog will populate entries at package init time (or via New() initialization) so no caller-side locking is required.

func (*FieldSpecCatalog) AllTypes

func (c *FieldSpecCatalog) AllTypes() []string

AllTypes returns the sorted list of registered resource-type names. The sort is deterministic so callers (handler library + ListResourceTypes RPC response) emit a stable ordering for snapshot tests + diff-friendly downstream consumers.

func (*FieldSpecCatalog) Get

func (c *FieldSpecCatalog) Get(typeName string) ([]FieldSpec, bool)

Get returns the field specs for typeName and ok=true when the type is registered. Returns (nil, false) for unknown types so callers can distinguish a missing-type from a registered-but-empty type (both return zero-length slices on the proto side; the boolean is the discriminator).

type RegionCatalog

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

RegionCatalog maps provider-type strings (the YAML config `provider:` field on iac.provider modules) to their supported region codes. The provider-type string comes from workflow.plugins.infra.v1.InfraResourceConfig.provider — i.e. "digitalocean", "aws", "gcp", "azure", "stub" — NOT the host module name.

func NewRegionCatalog

func NewRegionCatalog() *RegionCatalog

NewRegionCatalog returns the v1 local region catalog. Per design §FieldSpec Catalog the lists cover the regions surfaced by each provider plugin's typed driver as of 2026-05-27. Stub provider is included so unit + integration tests have deterministic options.

func (*RegionCatalog) For

func (r *RegionCatalog) For(providerType string) []string

For returns a defensive copy of the catalogued regions for the given provider type, or nil when the provider is uncatalogued. The defensive copy prevents callers from mutating the catalog (the slices are otherwise shared across invocations).

func (*RegionCatalog) Providers

func (r *RegionCatalog) Providers() []string

Providers returns the sorted list of provider-type keys this catalog knows about. Useful for tests + diagnostics; not used by the form-builder which iterates AdminProviderSummary entries.

Jump to

Keyboard shortcuts

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