Documentation
¶
Overview ¶
Package providers holds DNS providers and interface for works with its.
Index ¶
- Constants
- Variables
- func GetDisplayName(providerType string, customDisplayName string) string
- type Provider
- type ProviderConfigError
- type ProviderCreationError
- type ProviderCredentialsError
- type ProviderError
- type ProviderFactory
- type ProviderNotFoundError
- type ProviderRegistry
- type ProviderTypeNotSupportedError
- type Repo
Constants ¶
const ( TypeCloudflare = "cloudflare" TypeRegRu = "regru" )
Provider type constants
Variables ¶
var DefaultDisplayNames = map[string]string{ TypeCloudflare: "Cloudflare", TypeRegRu: "RegRu", }
DefaultDisplayNames contains default display names for provider types.
Functions ¶
func GetDisplayName ¶ added in v0.99.1
GetDisplayName returns the display name for a provider type. If a custom display name is provided, it takes precedence.
Types ¶
type Provider ¶
type Provider interface {
// AddRR creates a new DNS resource record for a given zone.
AddRR(ctx context.Context, zone string, params models.CreateDNSRecordParams) (models.DNSRecord, error)
// DeleteRR deletes a DNS resource record from a given zone.
DeleteRR(ctx context.Context, zone string, rr models.DNSRecord) error
// GetRRByName returns a single DNS resource record for the given zone & record identifiers.
GetRRByName(ctx context.Context, zone, name string) (models.DNSRecord, error)
// ListZones lists the zones on an account.
ListZones(ctx context.Context) ([]models.Zone, error)
// ListZonesByName lists the zone in an account using the zone name for filtering.
ListZonesByName(ctx context.Context, name string) ([]models.Zone, error)
// ListRecords returns a slice of DNS records for the given zone name.
ListRecords(ctx context.Context, params models.ListDNSRecordsParams) ([]models.DNSRecord, error)
// ListRecordsByZoneID returns a slice of DNS records for the given zone identifier.
ListRecordsByZoneID(ctx context.Context, id string, params models.ListDNSRecordsParams) ([]models.DNSRecord, error)
// UpdateRR updates and returns an existing DNS resource record.
UpdateRR(ctx context.Context, zone string, rr models.DNSRecord) (models.DNSRecord, error)
}
Provider exposes methods for manage DNS.
type ProviderConfigError ¶
type ProviderConfigError struct {
ProviderName string
ProviderType string
Field string
Message string
Cause error
}
ProviderConfigError indicates a configuration error for a provider.
func NewProviderConfigError ¶
func NewProviderConfigError(name, providerType, field, message string, cause error) *ProviderConfigError
NewProviderConfigError creates a new ProviderConfigError.
func (*ProviderConfigError) Error ¶
func (e *ProviderConfigError) Error() string
Error implements the error interface.
func (*ProviderConfigError) Unwrap ¶
func (e *ProviderConfigError) Unwrap() error
Unwrap returns the underlying error.
type ProviderCreationError ¶
type ProviderCreationError struct {
ProviderName string
ProviderType string
Message string
Cause error
}
ProviderCreationError indicates that a provider could not be created.
func NewProviderCreationError ¶
func NewProviderCreationError(name, providerType, message string, cause error) *ProviderCreationError
NewProviderCreationError creates a new ProviderCreationError.
func (*ProviderCreationError) Error ¶
func (e *ProviderCreationError) Error() string
Error implements the error interface.
func (*ProviderCreationError) Unwrap ¶
func (e *ProviderCreationError) Unwrap() error
Unwrap returns the underlying error.
type ProviderCredentialsError ¶
ProviderCredentialsError indicates an error with provider credentials.
func NewProviderCredentialsError ¶
func NewProviderCredentialsError(providerType, message string, cause error) *ProviderCredentialsError
NewProviderCredentialsError creates a new ProviderCredentialsError.
func (*ProviderCredentialsError) Error ¶
func (e *ProviderCredentialsError) Error() string
Error implements the error interface.
func (*ProviderCredentialsError) Unwrap ¶
func (e *ProviderCredentialsError) Unwrap() error
Unwrap returns the underlying error.
type ProviderError ¶
ProviderError represents a provider-related error.
func (*ProviderError) Error ¶
func (e *ProviderError) Error() string
Error implements the error interface.
func (*ProviderError) Unwrap ¶
func (e *ProviderError) Unwrap() error
Unwrap returns the underlying error.
type ProviderFactory ¶
type ProviderFactory interface {
// CreateProvider creates a new provider instance from the given configuration.
CreateProvider(cfg *config.ProviderConfig) (Provider, error)
// Type returns the provider type name (e.g., "cloudflare", "route53").
Type() string
}
ProviderFactory creates a provider from configuration.
func NewCloudflareFactory ¶
func NewCloudflareFactory() ProviderFactory
NewCloudflareFactory creates a new Cloudflare provider factory.
func NewRegRuFactory ¶ added in v0.99.4
func NewRegRuFactory() ProviderFactory
NewRegRuFactory creates a new RegRu provider factory.
type ProviderNotFoundError ¶
ProviderNotFoundError indicates that a provider was not found.
func NewProviderNotFoundError ¶
func NewProviderNotFoundError(name string, available []string) *ProviderNotFoundError
NewProviderNotFoundError creates a new ProviderNotFoundError.
func (*ProviderNotFoundError) Error ¶
func (e *ProviderNotFoundError) Error() string
Error implements the error interface.
type ProviderRegistry ¶
type ProviderRegistry interface {
// Register registers a provider factory.
Register(factory ProviderFactory)
// CreateProvider creates a provider by name from the given configuration.
CreateProvider(name string, cfg *config.Config) (Provider, error)
// GetSupportedTypes returns a list of supported provider types.
GetSupportedTypes() []string
}
ProviderRegistry manages provider factories and creates providers.
func NewProviderRegistry ¶
func NewProviderRegistry() ProviderRegistry
NewProviderRegistry creates a new provider registry.
type ProviderTypeNotSupportedError ¶
ProviderTypeNotSupportedError indicates that a provider type is not supported.
func NewProviderTypeNotSupportedError ¶
func NewProviderTypeNotSupportedError(providerType string, supported []string) *ProviderTypeNotSupportedError
NewProviderTypeNotSupportedError creates a new ProviderTypeNotSupportedError.
func (*ProviderTypeNotSupportedError) Error ¶
func (e *ProviderTypeNotSupportedError) Error() string
Error implements the error interface.
type Repo ¶
type Repo interface {
GetDNSRecord(ctx context.Context, zoneID, recordID string) (models.DNSRecord, error)
CreateDNSRecord(ctx context.Context, params models.CreateDNSRecordParams) (models.DNSRecord, error)
DeleteDNSRecord(ctx context.Context, zoneID, recordID string) error
ListDNSRecords(ctx context.Context, id string) ([]models.DNSRecord, error)
ListZones(ctx context.Context, z ...string) ([]models.Zone, error)
UpdateDNSRecord(ctx context.Context, params models.UpdateDNSRecordParams) (models.DNSRecord, error)
ZoneIDByName(zoneName string) (string, error)
}
Repo repository of DNS zones and resource records.
func NewRepoCloudFlare ¶
func NewRepoCloudFlare(api *cloudflare.API) Repo
NewRepoCloudFlare creates a repository for CloudFlare provider.
func NewRepoRegRu ¶ added in v0.99.4
NewRepoRegRu creates a repository for RegRu provider.