Documentation ¶
Overview ¶
Package dns manages DNS entries for the cluster
Index ¶
- Constants
- Variables
- func DefaultDNSProvider() (*cloudflare.Provider, error)
- func SortAddrSlice(s []netip.Addr) []netip.Addr
- func SortRecords(s []libdns.Record) []libdns.Record
- type AddrRecord
- type Host
- type Manager
- func (mgr *Manager) Add(ctx context.Context, name string, addrs ...netip.Addr) error
- func (mgr *Manager) AddHost(_ context.Context, zone string, id int, active bool, addrs ...netip.Addr) error
- func (mgr *Manager) AddRegion(_ context.Context, region string, zones ...string) error
- func (mgr *Manager) AsSyncAddr(rr libdns.Record) (SyncAddr, bool, error)
- func (mgr *Manager) GetRecords(ctx context.Context, names ...string) ([]libdns.Record, error)
- func (mgr *Manager) GetSyncRecords(ctx context.Context) ([]SyncAddrRecord, error)
- func (mgr *Manager) Show(ctx context.Context, names ...string) error
- func (mgr *Manager) Sync(ctx context.Context) error
- func (mgr *Manager) WriteTo(w io.Writer) (int64, error)
- type ManagerOption
- type Provider
- type SyncAddr
- type SyncAddrRecord
- type Zone
Constants ¶
const ( // CloudflareAPIToken is the environment variable // containing the API Token CloudflareAPIToken = "CLOUDFLARE_DNS_API_TOKEN" )
Variables ¶
var ( // ErrNoDNSProvider indicates a [libdns.Provider] wasn't assigned // to the [Manager] ErrNoDNSProvider = errors.New("dns provider not specified") // ErrNoDomain indicates a domain wasn't specified ErrNoDomain = errors.New("domain not specified") )
Functions ¶
func DefaultDNSProvider ¶
func DefaultDNSProvider() (*cloudflare.Provider, error)
DefaultDNSProvider returns a cloudflare DNS provider using an API Token from env CloudflareAPIToken
func SortAddrSlice ¶
SortAddrSlice sorts a slice of netip.Addr
func SortRecords ¶ added in v0.6.10
SortRecords sorts a slice of libdns.Record, by Name, Type and Value
Types ¶
type AddrRecord ¶
AddrRecord represents an A or AAAA record
func SortAddrRecords ¶
func SortAddrRecords(s []AddrRecord) []AddrRecord
SortAddrRecords sorts a slice of AddrRecord by Name and Address
func (*AddrRecord) Export ¶
func (rr *AddrRecord) Export() []libdns.Record
Export converts the record into libdns.Record
func (*AddrRecord) String ¶
func (rr *AddrRecord) String() string
String converts the record into BIND entries
type Host ¶
type Host struct { ID int Active bool Addrs []netip.Addr // contains filtered or unexported fields }
Host represents a member of the cluster
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a DNS Manager instance
func NewManager ¶
func NewManager(opts ...ManagerOption) (*Manager, error)
NewManager creates a DNS manager with the
func (*Manager) AddHost ¶
func (mgr *Manager) AddHost(_ context.Context, zone string, id int, active bool, addrs ...netip.Addr) error
AddHost registers a host
func (*Manager) AsSyncAddr ¶ added in v0.6.7
AsSyncAddr converts a A or AAAA libdns.Record into a SyncAddr
func (*Manager) GetRecords ¶ added in v0.6.7
GetRecords pulls all the address records on DNS for our domain, optionally only those matching the given names.
func (*Manager) GetSyncRecords ¶ added in v0.6.9
func (mgr *Manager) GetSyncRecords(ctx context.Context) ([]SyncAddrRecord, error)
GetSyncRecords pulls all the address records on DNS for our domain
type ManagerOption ¶
ManagerOption configures a Manager
func WithDomain ¶
func WithDomain(domain string) ManagerOption
WithDomain specifies where the manager operates
func WithLogger ¶
func WithLogger(log slog.Logger) ManagerOption
WithLogger attaches a logger to the Manager
func WithProvider ¶
func WithProvider(p Provider) ManagerOption
WithProvider attaches a libdns Provider to the Manager
type Provider ¶
type Provider interface { libdns.RecordGetter libdns.RecordDeleter libdns.RecordSetter libdns.RecordAppender }
Provider manages DNS entries
type SyncAddr ¶ added in v0.6.7
SyncAddr extends netip.Addr with ID and TTL fetched from the Provider
func AppendSyncAddr ¶ added in v0.6.10
AppendSyncAddr appends a netip.Addr to a SyncAddr slice if the address is new.
func SortSyncAddrSlice ¶ added in v0.6.7
SortSyncAddrSlice sorts a slice of SyncAddr by its address
type SyncAddrRecord ¶ added in v0.6.7
SyncAddrRecord is similar to AddrRecord but include libdns.Record details fetched from the Provider