Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type ConfigProvider
- type Handler
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) Answer(req *dns.Msg, network string) *dns.Msg
- func (b *InMemoryBackend) CreateChange(project, zone string, in *dnsapi.Change) (*dnsapi.Change, error)
- func (b *InMemoryBackend) CreatePolicy(project string, in *dnsapi.Policy) (*dnsapi.Policy, error)
- func (b *InMemoryBackend) CreateRRSet(project, zone string, in *dnsapi.ResourceRecordSet) (*dnsapi.ResourceRecordSet, error)
- func (b *InMemoryBackend) CreateResponsePolicy(project string, in *dnsapi.ResponsePolicy) (*dnsapi.ResponsePolicy, error)
- func (b *InMemoryBackend) CreateRule(project, policy string, in *dnsapi.ResponsePolicyRule) (*dnsapi.ResponsePolicyRule, error)
- func (b *InMemoryBackend) CreateZone(project string, in *dnsapi.ManagedZone) (*dnsapi.ManagedZone, error)
- func (b *InMemoryBackend) DeletePolicy(project, name string) error
- func (b *InMemoryBackend) DeleteRRSet(project, zone, name, typ string) error
- func (b *InMemoryBackend) DeleteResponsePolicy(project, name string) error
- func (b *InMemoryBackend) DeleteRule(project, policy, name string) error
- func (b *InMemoryBackend) DeleteZone(project, name string) error
- func (b *InMemoryBackend) GetChange(project, zone, id string) (*dnsapi.Change, error)
- func (b *InMemoryBackend) GetKey(project, zone, id string, digests []string) (*dnsapi.DnsKey, error)
- func (b *InMemoryBackend) GetOperation(project, zone, id string) (*dnsapi.Operation, error)
- func (b *InMemoryBackend) GetPolicy(project, name string) (*dnsapi.Policy, error)
- func (b *InMemoryBackend) GetProject(project string) *dnsapi.Project
- func (b *InMemoryBackend) GetRRSet(project, zone, name, typ string) (*dnsapi.ResourceRecordSet, error)
- func (b *InMemoryBackend) GetResponsePolicy(project, name string) (*dnsapi.ResponsePolicy, error)
- func (b *InMemoryBackend) GetRule(project, policy, name string) (*dnsapi.ResponsePolicyRule, error)
- func (b *InMemoryBackend) GetZone(project, name string) (*dnsapi.ManagedZone, error)
- func (b *InMemoryBackend) ListChanges(project, zone, sortBy, sortOrder, token string, limit int) (page.Page[*dnsapi.Change], error)
- func (b *InMemoryBackend) ListKeys(project, zone, token string, limit int, digests []string) (page.Page[*dnsapi.DnsKey], error)
- func (b *InMemoryBackend) ListOperations(project, zone, sortBy, token string, limit int) (page.Page[*dnsapi.Operation], error)
- func (b *InMemoryBackend) ListPolicies(project, token string, limit int) (page.Page[*dnsapi.Policy], error)
- func (b *InMemoryBackend) ListRRSets(project, zone, name, typ, token string, limit int) (page.Page[*dnsapi.ResourceRecordSet], error)
- func (b *InMemoryBackend) ListResponsePolicies(project, token string, limit int) (page.Page[*dnsapi.ResponsePolicy], error)
- func (b *InMemoryBackend) ListRules(project, policy, token string, limit int) (page.Page[*dnsapi.ResponsePolicyRule], error)
- func (b *InMemoryBackend) ListZones(project, dnsName, token string, limit int) (page.Page[*dnsapi.ManagedZone], error)
- func (b *InMemoryBackend) PatchRRSet(project, zone, name, typ string, patch map[string]any) (*dnsapi.ResourceRecordSet, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) UpdatePolicy(project, name string, in *dnsapi.Policy, patch map[string]any) (*dnsapi.Policy, error)
- func (b *InMemoryBackend) UpdateResponsePolicy(project, name string, in *dnsapi.ResponsePolicy, patch map[string]any) (*dnsapi.ResponsePolicy, error)
- func (b *InMemoryBackend) UpdateRule(project, policy, name string, in *dnsapi.ResponsePolicyRule, ...) (*dnsapi.ResponsePolicyRule, error)
- func (b *InMemoryBackend) UpdateZone(project, name string, in *dnsapi.ManagedZone, patch map[string]any) (*dnsapi.Operation, error)
- type Provider
- type Settings
Constants ¶
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 ¶
var ErrNilAppContext = errors.New("gcpdns: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
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 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) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns project[/zone] for metrics.
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Cloud DNS runs on its own listener.
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) 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 ¶
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) 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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the ports are bound in StartWorker.
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.