plan

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 7 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Policies = map[string]Policy{
	"sync":        &SyncPolicy{},
	"upsert-only": &UpsertOnlyPolicy{},
	"create-only": &CreateOnlyPolicy{},
}

Policies is a registry of available policies.

Functions

func CompareBoolean added in v0.7.2

func CompareBoolean(defaultValue bool, name, current, previous string) bool

CompareBoolean is an implementation of PropertyComparator for comparing boolean-line values For example external-dns.alpha.kubernetes.io/cloudflare-proxied: "true" If value doesn't parse as boolean, the defaultValue is used

func IsManagedRecord added in v0.12.1

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

Types

type Changes

type Changes struct {
	// Records that need to be created
	Create []*endpoint.Endpoint
	// Records that need to be updated (current data)
	UpdateOld []*endpoint.Endpoint
	// Records that need to be updated (desired data)
	UpdateNew []*endpoint.Endpoint
	// Records that need to be deleted
	Delete []*endpoint.Endpoint
}

Changes holds lists of actions to be executed by dns providers

func (*Changes) HasChanges added in v0.9.0

func (c *Changes) HasChanges() bool

type ConflictResolver added in v0.5.0

type ConflictResolver interface {
	ResolveCreate(candidates []*endpoint.Endpoint) *endpoint.Endpoint
	ResolveUpdate(current *endpoint.Endpoint, candidates []*endpoint.Endpoint) *endpoint.Endpoint
}

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 added in v0.5.18

type CreateOnlyPolicy struct{}

CreateOnlyPolicy allows only creating DNS records.

func (*CreateOnlyPolicy) Apply added in v0.5.18

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

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

type PerResource added in v0.5.0

type PerResource struct{}

PerResource allows only one resource to own a given dns name

func (PerResource) ResolveCreate added in v0.5.0

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) ResolveUpdate added in v0.5.0

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 desired records
	Desired []*endpoint.Endpoint
	// List of missing records to be created, use for the migrations (e.g. old-new TXT format)
	Missing []*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 *Changes
	// DomainFilter matches DNS names
	DomainFilter endpoint.DomainFilterInterface
	// Property comparator compares custom properties of providers
	PropertyComparator PropertyComparator
	// DNS record types that will be considered for management
	ManagedRecords []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.

type Policy added in v0.3.0

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

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

type PropertyComparator added in v0.7.2

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 added in v0.3.0

type SyncPolicy struct{}

SyncPolicy allows for full synchronization of DNS records.

func (*SyncPolicy) Apply added in v0.3.0

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

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

type UpsertOnlyPolicy added in v0.3.0

type UpsertOnlyPolicy struct{}

UpsertOnlyPolicy allows everything but deleting DNS records.

func (*UpsertOnlyPolicy) Apply added in v0.3.0

func (p *UpsertOnlyPolicy) Apply(changes *Changes) *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