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

gcpdns

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 26 Imported by: 0

README

Cloud DNS

Parity grade: B · SDK google.golang.org/api@v0.302.0 · last audited 2026-10-25 (423518f77)

Coverage

Metric Value
Feature families 8 (2 ok, 5 partial, 1 gap)
Known gaps 5
Deferred items 0
Resource leaks clean
Known gaps
  • managedZones.getIamPolicy, setIamPolicy and testIamPermissions are not routed (404); dns/v1beta2 and dns/v2 are not served.
  • Responses are never DNSSEC-signed (no RRSIG/NSEC/NSEC3); DNSKEY private keys are discarded and DNSSEC state transfer is stored only.
  • Response policies and rules, server policies, private zones, forwarding and peering are stored but have no effect on resolution; routing policies are answered as the union of their items.
  • Error message texts (validation, containerNotEmpty, quota) and a few conditions (rrsets.* calls appearing in the change history, change completion timing, project number, non-fixed quota values) were chosen without a production reference.
  • The rrsets list filter parameter, zone cloudLoggingConfig effects (no query logs), reverse-lookup and Service Directory zones are not implemented beyond storing their configuration.

More

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the dedicated Cloud DNS REST listener's default TCP port.
	DefaultPort = 8140
	// DefaultDNSPort is the default UDP and TCP port of the authoritative DNS server.
	DefaultDNSPort = 8141
)

Variables

View Source
var ErrNilAppContext = errors.New("gcpdns: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

View Source
var ErrSnapshotNull = errors.New("gcpdns: snapshot contains a null record")

ErrSnapshotNull is returned when a snapshot holds a null record.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Reason  string
	Message string
	Status  int
}

APIError is a Google JSON REST error.

func (*APIError) Error

func (e *APIError) Error() string

Error implements error.

type ConfigProvider

type ConfigProvider interface {
	GetGCPDNSSettings() Settings
}

ConfigProvider extracts Cloud DNS configuration from the AppContext Config.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Port    int
	DNSPort int
	// contains filtered or unexported fields
}

Handler serves the Cloud DNS REST API and the authoritative DNS data plane.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a Handler; callers override Port and DNSPort from Settings.

func (*Handler) Addr

func (h *Handler) Addr() string

Addr returns the bound REST listener address, or "" before StartWorker.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns project[/zone] for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler for all Cloud DNS REST requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset removes all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Cloud DNS runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops both listeners.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the DNS server and the REST listener synchronously so a port conflict is returned.

type InMemoryBackend

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

InMemoryBackend holds all Cloud DNS state under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) Answer

func (b *InMemoryBackend) Answer(req *dns.Msg, network string) *dns.Msg

Answer builds the authoritative response to req.

func (*InMemoryBackend) CreateChange

func (b *InMemoryBackend) CreateChange(project, zone string, in *dnsapi.Change) (*dnsapi.Change, error)

CreateChange applies a change atomically; it is returned pending and reads as done afterwards.

func (*InMemoryBackend) CreatePolicy

func (b *InMemoryBackend) CreatePolicy(project string, in *dnsapi.Policy) (*dnsapi.Policy, error)

CreatePolicy stores a DNS server policy.

func (*InMemoryBackend) CreateRRSet

func (b *InMemoryBackend) CreateRRSet(
	project, zone string, in *dnsapi.ResourceRecordSet,
) (*dnsapi.ResourceRecordSet, error)

CreateRRSet adds a record set as a one-addition change.

func (*InMemoryBackend) CreateResponsePolicy

func (b *InMemoryBackend) CreateResponsePolicy(
	project string,
	in *dnsapi.ResponsePolicy,
) (*dnsapi.ResponsePolicy, error)

CreateResponsePolicy stores a response policy.

func (*InMemoryBackend) CreateRule

func (b *InMemoryBackend) CreateRule(
	project, policy string,
	in *dnsapi.ResponsePolicyRule,
) (*dnsapi.ResponsePolicyRule, error)

CreateRule stores a response policy rule.

func (*InMemoryBackend) CreateZone

func (b *InMemoryBackend) CreateZone(project string, in *dnsapi.ManagedZone) (*dnsapi.ManagedZone, error)

CreateZone validates and stores a managed zone with its default SOA and NS records.

func (*InMemoryBackend) DeletePolicy

func (b *InMemoryBackend) DeletePolicy(project, name string) error

DeletePolicy removes a policy that is not attached to any network.

func (*InMemoryBackend) DeleteRRSet

func (b *InMemoryBackend) DeleteRRSet(project, zone, name, typ string) error

DeleteRRSet removes a record set as a one-deletion change.

func (*InMemoryBackend) DeleteResponsePolicy

func (b *InMemoryBackend) DeleteResponsePolicy(project, name string) error

DeleteResponsePolicy removes a response policy with no rules and no networks.

func (*InMemoryBackend) DeleteRule

func (b *InMemoryBackend) DeleteRule(project, policy, name string) error

DeleteRule removes a rule.

func (*InMemoryBackend) DeleteZone

func (b *InMemoryBackend) DeleteZone(project, name string) error

DeleteZone removes a zone that holds only its default SOA and NS records.

func (*InMemoryBackend) GetChange

func (b *InMemoryBackend) GetChange(project, zone, id string) (*dnsapi.Change, error)

GetChange returns one change.

func (*InMemoryBackend) GetKey

func (b *InMemoryBackend) GetKey(project, zone, id string, digests []string) (*dnsapi.DnsKey, error)

GetKey returns one DNSSEC key with the requested KSK digests (sha256 by default).

