plan

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// OwnerLabelDeliminator is a deliminator used between owners in the OwnerLabelKey value when multiple owners are assigned.
	OwnerLabelDeliminator = "&&"
)

Variables

View Source
var (
	ErrInvalidTarget      = errors.New("invalid target")
	ErrOwnerConflict      = errors.New("owner conflict")
	ErrRecordTypeConflict = errors.New("record type conflict")
)
View Source
var Policies = map[string]Policy{
	"sync":        &SyncPolicy{},
	"upsert-only": &UpsertOnlyPolicy{},
	"create-only": &CreateOnlyPolicy{},
}

Policies is a registry of available policies.

Functions

func IsManagedRecord

func IsManagedRecord(record string, managedRecords, excludeRecords []string) bool

Types

type ConflictResolver

type ConflictResolver interface {
	ResolveCreate(candidates []*endpoint.Endpoint) *endpoint.Endpoint
	ResolveUpdate(current *endpoint.Endpoint, candidates []*endpoint.Endpoint) *endpoint.Endpoint
	ResolveRecordTypes(key planKey, row *planTableRow) map[string]*domainEndpoints
}

ConflictResolver is used to make a decision in case of two or more different kubernetes resources are trying to acquire same DNS name

type CreateOnlyPolicy

type CreateOnlyPolicy struct{}

CreateOnlyPolicy allows only creating DNS records.

func (*CreateOnlyPolicy) Apply

func (p *CreateOnlyPolicy) Apply(changes *plan.Changes) *plan.Changes

Apply applies the create-only policy which strips out updates and deletions.

type PerResource

type PerResource struct{}

PerResource allows only one resource to own a given dns name

func (PerResource) ResolveCreate

func (s PerResource) ResolveCreate(candidates []*endpoint.Endpoint) *endpoint.Endpoint

ResolveCreate is invoked when dns name is not owned by any resource ResolveCreate takes "minimal" (string comparison of Target) endpoint to acquire the DNS record

func (PerResource) ResolveRecordTypes

func (s PerResource) ResolveRecordTypes(key planKey, row *planTableRow) map[string]*domainEndpoints

ResolveRecordTypes attempts to detect and resolve record type conflicts in desired endpoints for a domain. For eample if the there is more than 1 candidate and at lease one of them is a CNAME. Per RFC 1034 3.6.2 domains that contain a CNAME can not contain any other record types. The default policy will prefer A and AAAA record types when a conflict is detected (consistent with endpoint.Targets.Less).

func (PerResource) ResolveUpdate

func (s PerResource) ResolveUpdate(current *endpoint.Endpoint, candidates []*endpoint.Endpoint) *endpoint.Endpoint

ResolveUpdate is invoked when dns name is already owned by "current" endpoint ResolveUpdate uses "current" record as base and updates it accordingly with new version of same resource if it doesn't exist then pick min

type Plan

type Plan struct {
	// List of current records
	Current []*endpoint.Endpoint
	// List of the records that were successfully resolved by this instance previously.
	Previous []*endpoint.Endpoint
	// List of desired records
	Desired []*endpoint.Endpoint
	// Policies under which the desired changes are calculated
	Policies []Policy
	// List of changes necessary to move towards desired state
	// Populated after calling Calculate()
	Changes *externaldnsplan.Changes
	// DomainFilter matches DNS names
	DomainFilter endpoint.MatchAllDomainFilters
	// ManagedRecords are DNS record types that will be considered for management.
	ManagedRecords []string
	// ExcludeRecords are DNS record types that will be excluded from management.
	ExcludeRecords []string
	// OwnerID of records to manage
	OwnerID string
	// Errors list of errors describing issues that can't be resolved by the plan.
	// Populated after calling Calculate()
	Errors []error
	// RootHost the host dns name being managed by the set of records in the plan.
	RootHost *string
}

Plan can convert a list of desired and current records to a series of create, update and delete actions.

func (*Plan) Calculate

func (p *Plan) Calculate() *Plan

Calculate computes the actions needed to move current state towards desired state. It then passes those changes to the current policy for further processing. It returns a copy of Plan with the changes populated.

func (*Plan) Error

func (p *Plan) Error() error

Error returns all Errors as a single error or nil if there are none.

type Policy

type Policy interface {
	Apply(changes *plan.Changes) *plan.Changes
}

Policy allows to apply different rules to a set of changes.

type PropertyComparator

type PropertyComparator func(name string, previous string, current string) bool

PropertyComparator is used in Plan for comparing the previous and current custom annotations.

type SyncPolicy

type SyncPolicy struct{}

SyncPolicy allows for full synchronization of DNS records.

func (*SyncPolicy) Apply

func (p *SyncPolicy) Apply(changes *plan.Changes) *plan.Changes

Apply applies the sync policy which returns the set of changes as is.

type UpsertOnlyPolicy

type UpsertOnlyPolicy struct{}

UpsertOnlyPolicy allows everything but deleting DNS records.

func (*UpsertOnlyPolicy) Apply

func (p *UpsertOnlyPolicy) Apply(changes *plan.Changes) *plan.Changes

Apply applies the upsert-only policy which strips out any deletions.

Jump to

Keyboard shortcuts

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