-
Notifications
You must be signed in to change notification settings - Fork 66
/
interface.go
114 lines (95 loc) · 3.65 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package source
import (
"github.com/gardener/controller-manager-library/pkg/controllermanager/controller"
"github.com/gardener/controller-manager-library/pkg/controllermanager/controller/reconcile"
"github.com/gardener/controller-manager-library/pkg/logger"
"github.com/gardener/controller-manager-library/pkg/resources"
"github.com/gardener/controller-manager-library/pkg/utils"
"github.com/gardener/external-dns-management/pkg/dns"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/gardener/external-dns-management/pkg/apis/dns/v1alpha1"
)
type DNSInfo struct {
Names dns.DNSNameSet
OwnerId *string
TTL *int64
Interval *int64
Targets utils.StringSet
Text utils.StringSet
OrigRef *v1alpha1.EntryReference
TargetRef *v1alpha1.EntryReference
RoutingPolicy *v1alpha1.RoutingPolicy
IPStack string
ResolveTargetsToAddresses *bool
Ignore bool
}
type DNSFeedback interface {
Succeeded(logger logger.LogContext)
Pending(logger logger.LogContext, dnsname string, msg string, dnsState *DNSState)
Ready(logger logger.LogContext, dnsname string, msg string, dnsState *DNSState)
Invalid(logger logger.LogContext, dnsname string, err error, dnsState *DNSState)
Failed(logger logger.LogContext, dnsname string, err error, dnsState *DNSState)
Deleted(logger logger.LogContext, dnsname string, msg string)
Created(logger logger.LogContext, dnsname string, name resources.ObjectName)
}
type DNSSource interface {
Setup() error
CreateDNSFeedback(obj resources.Object) DNSFeedback
GetDNSInfo(logger logger.LogContext, obj resources.ObjectData, current *DNSCurrentState) (*DNSInfo, error)
Delete(logger logger.LogContext, obj resources.Object) reconcile.Status
Deleted(logger logger.LogContext, key resources.ClusterObjectKey)
}
type DNSSourceType interface {
Name() string
GroupKind() schema.GroupKind
Create(controller.Interface) (DNSSource, error)
}
type TargetExtraction struct {
Targets utils.StringSet
Texts utils.StringSet
IPStack string
ResolveTargetsToAddresses *bool
Ignore bool
}
type (
DNSTargetExtractor func(logger logger.LogContext, obj resources.ObjectData, names dns.DNSNameSet) (*TargetExtraction, error)
DNSSourceCreator func(controller.Interface) (DNSSource, error)
)
type DNSState struct {
v1alpha1.DNSEntryStatus
CreationTimestamp metav1.Time
}
type DNSCurrentState struct {
Names map[dns.DNSSetName]*DNSState
Targets utils.StringSet
AnnotatedNames utils.StringSet
AnnotatedRoutingPolicy *v1alpha1.RoutingPolicy
}
func (s *DNSCurrentState) GetSetIdentifier() string {
if s.AnnotatedRoutingPolicy == nil {
return ""
}
return s.AnnotatedRoutingPolicy.SetIdentifier
}
func NewDNSSouceTypeForExtractor(name string, kind schema.GroupKind, handler DNSTargetExtractor) DNSSourceType {
return &handlerdnssourcetype{dnssourcetype{name, kind}, NewDefaultDNSSource(handler)}
}
func NewDNSSouceTypeForCreator(name string, kind schema.GroupKind, handler DNSSourceCreator) DNSSourceType {
return &creatordnssourcetype{dnssourcetype{name, kind}, handler}
}
type dnssourcetype struct {
name string
kind schema.GroupKind
}
type handlerdnssourcetype struct {
dnssourcetype
DefaultDNSSource
}
type creatordnssourcetype struct {
dnssourcetype
handler DNSSourceCreator
}