models

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_SCOPE     = "default"
	DEFAULT_PATH      = ""
	DEFAULT_EXTENSION = "yaml"
)

Variables

View Source
var (
	SubdomainNotFoundError      = errors.New("subdomain not found in zone")
	SubdomainAlreadyExistsError = errors.New("subdomain already exists in zone")

	TypeNotFoundError      = errors.New("record type not found in subdomain")
	TypeAlreadyExistsError = errors.New("record type already exists in subdomain")

	ValidateNotAnIP                 = errors.New("value not validated as an IP")
	ValidateNotAnIPV4               = errors.New("value not validated as an IPV4")
	ValidateNotAnIPV6               = errors.New("value not validated as an IPV6")
	ValidateIPNotAllowed            = errors.New("an IP value is not allowed")
	ValidateFQDNRequiredTrailingDot = errors.New("fqdn value must end with a dot")
	ValidateFQDNForbidTrailingDot   = errors.New("fqdn value may not end with a dot")
	ValidateNotAFQDN                = errors.New("value not validated as a fqdn")
)

Functions

func RefFloat64 added in v0.1.0

func RefFloat64(value float64) *float64

func RefInt added in v0.1.0

func RefInt(value int) *int

func RefString added in v0.1.0

func RefString(value string) *string

func RefStringAsFloat64 added in v0.1.0

func RefStringAsFloat64(value string) *float64

func RefStringAsInt added in v0.1.0

func RefStringAsInt(value string) *int

Types

type BaseRecord

type BaseRecord struct {
	RecordChild  *yaml.Node `yaml:"-"`
	RecordNode   *yaml.Node `yaml:"-"`
	RecordParent *yaml.Node `yaml:"-"`
	IsDeleted    bool       `yaml:"-"`
	Name         string
	Type         string
	Values       []RecordValue `yaml:"values" line_comment:"Enable or disable."`
	TTL          int
	Terraform    Terraform
	Octodns      OctodnsRecordConfig
}

type GitClient

type GitClient interface {
	AddScope(name, path, branch, ext string) error
	SetScope(name, path, branch, ext string) error
	GetZone(zone, scope string) (*Zone, error)
	SetBranch(branch string) error
	SetAuthor(name, email string) error
}

func NewGitHubClient

func NewGitHubClient(accessToken, owner, repo string) (GitClient, error)

type GitHubClient

type GitHubClient struct {
	*github.Client
	Owner       string
	Repo        string
	Scopes      map[string]Scope
	Counter     int
	Zones       map[string]*Zone
	Mutex       sync.RWMutex
	Branch      string
	AuthorName  string
	AuthorEmail string
}

func (*GitHubClient) AddScope

func (g *GitHubClient) AddScope(name, path, branch, ext string) error

func (*GitHubClient) GetScope

func (g *GitHubClient) GetScope(name string) (scope Scope, err error)

func (*GitHubClient) GetZone

func (g *GitHubClient) GetZone(zone, scope string) (*Zone, error)

func (*GitHubClient) SaveZone

func (g *GitHubClient) SaveZone(zone *Zone, comment string) error

func (*GitHubClient) SetAuthor

func (g *GitHubClient) SetAuthor(name, email string) error

func (*GitHubClient) SetBranch

func (g *GitHubClient) SetBranch(branch string) error

func (*GitHubClient) SetScope

func (g *GitHubClient) SetScope(name, path, branch, ext string) error

type OctodnsAzureDNS

type OctodnsAzureDNS struct {
	Healthcheck OctodnsAzureDNSHealthcheck `yaml:",omitempty"`
}

type OctodnsAzureDNSHealthcheck

type OctodnsAzureDNSHealthcheck struct {
	Interval    int `yaml:",omitempty"`
	Timeout     int `yaml:",omitempty"`
	NumFailures int `yaml:",omitempty"`
}

type OctodnsCloudflare

type OctodnsCloudflare struct {
	Proxied bool `yaml:",omitempty"`
	AutoTTL bool `yaml:",omitempty"`
}

type OctodnsRecordConfig

type OctodnsRecordConfig struct {
	Cloudflare *OctodnsCloudflare `yaml:",omitempty"`
	AzureDNS   *OctodnsAzureDNS   `yaml:",omitempty"`
}

type RType

