provider

package
v0.0.0-...-eedacba Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrZoneAlreadyExists error returned when zone cannot be created when it already exists
	ErrZoneAlreadyExists = errors.New("specified zone already exists")
	// ErrZoneNotFound error returned when specified zone does not exists
	ErrZoneNotFound = errors.New("specified zone 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 AWSConfig

type AWSConfig struct {
	DomainFilter         DomainFilter
	ZoneIDFilter         ZoneIDFilter
	ZoneTypeFilter       ZoneTypeFilter
	MaxChangeCount       int
	EvaluateTargetHealth bool
	AssumeRole           string
	DryRun               bool
}

AWSConfig contains configuration to create a new AWS provider.

type AWSProvider

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

AWSProvider is an implementation of Provider for AWS Route53.

func NewAWSProvider

func NewAWSProvider(awsConfig AWSConfig) (*AWSProvider, error)

NewAWSProvider initializes a new AWS Route53 based Provider.

func (*AWSProvider) ApplyChanges

func (p *AWSProvider) ApplyChanges(changes *plan.Changes) error

ApplyChanges applies a given set of changes in a given zone.

func (*AWSProvider) CreateRecords

func (p *AWSProvider) CreateRecords(endpoints []*endpoint.Endpoint) error

CreateRecords creates a given set of DNS records in the given hosted zone.

func (*AWSProvider) DeleteRecords

func (p *AWSProvider) DeleteRecords(endpoints []*endpoint.Endpoint) error

DeleteRecords deletes a given set of DNS records in a given zone.

func (*AWSProvider) Records

func (p *AWSProvider) Records() (endpoints []*endpoint.Endpoint, _ error)

Records returns the list of records in a given hosted zone.

func (*AWSProvider) UpdateRecords

func (p *AWSProvider) UpdateRecords(endpoints, _ []*endpoint.Endpoint) error

UpdateRecords updates a given set of old records to a new set of records in a given hosted zone.

func (*AWSProvider) Zones

func (p *AWSProvider) Zones() (map[string]*route53.HostedZone, error)

Zones returns the list of hosted zones.

type AWSSDClient

type AWSSDClient interface {
	CreateService(input *sd.CreateServiceInput) (*sd.CreateServiceOutput, error)
	DeregisterInstance(input *sd.DeregisterInstanceInput) (*sd.DeregisterInstanceOutput, error)
	GetService(input *sd.GetServiceInput) (*sd.GetServiceOutput, error)
	ListInstancesPages(input *sd.ListInstancesInput, fn func(*sd.ListInstancesOutput, bool) bool) error
	ListNamespacesPages(input *sd.ListNamespacesInput, fn func(*sd.ListNamespacesOutput, bool) bool) error
	ListServicesPages(input *sd.ListServicesInput, fn func(*sd.ListServicesOutput, bool) bool) error
	RegisterInstance(input *sd.RegisterInstanceInput) (*sd.RegisterInstanceOutput, error)
	UpdateService(input *sd.UpdateServiceInput) (*sd.UpdateServiceOutput, error)
}

AWSSDClient is the subset of the AWS Route53 Auto Naming API that we actually use. Add methods as required. Signatures must match exactly. Taken from https://github.com/aws/aws-sdk-go/blob/master/service/servicediscovery/api.go

type AWSSDProvider

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

AWSSDProvider is an implementation of Provider for AWS Route53 Auto Naming.

func NewAWSSDProvider

func NewAWSSDProvider(domainFilter DomainFilter, namespaceType string, dryRun bool) (*AWSSDProvider, error)

NewAWSSDProvider initializes a new AWS Route53 Auto Naming based Provider.

func (*AWSSDProvider) ApplyChanges

func (p *AWSSDProvider) ApplyChanges(changes *plan.Changes) error

ApplyChanges applies Kubernetes changes in endpoints to AWS API

func (*AWSSDProvider) CreateService

func (p *AWSSDProvider) CreateService(namespaceID *string, srvName *string, ep *endpoint.Endpoint) (*sd.Service, error)

CreateService creates a new service in AWS API. Returns the created service.

func (*AWSSDProvider) DeregisterInstance

func (p *AWSSDProvider) DeregisterInstance(service *sd.Service, ep *endpoint.Endpoint) error

DeregisterInstance removes an instance from given service.

func (*AWSSDProvider) GetServiceDetail

func (p *AWSSDProvider) GetServiceDetail(serviceID *string) (*sd.Service, error)

GetServiceDetail returns detail of given service

func (*AWSSDProvider) ListInstancesByServiceID

func (p *AWSSDProvider) ListInstancesByServiceID(serviceID *string) ([]*sd.InstanceSummary, error)

ListInstancesByServiceID returns list of instances registered in given service.

func (*AWSSDProvider) ListNamespaces

func (p *AWSSDProvider) ListNamespaces() ([]*sd.NamespaceSummary, error)

ListNamespaces returns all namespaces matching defined namespace filter

func (*AWSSDProvider) ListServicesByNamespaceID

func (p *AWSSDProvider) ListServicesByNamespaceID(namespaceID *string) (map[string]*sd.Service, error)

ListServicesByNamespaceID returns list of services in given namespace. Returns map[srv_name]*sd.Service

func (*AWSSDProvider) Records

func (p *AWSSDProvider) Records() (endpoints []*endpoint.Endpoint, err error)

Records returns list of all endpoints.

func (*AWSSDProvider) RegisterInstance

func (p *AWSSDProvider) RegisterInstance(service *sd.Service, ep *endpoint.Endpoint) error

RegisterInstance creates a new instance in given service.

func (*AWSSDProvider) UpdateService

func (p *AWSSDProvider) UpdateService(service *sd.Service, ep *endpoint.Endpoint) error

UpdateService updates the specified service with information from provided endpoint.

type DomainFilter

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

DomainFilter holds a lists of valid domain names

func NewDomainFilter

func NewDomainFilter(domainFilters []string) DomainFilter

NewDomainFilter returns a new DomainFilter given a comma separated list of domains

func (DomainFilter) IsConfigured

func (df DomainFilter) IsConfigured() bool

IsConfigured returns true if DomainFilter is configured, false otherwise

func (DomainFilter) Match

func (df DomainFilter) Match(domain string) bool

Match checks whether a domain can be found in the DomainFilter.

type InMemoryOption

type InMemoryOption func(*InMemoryProvider)

InMemoryOption allows to extend in-memory provider

func InMemoryInitZones

func InMemoryInitZones(zones []string) InMemoryOption

InMemoryInitZones pre-seeds the InMemoryProvider with given zones

func InMemoryWithDomain

func InMemoryWithDomain(domainFilter DomainFilter) InMemoryOption

InMemoryWithDomain modifies the domain on which dns zones are filtered

func InMemoryWithLogging

func InMemoryWithLogging() InMemoryOption

InMemoryWithLogging injects logging when ApplyChanges is called

type InMemoryProvider

type InMemoryProvider struct {
	OnApplyChanges func(changes *plan.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(opts ...InMemoryOption) *InMemoryProvider

NewInMemoryProvider returns InMemoryProvider DNS provider interface implementation

func (*InMemoryProvider) ApplyChanges

func (im *InMemoryProvider) ApplyChanges(changes *plan.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) CreateZone

func (im *InMemoryProvider) CreateZone(newZone string) error

CreateZone adds new zone if not present

func (*InMemoryProvider) Records

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

Records returns the list of endpoints

func (*InMemoryProvider) Zones

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

Zones returns filtered zones as specified by domain

type Provider

type Provider interface {
	Records() ([]*endpoint.Endpoint, error)
	ApplyChanges(changes *plan.Changes) error
}

Provider defines the interface DNS providers should implement.

type Route53API

type Route53API interface {
	ListResourceRecordSetsPages(input *route53.ListResourceRecordSetsInput, fn func(resp *route53.ListResourceRecordSetsOutput, lastPage bool) (shouldContinue bool)) error
	ChangeResourceRecordSets(*route53.ChangeResourceRecordSetsInput) (*route53.ChangeResourceRecordSetsOutput, error)
	CreateHostedZone(*route53.CreateHostedZoneInput) (*route53.CreateHostedZoneOutput, error)
	ListHostedZonesPages(input *route53.ListHostedZonesInput, fn func(resp *route53.ListHostedZonesOutput, lastPage bool) (shouldContinue bool)) error
}

Route53API is the subset of the AWS Route53 API that we actually use. Add methods as required. Signatures must match exactly. mostly taken from: https://github.com/kubernetes/kubernetes/blob/853167624edb6bc0cfdcdfb88e746e178f5db36c/federation/pkg/dnsprovider/providers/aws/route53/stubs/route53api.go

type ZoneIDFilter

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

ZoneIDFilter holds a list of zone ids to filter by

func NewZoneIDFilter

func NewZoneIDFilter(zoneIDs []string) ZoneIDFilter

NewZoneIDFilter returns a new ZoneIDFilter given a list of zone ids

func (ZoneIDFilter) Match

func (f ZoneIDFilter) Match(zoneID string) bool

Match checks whether a zone matches one of the provided zone ids

type ZoneTypeFilter

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

ZoneTypeFilter holds a zone type to filter for.

func NewZoneTypeFilter

func NewZoneTypeFilter(zoneType string) ZoneTypeFilter

NewZoneTypeFilter returns a new ZoneTypeFilter given a zone type to filter for.

func (ZoneTypeFilter) Match

func (f ZoneTypeFilter) Match(zone *route53.HostedZone) bool

Match checks whether a zone matches the zone type that's filtered for.

Jump to

Keyboard shortcuts

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