providers

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package providers holds DNS providers and interface for works with its.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

func NewProvider

func NewProvider(repo Repo) Provider

NewProvider creates a new provider.

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

type ProviderCredentialsError struct {
	ProviderType string
	Message      string
	Cause        error
}

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

type ProviderError struct {
	ProviderName string
	ProviderType string
	Message      string
	Cause        error
}

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.

type ProviderNotFoundError

type ProviderNotFoundError struct {
	ProviderName string
	Available    []string
}

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

type ProviderTypeNotSupportedError struct {
	ProviderType string
	Supported    []string
}

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

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.

Jump to

Keyboard shortcuts

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