type RType struct {
	// contains filtered or unexported fields
}
var (
	TYPE_A      RType = RType{/* contains filtered or unexported fields */}
	TYPE_AAAA   RType = RType{/* contains filtered or unexported fields */}
	TYPE_CAA    RType = RType{/* contains filtered or unexported fields */}
	TYPE_CNAME  RType = RType{/* contains filtered or unexported fields */}
	TYPE_DNAME  RType = RType{/* contains filtered or unexported fields */}
	TYPE_LOC    RType = RType{/* contains filtered or unexported fields */}
	TYPE_MX     RType = RType{/* contains filtered or unexported fields */}
	TYPE_NAPTR  RType = RType{/* contains filtered or unexported fields */}
	TYPE_NS     RType = RType{/* contains filtered or unexported fields */}
	TYPE_PTR    RType = RType{/* contains filtered or unexported fields */}
	TYPE_SPF    RType = RType{/* contains filtered or unexported fields */}
	TYPE_SRV    RType = RType{/* contains filtered or unexported fields */}
	TYPE_SSHFP  RType = RType{/* contains filtered or unexported fields */}
	TYPE_TXT    RType = RType{/* contains filtered or unexported fields */}
	TYPE_URLFWD RType = RType{/* contains filtered or unexported fields */}

	TYPES = map[string]RType{
		TYPE_A.String():      TYPE_A,
		TYPE_AAAA.String():   TYPE_AAAA,
		TYPE_CAA.String():    TYPE_CAA,
		TYPE_CNAME.String():  TYPE_CNAME,
		TYPE_DNAME.String():  TYPE_DNAME,
		TYPE_LOC.String():    TYPE_LOC,
		TYPE_MX.String():     TYPE_MX,
		TYPE_NAPTR.String():  TYPE_NAPTR,
		TYPE_NS.String():     TYPE_NS,
		TYPE_PTR.String():    TYPE_PTR,
		TYPE_SPF.String():    TYPE_SPF,
		TYPE_SRV.String():    TYPE_SRV,
		TYPE_SSHFP.String():  TYPE_SSHFP,
		TYPE_TXT.String():    TYPE_TXT,
		TYPE_URLFWD.String(): TYPE_URLFWD,
	}
)

func (RType) IsEnabled

func (r RType) IsEnabled() bool

func (RType) LowerString

func (r RType) LowerString() string

func (RType) String

func (r RType) String() string

type Record

type Record struct {
	BaseRecord
	Values []RecordValue `yaml:"values" line_comment:"Enable or disable."`
}

func (*Record) AddType

func (r *Record) AddType(record Record) error

func (*Record) AddValueFromString

func (r *Record) AddValueFromString(valueString string) error

func (*Record) ClearValues

func (r *Record) ClearValues()

func (Record) MarshalYAML

func (r Record) MarshalYAML() (interface{}, error)

func (*Record) UnmarshalYAML

func (r *Record) UnmarshalYAML(
	value *yaml.Node,
) error

func (*Record) UpdateYaml

func (r *Record) UpdateYaml() error

func (*Record) ValuesAsString

func (r *Record) ValuesAsString() []string

type RecordValue

type RecordValue struct {
	// contains filtered or unexported fields
}

func (RecordValue) MarshalYAML

func (r RecordValue) MarshalYAML() (interface{}, error)

func (*RecordValue) String

func (r *RecordValue) String() string

func (*RecordValue) StringCAA added in v0.1.0

func (r *RecordValue) StringCAA() string

func (*RecordValue) StringLOC added in v0.1.0

func (r *RecordValue) StringLOC() string

func (*RecordValue) StringMX

func (r *RecordValue) StringMX() string

func (*RecordValue) StringNAPTR added in v0.1.0

func (r *RecordValue) StringNAPTR() string

func (*RecordValue) StringSRV

func (r *RecordValue) StringSRV() string

func (*RecordValue) StringSSHFP added in v0.1.0

func (r *RecordValue) StringSSHFP() string

func (*RecordValue) StringURLFWD added in v0.1.0

func (r *RecordValue) StringURLFWD() string

func (*RecordValue) UnmarshalString added in v0.1.0

func (r *RecordValue) UnmarshalString(value string) error

func (*RecordValue) UnmarshalStringA added in v0.1.0

func (r *RecordValue) UnmarshalStringA(value string) error

func (*RecordValue) UnmarshalStringAAAA added in v0.1.0

