mem

package
v0.0.0-...-50c2eee Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrZoneAlreadyExists error returned when zoneRecords cannot be created when it already exists
	ErrZoneAlreadyExists = errors.New("specified zoneRecords already exists")
	// ErrZoneNotFound error returned when specified zoneRecords does not exists
	ErrZoneNotFound = errors.New("specified zoneRecords not found")
	// ErrRecordAlreadyExists when create request is sent but record already exists
	ErrRecordAlreadyExists = errors.New("record already exists")
	// ErrRecordNotFound when update/delete request is sent but record not found
	ErrRecordNotFound = errors.New("record not found")
	// ErrDuplicateRecordFound when record is repeated in create/update/delete
	ErrDuplicateRecordFound = errors.New("invalid batch request")
)

Functions

This section is empty.

Types

type InMemoryProvider

type InMemoryProvider struct {
	provider.BaseProvider

	Name string

	ZoneDomains map[string]string

	// Callbacks for logging and testing
	OnApplyChanges func(ctx context.Context, changes *endpoint.Changes)
	OnRecords      func()
	// contains filtered or unexported fields
}

InMemoryProvider - dns provider only used for testing purposes initialized as dns provider with no records

func NewInMemoryProvider

func NewInMemoryProvider(n string, sync *endpoint.SyncConfig) *InMemoryProvider

NewInMemoryProvider returns InMemoryProvider DNS provider interface implementation

func (*InMemoryProvider) ApplyChanges

func (im *InMemoryProvider) ApplyChanges(ctx context.Context, changes *endpoint.Changes) error

ApplyChanges simply modifies records in memory error checking occurs before any modifications are made, i.e. batch processing create record - record should not exist update/delete record - record should exist create/update/delete lists should not have overlapping records

func (*InMemoryProvider) ApplyChangesZone

func (c *InMemoryProvider) ApplyChangesZone(ctx context.Context, zoneID string, changes *endpoint.Changes) error

func (*InMemoryProvider) CreateZone

func (c *InMemoryProvider) CreateZone(zone string) error

func (*InMemoryProvider) Records

func (im *InMemoryProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, error)

Records returns the list of endpoints

func (*InMemoryProvider) RecordsZone

func (c *InMemoryProvider) RecordsZone(zone string) ([]*endpoint.Endpoint, error)

func (*InMemoryProvider) Zones

func (im *InMemoryProvider) Zones() map[string]string

Zones returns filtered zones as specified by domain

func (*InMemoryProvider) ZonesZone

func (c *InMemoryProvider) ZonesZone() map[string]string

type MemSource

type MemSource struct {
	Records []*endpoint.Endpoint

	Error   error
	Handler func()
}

MemSource is a source backed by files or static data, mainly for testing.

func (*MemSource) AddEventHandler

func (m *MemSource) AddEventHandler(ctx context.Context, handler func())

AddEventHandler adds an event handler that should be triggered if something in source changes

func (*MemSource) Endpoints

func (m *MemSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error)

Endpoints returns the desired mock endpoints.

Jump to

Keyboard shortcuts

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