dns.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dns
  2. // RecordType strongly types dns record types
  3. type RecordType int
  4. const (
  5. // RecordType_A represents a DNS RecordType_A record
  6. RecordType_A RecordType = iota
  7. // RecordType_CNAME represents a DNS RecordType_CNAME record
  8. RecordType_CNAME
  9. )
  10. // WrappedClient is an interface describing a wrapper
  11. // around a particular dns implementation
  12. type WrappedClient interface {
  13. CreateARecord(record Record) error
  14. CreateCNAMERecord(record Record) error
  15. }
  16. // Client wraps the underlying powerdns client
  17. // providing a stable api around interacting with DNS
  18. type Client struct {
  19. Client WrappedClient
  20. }
  21. // Record describes a specific DNS record to create
  22. // and can include implementation-specific attributes
  23. type Record struct {
  24. Type RecordType
  25. Name string
  26. RootDomain string
  27. Value string
  28. }
  29. // CreateRecord creates a new dns record
  30. func (c Client) CreateRecord(record Record) error {
  31. if record.Type == RecordType_A {
  32. return c.Client.CreateARecord(record)
  33. }
  34. return c.Client.CreateCNAMERecord(record)
  35. }