Help us shape the future of Go! Take the 2026 Go Developer Survey

record

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const SchemaV1 = "workflow.dns-portfolio.export.v1"

SchemaV1 is the canonical schema identifier for a dns-portfolio export.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b Record) bool

Equal reports whether two records are canonically equal, keying on (Type, Name, Value, TTL) and ignoring extra/optional fields like Priority.

func KnownType

func KnownType(t string) bool

KnownType reports whether t is a well-known DNS record type. Advisory only — unknown types are valid in a portfolio snapshot.

func Sanitize

func Sanitize(p *Portfolio)

Sanitize sets p.Sanitized = true.

Types

type Portfolio

type Portfolio struct {
	Schema    string     `json:"schema"`
	Sanitized bool       `json:"sanitized,omitempty"`
	Snapshots []Snapshot `json:"snapshots"`
}

Portfolio is the top-level export envelope for a canonical DNS catalog. Matches the "workflow.dns-portfolio.export.v1" schema used by scenario 88.

func FromResourceStates

func FromResourceStates(states []interfaces.ResourceState) Portfolio

FromResourceStates converts imported IaC state into a canonical Portfolio. Reads each infra.dns ResourceState's records (Outputs preferred, else AppliedConfig), renaming provider-specific value keys to the canonical "value". If an infra.dns state includes provider-supplied authority metadata in Outputs["authority"], safe keys are copied into Snapshot.Authority. Each infra.dns_delegation state populates Snapshot.Authority for the matching domain from safe Outputs["authority"] keys, plus top-level registrar_nameservers and live_nameservers values when present. States of other types are silently skipped.

Snapshots are grouped by (Provider, Domain) so that infra.dns and infra.dns_delegation states for the same domain are merged into one Snapshot. Output is sorted by (Provider, Domain) for deterministic order.

Provider value-key divergence (verified against provider drivers):

  • DigitalOcean + Cloudflare emit "data"
  • Hover emits "content" (workflow-plugin-hover/internal/drivers/dns.go:538)
  • Namecheap emits "address"

The valueAlias helper resolves the first non-empty of: data → content → address → value.

func (*Portfolio) Validate

func (p *Portfolio) Validate() error

Validate enforces structural invariants on the Portfolio. It does NOT whitelist record types — unknown types (PTR, HTTPS, SVCB, …) are preserved. Only empty type and negative TTL are rejected.

type Record

type Record struct {
	Type      string `json:"type"`
	Name      string `json:"name"`
	Value     string `json:"value"`
	TTL       int    `json:"ttl"`
	Priority  *int   `json:"priority,omitempty"`
	Port      *int   `json:"port,omitempty"`
	Weight    *int   `json:"weight,omitempty"`
	Flags     *int   `json:"flags,omitempty"`
	Tag       string `json:"tag,omitempty"`
	Proxied   *bool  `json:"proxied,omitempty"`
	Proxiable *bool  `json:"proxiable,omitempty"`
}

Record is the canonical, provider-neutral DNS record type. The Value field uses json:"value" to match scenario-88's fixture shape (fixture records use "value", NOT "data").

knownTypes is advisory only — a portfolio is a SNAPSHOT of whatever the provider returns, so unknown/newer types (PTR, HTTPS, SVCB, TLSA, DNAME, …) MUST be preserved, never rejected. KnownType drives an optional warning only.

type Snapshot

type Snapshot struct {
	ID        string         `json:"id"`
	Provider  string         `json:"provider"`
	Domain    string         `json:"domain"`
	Authority map[string]any `json:"authority,omitempty"`
	Records   []Record       `json:"records"`
	Extra     map[string]any `json:"extra,omitempty"`
}

Snapshot is a flat representation of one DNS zone at a point in time. One snapshot == one zone (matches scenario-88 fixture shape: flat, no zones[]).

Jump to

Keyboard shortcuts

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