Added comments
This commit is contained in:
@ -2,6 +2,7 @@ package dns_manager
|
|||||||
|
|
||||||
type RecordType string
|
type RecordType string
|
||||||
|
|
||||||
|
// Defining supported record types
|
||||||
const (
|
const (
|
||||||
None RecordType = "None essential"
|
None RecordType = "None essential"
|
||||||
A RecordType = "A"
|
A RecordType = "A"
|
||||||
@ -11,6 +12,8 @@ const (
|
|||||||
TXT RecordType = "TXT"
|
TXT RecordType = "TXT"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// This is the DNS record structure.
|
||||||
|
// Ready to be marshaled into JSON
|
||||||
type Record struct {
|
type Record struct {
|
||||||
Type RecordType `json:"type,omitempty"`
|
Type RecordType `json:"type,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
@ -18,6 +21,15 @@ type Record struct {
|
|||||||
TTL uint `json:"ttl,omitempty"`
|
TTL uint `json:"ttl,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is representation of simple API response
|
||||||
|
// to driver query
|
||||||
|
type Response struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// The core of library<->drivers architecture
|
||||||
|
// All drivers must implement those methods
|
||||||
type Actions interface {
|
type Actions interface {
|
||||||
AddRecord(*Record) (*Response, error)
|
AddRecord(*Record) (*Response, error)
|
||||||
DeleteRecord(*Record) (*Response, error)
|
DeleteRecord(*Record) (*Response, error)
|
||||||
@ -25,15 +37,15 @@ type Actions interface {
|
|||||||
GetRecords() ([]*Record, error)
|
GetRecords() ([]*Record, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is local scope interface that defines
|
||||||
|
// method New() which must be implemented by all
|
||||||
|
// libraries. The New() represents fabric method.
|
||||||
type manager interface {
|
type manager interface {
|
||||||
New() (Actions, error)
|
New() (Actions, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Response struct {
|
// Naive method that checks if record type is
|
||||||
Error string `json:"error"`
|
// supported by this library.
|
||||||
Message string `json:"message"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rt RecordType) Check() bool {
|
func (rt RecordType) Check() bool {
|
||||||
switch rt {
|
switch rt {
|
||||||
case None, A, AAAA, MX, CNAME, TXT:
|
case None, A, AAAA, MX, CNAME, TXT:
|
||||||
|
Reference in New Issue
Block a user