Documentation
¶
Index ¶
- func AuditRecords(dType string, rcs models.Records) []error
- func CanonicalName(name string) string
- func EndToNative(observer ConversionObserver, function string, before ConversionSnapshot, ...)
- func EndToRC(observer ConversionObserver, function string, before ConversionSnapshot, ...)
- func Finalize() error
- func GetDefaultTTL(providerName string) uint32
- func RecordTypeSupported(pType string, typeNum uint16, label string) bool
- func Register[T InitializableProvider](name string, definition Definition)
- type ConversionObserver
- type ConversionSnapshot
- type CreateOption
- type CreateOptions
- type CredsField
- type DNSServiceProvider
- type Definition
- type DocumentationNote
- type InitializableProvider
- type Initializer
- type None
- type ProviderKind
- type RecordAuditor
- type RecordIdentityFunc
- type Registrar
- type ZoneCreator
- type ZoneLister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuditRecords ¶
AuditRecords calls the RecordAudit function for a provider.
func CanonicalName ¶ added in v5.4.0
CanonicalName resolves a provider-type alias. Unknown names are returned unchanged so callers can retain their existing validation and diagnostics.
func EndToNative ¶
func EndToNative(observer ConversionObserver, function string, before ConversionSnapshot, records models.Records, result any, err error)
EndToNative safely completes an observation when observer may be nil.
func EndToRC ¶
func EndToRC(observer ConversionObserver, function string, before ConversionSnapshot, native any, result models.Records, err error)
EndToRC safely completes an observation when observer may be nil.
func Finalize ¶ added in v5.4.0
func Finalize() error
Finalize validates selectors against the complete record catalog. Call after package registration and before concurrent reads. The _all package does this at startup; accessors also ensure finalization for programs/tests importing individual providers.
Register and private-type registration invalidate the result. Tests adding either must finish registration before reading again. Repeated calls without registrations do not mutate definitions. Registration concurrent with reads remains unsupported.
func GetDefaultTTL ¶
GetDefaultTTL returns the provider's default TTL, or 0 if not registered.
func RecordTypeSupported ¶ added in v5.5.0
RecordTypeSupported reports whether DNS provider type pType can serve a record of type typeNum at label (a short name, "@" for the apex). Unknown provider types (such as "-") are not checked and always report true.
label only matters for DS records: a provider with CanUseDSForChildren but without general DS support may publish DS records on delegated subdomains, but not at the apex. For all other types label is ignored.
func Register ¶ added in v5.4.0
func Register[T InitializableProvider](name string, definition Definition)
Register registers a concrete pointer-to-struct implementation. Invalid or conflicting declarations panic during startup, before any provider is used. Call it during package initialization, before concurrent registry reads. Registration inspects interfaces; it never calls Initialize. Supplied slices, maps, and notes must not be modified after registration.
Types ¶
type ConversionObserver ¶
type ConversionObserver interface {
BeginToRC(function string, native any) ConversionSnapshot
EndToRC(function string, before ConversionSnapshot, nativeAfter any, result models.Records, err error)
BeginToNative(function string, records models.Records) ConversionSnapshot
EndToNative(function string, before ConversionSnapshot, recordsAfter models.Records, result any, err error)
}
ConversionObserver observes the exact inputs and outputs of provider record conversions. Implementations may also verify that conversions did not mutate their inputs.
type ConversionSnapshot ¶
type ConversionSnapshot any
ConversionSnapshot is an opaque snapshot returned before a conversion and passed back after it. Its concrete type belongs to the observer.
func BeginToNative ¶
func BeginToNative(observer ConversionObserver, function string, records models.Records) ConversionSnapshot
BeginToNative safely begins an observation when observer may be nil.
func BeginToRC ¶
func BeginToRC(observer ConversionObserver, function string, native any) ConversionSnapshot
BeginToRC safely begins an observation when observer may be nil.
type CreateOption ¶
type CreateOption func(*CreateOptions)
CreateOption customizes provider construction.
func WithConversionObserver ¶
func WithConversionObserver(observer ConversionObserver) CreateOption
WithConversionObserver supplies an observer for provider record conversions.
type CreateOptions ¶
type CreateOptions struct {
ConversionObserver ConversionObserver
// RequestedRole is set by the typed factory after caller options are applied.
// It is exactly KindDNS or KindRegistrar for runtime instances.
RequestedRole ProviderKind
}
CreateOptions holds dependencies supplied while constructing a provider.
func (*CreateOptions) WithDefaults ¶ added in v5.4.0
func (options *CreateOptions) WithDefaults() CreateOptions
WithDefaults returns a copy with shared defaults applied. A nil receiver and zero-valued options are equivalent. The requested role remains unspecified unless set by a typed factory.
type CredsField ¶
type CredsField struct {
// Key is the exact name of the field as it should appear inside the
// creds.json provider entry (for example "apitoken" or "KeyId").
Key string
// Label is the human readable text shown when prompting.
Label string
// Help is a short sentence explaining the field.
Help string
// Secret masks the input when prompting. Ignored when Multiline is
// also set, since the external editor does not mask input.
Secret bool
// Multiline opens the user's $EDITOR so values like PEM blocks with
// embedded newlines can be entered in full.
Multiline bool
// Required makes the init command reject an empty value.
Required bool
// Default suggests a value. Presented as the pre filled answer.
Default string
// EnvVar, when set, is used as the default if the environment variable is
// present. It overrides Default.
EnvVar string
// Choices restricts input to one of the listed values.
Choices []string
// ConfirmValue asks a yes/no question and stores this value on yes.
ConfirmValue string
// Validator can reject an entered value with an explanatory error.
Validator func(string) error
// Internal marks the field as a UI selector whose answer drives
// ShowIf logic on later fields. Internal answers are not written to
// creds.json.
//
// Convention: prefix the Key with an underscore (for example
// "_authMethod") so it is visually distinct from real creds.json
// keys when reading metadata registrations.
Internal bool
// ShowIf restricts when this field is shown. Each entry maps an
// earlier field's Key to the value that must be selected for this
// field to appear. An empty map means always show.
ShowIf map[string]string
}
CredsField describes a single key/value pair that belongs in the provider entry inside creds.json.
type DNSServiceProvider ¶
type DNSServiceProvider interface {
models.DNSProvider
}
DNSServiceProvider is able to generate a set of corrections that need to be made to correct records for a domain. Implement this only if the provider is a DNS Service Provider (can update records in a DNS zone).
func CreateDNSProvider ¶
func CreateDNSProvider(providerTypeName string, config map[string]string, meta json.RawMessage, opts ...CreateOption) (DNSServiceProvider, error)
CreateDNSProvider initializes a dns provider instance from given credentials.
type Definition ¶ added in v5.4.0
type Definition struct {
// FriendlyName is the brand name ("Google", not "GCLOUD")
FriendlyName string
// Maintainer is the github username of the maintainer.
Maintainer string
// Aliases (optional) is an optional list of aliases. For example, if
// we rename CLOUDFLAREAPI to CLOUDFLARE, we would make CLOUDFLAREAPI an alias to
// support legacy configurations.
Aliases []string
// SupportedTypes is an exhaustive, required declaration of record support.
// List Basic8 (A, AAAA, CAA, CNAME, MX, NS, SRV, TXT) explicitly when
// supported. A non-nil empty slice declares no record support. Nil still
// resolves to Basic8 for compatibility, but provider registrations must
// supply a list. Entries may use TYPE:Status:Reason
// to attach a comment to Can, Cannot, or Unimplemented status. A trailing
// ": http(s)://..." in Reason supplies a link.
// Internal commands such as IMPORT_TRANSFORM do not belong in this list.
SupportedTypes []string
// OfficiallySupported documents if the provider has official support.
// Omit it for the default, Cannot() without a reason.
OfficiallySupported *DocumentationNote
// DefaultTTL (optional) minimum TTL when `get-zone` writes .js files
DefaultTTL uint32
// CanAutoDNSSEC defaults to Cannot(). Declare Can() or Unimplemented()
// to document a different status, or Cannot(reason) to explain the default.
CanAutoDNSSEC *DocumentationNote
// CanConcur defaults to Can(). Declare Cannot() for providers that must
// not be used concurrently. Unimplemented() is invalid for this field.
CanConcur *DocumentationNote
// CanDualHost defaults to Can(). Declare Cannot() or Unimplemented()
// when the provider cannot manage apex NS records for dual hosting, or
// Can(reason) to explain support that needs qualification.
CanDualHost *DocumentationNote
// CanUseDSForChildren defaults to no child-DS support unless SupportedTypes
// grants general DS support, which also grants child-DS support.
CanUseDSForChildren *DocumentationNote
// Interface discovery sets the capabilities; these reasons explain the result.
CanGetZonesReason string
CreateDomainsReason string
// RecordIdentity optionally distinguishes records with the same label,
// type, and RDATA when the provider stores them as separate objects.
RecordIdentity RecordIdentityFunc
// CredFields is a description of the creds.json fields for this provider. Used by "init".
CredFields []CredsField
// DocsURL optionally overrides https://docs.dnscontrol.org/provider/<lowercase name>
// for legacy documentation paths. An override matching the default is an error.
// Register fills an empty value with the default URL.
DocsURL string
// VendorAPIDocURL optionally links to the vendor's API documentation.
VendorAPIDocURL string
// PortalURL points to where a user can obtain API credentials.
PortalURL string
// Notes is optional onboarding text shown before prompting for credentials.
Notes string
// PostWrite prepares local resources after the wizard writes creds.json.
PostWrite func(map[string]string) error
// Calculated by Register and Finalize. Providers must leave these fields unset.
TypeName string // ex. "BIND"
ImplementationType reflect.Type
Initializer Initializer // Function called to initialize a client
Kind ProviderKind // Are we initializing a REgistrar or DNS Provider?
RecordAuditor RecordAuditor
CanGetZones bool
DocCreateDomains bool
// contains filtered or unexported fields
}
Definition describes a provider implementation, never a configured account. providers.Register is the main entry point. It registers the provider, generates the derived fields, and cross-checks for errors. Definitions and their nested metadata are read-only to callers. Framework finalization validates type selectors before concurrent reads.
func AllDefinitions ¶ added in v5.4.0
func AllDefinitions() []*Definition
AllDefinitions returns canonical definitions sorted by TypeName. The returned pointers and their nested metadata must be treated as read-only.
func GetDefinition ¶ added in v5.4.0
func GetDefinition(name string) (*Definition, bool)
GetDefinition returns the stored provider definition. Canonical names and aliases return the same pointer. The definition and its nested metadata must be treated as read-only.
func (*Definition) RecordTypeSupport ¶ added in v5.4.0
func (d *Definition) RecordTypeSupport(name string) DocumentationNote
RecordTypeSupport returns the effective status and annotation. Unknown types are unsupported, including when '*' is declared.
type DocumentationNote ¶
DocumentationNote is a way for providers to give more detail about what features they support.
func Can ¶
func Can(comments ...string) *DocumentationNote
Can is a small helper for concisely creating Documentation Notes comments are variadic for easy omission. First is comment, second is link, the rest are ignored.
func Cannot ¶
func Cannot(comments ...string) *DocumentationNote
Cannot is a small helper for concisely creating Documentation Notes comments are variadic for easy omission. First is comment, second is link, the rest are ignored.
func Unimplemented ¶
func Unimplemented(comments ...string) *DocumentationNote
Unimplemented is a small helper for concisely creating Documentation Notes comments are variadic for easy omission. First is comment, second is link, the rest are ignored.
type InitializableProvider ¶ added in v5.4.0
type InitializableProvider interface {
Initialize(map[string]string, json.RawMessage, *CreateOptions) error
}
InitializableProvider initializes a fresh provider instance. Implementations must populate the receiver, not replace it with a shared instance.
type Initializer ¶ added in v5.4.0
type Initializer func(map[string]string, json.RawMessage, *CreateOptions) (any, error)
Initializer allocates and initializes a fresh instance, returning nil on error.
type None ¶
type None struct{}
None is a basic provider type that does absolutely nothing. Can be useful as a placeholder for third parties or unimplemented providers.
func (None) GetRegistrarCorrections ¶
func (n None) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error)
GetRegistrarCorrections returns corrections to update registrars.
func (*None) Initialize ¶ added in v5.4.0
func (*None) Initialize(map[string]string, json.RawMessage, *CreateOptions) error
Initialize needs no credentials or setup for the placeholder registrar.
type ProviderKind ¶
type ProviderKind uint8
ProviderKind is a bitmask describing the capabilities a provider offers from the perspective of the DNSControl configuration.
const ( // KindDNS marks a provider that can host DNS records. KindDNS ProviderKind = 1 << iota // KindRegistrar marks a provider that can act as a domain registrar. KindRegistrar )
func (ProviderKind) Has ¶
func (kind ProviderKind) Has(other ProviderKind) bool
Has reports whether the given kind bit is set.
type RecordAuditor ¶
RecordAuditor is a function that verifies that all the records are supportable by this provider. It returns a list of errors detailing records that this provider can not support.
type RecordIdentityFunc ¶ added in v5.2.0
type RecordIdentityFunc func(*models.RecordConfig) string
RecordIdentityFunc returns the identity text of a record: text that distinguishes two records which share a label, rType and RDATA but are stored by the provider as separate objects (DNSPod record lines, Route 53 routing policies). Validation uses it for duplicate detection, and validation runs before the provider has read the zone, so the function must depend only on the record it is given.
func GetRecordIdentity ¶ added in v5.2.0
func GetRecordIdentity(dType string) RecordIdentityFunc
GetRecordIdentity returns the provider's RecordIdentity function, or nil if the provider does not declare one.
type Registrar ¶
Registrar is an interface for a domain registrar. It can return a list of needed corrections to be applied in the future. Implement this only if the provider is a "registrar" (i.e. can update the NS records of the parent to a domain).
func CreateRegistrar ¶
func CreateRegistrar(rType string, config map[string]string, opts ...CreateOption) (Registrar, error)
CreateRegistrar initializes a registrar instance from given credentials.
type ZoneCreator ¶
type ZoneCreator interface {
EnsureZoneExists(dc *models.DomainConfig) error
}
ZoneCreator should be implemented by providers that have the ability to create zones (used for automatically creating zones if they don't exist).
type ZoneLister ¶
ZoneLister should be implemented by providers that have the ability to list the zones they manage. This facilitates using the "get-zones" command for "all" zones.