update

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package update is responsible for updating destinations using IP

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CFOption

type CFOption func(c *CloudFlareUpdate)

CFOption allows to modify the cloudflare updater

func WithCFAPI

func WithCFAPI(api CloudflareAPI) CFOption

WithCFAPI allows to pass another API than the default one

type CloudFlareUpdate

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

CloudFlareUpdate communicates with the cloudflare API to change records

func NewCloudFlareUpdate

func NewCloudFlareUpdate(cfg *cfg.CloudflareAPI, opts ...CFOption) (*CloudFlareUpdate, error)

NewCloudFlareUpdate returns a new cloudflare updater

func (*CloudFlareUpdate) Name

func (c *CloudFlareUpdate) Name() string

Name returns a human-readable identifier for the updater

func (*CloudFlareUpdate) Update

func (c *CloudFlareUpdate) Update(IP string) error

Update changes the record from the config in Cloudflare to `ip`

type CloudflareAPI

type CloudflareAPI interface {
	ZoneIDByName(string) (string, error)
	DNSRecords(string, cloudflare.DNSRecord) ([]cloudflare.DNSRecord, error)
	UpdateDNSRecord(string, string, cloudflare.DNSRecord) error
}

CloudflareAPI allows us to decouple the third-party CloudFlare API implementation. This is useful for mocking the cloudflare api for testing.

type FOption

type FOption func(*FileUpdate)

FOption can be used to configure optional parameters for the file updater

func WithOutputWriteCloser

func WithOutputWriteCloser(wc io.WriteCloser) FOption

WithOutputWriteCloser allows for a more generic way of writing the output

type FileUpdate

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

FileUpdate supplies methods to update the IP in a template and write it to an output file

func NewFileUpdate

func NewFileUpdate(cfg *cfg.FileConfig, opts ...FOption) (*FileUpdate, error)

NewFileUpdate creates a file updater

func (*FileUpdate) Name

func (f *FileUpdate) Name() string

Name returns a human-readable identifier for the updater

func (*FileUpdate) Update

func (f *FileUpdate) Update(ip string) error

Update takes the IP and writes it to the specified output file using the provided input template

type Updater

type Updater interface {
	Update(IP string) error
	Name() string
}

Updater is an interface that takes a configuration and updates the IP

Jump to

Keyboard shortcuts

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