func (r *RecordValue) UnmarshalStringAAAA(value string) error

func (*RecordValue) UnmarshalStringCAA added in v0.1.0

func (r *RecordValue) UnmarshalStringCAA(value string) error

func (*RecordValue) UnmarshalStringFQDN added in v0.1.0

func (r *RecordValue) UnmarshalStringFQDN(value string) error

func (*RecordValue) UnmarshalStringLOC added in v0.1.0

func (r *RecordValue) UnmarshalStringLOC(value string) error

func (*RecordValue) UnmarshalStringMX added in v0.1.0

func (r *RecordValue) UnmarshalStringMX(value string) error

func (*RecordValue) UnmarshalStringNAPTR added in v0.1.0

func (r *RecordValue) UnmarshalStringNAPTR(value string) error

func (*RecordValue) UnmarshalStringNS added in v0.1.0

func (r *RecordValue) UnmarshalStringNS(value string) error

func (*RecordValue) UnmarshalStringPTR added in v0.1.0

func (r *RecordValue) UnmarshalStringPTR(value string) error

func (*RecordValue) UnmarshalStringSPF added in v0.1.0

func (r *RecordValue) UnmarshalStringSPF(value string) error

func (*RecordValue) UnmarshalStringSRV added in v0.1.0

func (r *RecordValue) UnmarshalStringSRV(value string) error

func (*RecordValue) UnmarshalStringSSHFP added in v0.1.0

func (r *RecordValue) UnmarshalStringSSHFP(value string) error

func (*RecordValue) UnmarshalStringURLFWD added in v0.1.0

func (r *RecordValue) UnmarshalStringURLFWD(value string) error

func (*RecordValue) UnmarshalYAML

func (r *RecordValue) UnmarshalYAML(
	value *yaml.Node,
) error

type Scope

type Scope struct {
	Name   string
	Path   string
	Branch string
	Ext    string
}

func NewScope added in v0.1.0

func NewScope(name, path, branch, ext string) Scope

func (*Scope) CreateFilePath

func (s *Scope) CreateFilePath(zone string) string

func (*Scope) GetBranch

func (s *Scope) GetBranch(fallback string) string

type Subdomain

type Subdomain struct {
	Name string

	ContentNode *yaml.Node
	Types       map[string]*Record
	// contains filtered or unexported fields
}

func (*Subdomain) CreateType

func (r *Subdomain) CreateType(rtype string) (record *Record, err error)

func (*Subdomain) DeleteType

func (r *Subdomain) DeleteType(rtype string) (err error)

func (*Subdomain) FindAllType

func (r *Subdomain) FindAllType() error

func (*Subdomain) GetType

func (r *Subdomain) GetType(rtype string) (record *Record, err error)

func (*Subdomain) SetYaml

func (r *Subdomain) SetYaml(key, content *yaml.Node)

func (*Subdomain) UpdateYaml

func (r *Subdomain) UpdateYaml() (err error)

type Terraform

type Terraform struct {
	Hash string `yaml:",omitempty"`
}

type Zone

type Zone struct {
	// contains filtered or unexported fields
}

func (*Zone) Close

func (z *Zone) Close() int

func (*Zone) CreateSubdomain

func (z *Zone) CreateSubdomain(subdomain string) (sub Subdomain, err error)

func (*Zone) DeleteSubdomain

func (z *Zone) DeleteSubdomain(subdomain string) (err error)

func (*Zone) FindRecordByType

func (z *Zone) FindRecordByType(subdomain string, rtype string) (rrecord *yaml.Node, rcontent *yaml.Node, rparent *yaml.Node, err error)

func (*Zone) FindSubdomain

func (z *Zone) FindSubdomain(subdomain string) (record Subdomain, err error)

func (*Zone) GetRecord

func (z *Zone) GetRecord(subdomain string, rtype string) (record *Record, err error)

func (*Zone) Open

func (z *Zone) Open() int

func (*Zone) ReadYaml

func (z *Zone) ReadYaml(content []byte) error

func (*Zone) ReadYamlFile

func (z *Zone) ReadYamlFile(filename string) error

func (Zone) WriteYaml

func (z Zone) WriteYaml() ([]byte, error)

func (Zone) WriteYamlToFile

func (z Zone) WriteYamlToFile(filename string) error

Jump to

Keyboard shortcuts

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