func (*InMemoryBackend) GetOperation

func (b *InMemoryBackend) GetOperation(project, zone, id string) (*dnsapi.Operation, error)

GetOperation returns one zone operation.

func (*InMemoryBackend) GetPolicy

func (b *InMemoryBackend) GetPolicy(project, name string) (*dnsapi.Policy, error)

GetPolicy returns one policy.

func (*InMemoryBackend) GetProject

func (b *InMemoryBackend) GetProject(project string) *dnsapi.Project

GetProject returns the project's DNS quota block.

func (*InMemoryBackend) GetRRSet

func (b *InMemoryBackend) GetRRSet(project, zone, name, typ string) (*dnsapi.ResourceRecordSet, error)

GetRRSet returns one record set.

func (*InMemoryBackend) GetResponsePolicy

func (b *InMemoryBackend) GetResponsePolicy(project, name string) (*dnsapi.ResponsePolicy, error)

GetResponsePolicy returns one response policy.

func (*InMemoryBackend) GetRule

func (b *InMemoryBackend) GetRule(project, policy, name string) (*dnsapi.ResponsePolicyRule, error)

GetRule returns one rule.

func (*InMemoryBackend) GetZone

func (b *InMemoryBackend) GetZone(project, name string) (*dnsapi.ManagedZone, error)

GetZone returns one managed zone.

func (*InMemoryBackend) ListChanges

func (b *InMemoryBackend) ListChanges(
	project, zone, sortBy, sortOrder, token string, limit int,
) (page.Page[*dnsapi.Change], error)

ListChanges returns a page of changes ordered by sequence.

func (*InMemoryBackend) ListKeys

func (b *InMemoryBackend) ListKeys(
	project, zone, token string, limit int, digests []string,
) (page.Page[*dnsapi.DnsKey], error)

ListKeys returns a page of the zone's DNSSEC keys.

func (*InMemoryBackend) ListOperations

func (b *InMemoryBackend) ListOperations(
	project, zone, sortBy, token string, limit int,
) (page.Page[*dnsapi.Operation], error)

ListOperations returns a page of zone operations ordered by start time or id.

func (*InMemoryBackend) ListPolicies

func (b *InMemoryBackend) ListPolicies(project, token string, limit int) (page.Page[*dnsapi.Policy], error)

ListPolicies returns a page of the project's policies ordered by name.

func (*InMemoryBackend) ListRRSets

func (b *InMemoryBackend) ListRRSets(
	project, zone, name, typ, token string, limit int,
) (page.Page[*dnsapi.ResourceRecordSet], error)

ListRRSets returns a page of record sets in canonical order, optionally filtered by name and type.

func (*InMemoryBackend) ListResponsePolicies

func (b *InMemoryBackend) ListResponsePolicies(
	project, token string, limit int,
) (page.Page[*dnsapi.ResponsePolicy], error)

ListResponsePolicies returns a page of the project's response policies.

func (*InMemoryBackend) ListRules

func (b *InMemoryBackend) ListRules(
	project, policy, token string, limit int,
) (page.Page[*dnsapi.ResponsePolicyRule], error)

ListRules returns a page of a response policy's rules ordered by name.

func (*InMemoryBackend) ListZones

func (b *InMemoryBackend) ListZones(project, dnsName, token string, limit int) (page.Page[*dnsapi.ManagedZone], error)

ListZones returns a page of the project's zones ordered by name, optionally filtered by dnsName.

func (*InMemoryBackend) PatchRRSet

func (b *InMemoryBackend) PatchRRSet(
	project, zone, name, typ string, patch map[string]any,
) (*dnsapi.ResourceRecordSet, error)

PatchRRSet merges patch into an existing record set.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset removes all state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a snapshot.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state.

func (*InMemoryBackend) UpdatePolicy

func (b *InMemoryBackend) UpdatePolicy(
	project, name string, in *dnsapi.Policy, patch map[string]any,
) (*dnsapi.Policy, error)

UpdatePolicy replaces (in) or merges (patch) a policy.

func (*InMemoryBackend) UpdateResponsePolicy

func (b *InMemoryBackend) UpdateResponsePolicy(
	project, name string, in *dnsapi.ResponsePolicy, patch map[string]any,
) (*dnsapi.ResponsePolicy, error)

UpdateResponsePolicy replaces (in) or merges (patch) a response policy.

func (*InMemoryBackend) UpdateRule

func (b *InMemoryBackend) UpdateRule(
	project, policy, name string, in *dnsapi.ResponsePolicyRule, patch map[string]any,
) (*dnsapi.ResponsePolicyRule, error)

UpdateRule replaces (in) or merges (patch) a rule.

func (*InMemoryBackend) UpdateZone

func (b *InMemoryBackend) UpdateZone(
	project, name string, in *dnsapi.ManagedZone, patch map[string]any,
) (*dnsapi.Operation, error)

UpdateZone replaces the mutable fields of a zone (PUT); patch is non-nil for PATCH merge semantics.

type Provider

type Provider struct{}

Provider implements service.Provider for Google Cloud DNS. It serves the REST API and the DNS data plane on their own listeners (see Handler.StartWorker) and never matches on the shared AWS router.

func (*Provider) Init

Init creates the backend and handler; the ports are bound in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Settings

type Settings struct {
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 172-byte string literal not displayed */
	DNSPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 200-byte string literal not displayed */
}

Settings holds service-level configuration, embedded in the root CLI as CLI.GCPDNS.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider is available.

Jump to

Keyboard shortcuts

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