dnser

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 3 Imported by: 0

README

dnser

Go Report Card

DNS done GitOps way

How it works

apiVersion: 1
config:
- ip: 127.0.0.1
  domain: example.org
  aliases:
  - foo.example.org:
    - bar.example.org
    - baz.example.org
  - foobar.example.org    

The configuration consists of a number of items. Each item must contain ip, domain and aliases. aliases is a list of trees.

dnser will create an A record of domain to ip. Then it will create ALIAS tree roots to domain, and then alias each tree node to their parent.

dnser will also delete all records that resolve to domain but not present in any of the aliases trees.

Usage

Go package
config := config.LoadFromString(yamlString)
r53Adapter := adapter.NewRoute53(id, secret)
records, err := r53Adapter.List(context.Background())
if err != nil {
    panic(err)
}
m := massager.Massager{
    Desired: config,
    Current: records,
}
chset := m.CalculateNeededActions()
err = r53Adapter.Process(context.Background(), chset)
if err != nil {
    panic(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type   ActionType
	Record DNSRecord
}

Action combines the action type and the DNS record.

type ActionType

type ActionType string

ActionType is the type of actions to be performed on the record: Upsert or Delete.

const (
	Upsert ActionType = "UPSERT"
	Delete ActionType = "DELETE"
)

Available Action Types

type Adapter

type Adapter interface {
	Lister
	Processor
}

Adapter combines Lister and Processor.

type DNSRecord

type DNSRecord struct {
	Alias bool

	Name   config.Domain
	Target config.Domain
}

DNSRecord contains the minimal set of data needed to represent an A DNS record.

func NewAliasRecord added in v1.1.0

func NewAliasRecord(name, target string) DNSRecord

NewAliasRecord constructs an alias DNSRecord from input strings.

func NewRecord added in v1.1.0

func NewRecord(name, target string) DNSRecord

NewRecord constructs a non-alias DNSRecord from input strings.

func (DNSRecord) NameZone added in v1.1.0

func (r DNSRecord) NameZone() config.Domain

NameZone returns the domain zone of Record's Name.

func (DNSRecord) TargetZone added in v1.1.0

func (r DNSRecord) TargetZone() config.Domain

TargetZone returns the domain zone of Record's Target.

type Lister

type Lister interface {
	// List lists all currently existing DNS records that the adapter has access to.
	List(ctx context.Context) ([]DNSRecord, error)
}

Lister implements List.

type Processor

type Processor interface {
	// Process performs the appropriate changes for each action.
	Process(ctx context.Context, actions [][]Action) error
}

Processor implements Process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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