Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
39436ea
refactor: decouple CRD types from internal endpoint package
u-kai Sep 6, 2025
85203ba
perf(endpoint): optimize ProviderSpecific to use map for O(1) access
u-kai Sep 6, 2025
5fdeeba
refactor: use maps package for ProviderSpecific operations
u-kai Sep 9, 2025
a8f89fd
add omitempty to DNSEndpointSpec.Endpoints
u-kai Sep 12, 2025
bbe0387
refactor(endpoint): remove ProviderSpecific String() methad and fix t…
u-kai Sep 19, 2025
010da28
Merge branch 'master' of https://github.com/kubernetes-sigs/external-…
u-kai Sep 21, 2025
1301503
refactor(crd): move endpoint conversion logic to ToInternal method
u-kai Sep 22, 2025
aeeff6f
fix(webhook): maintain backward compatibility for records conversion
u-kai Sep 22, 2025
46bc513
fix(webhook): maintain backward compatibility for adjustEndpoints con…
u-kai Sep 22, 2025
3cbefbf
fix(webhook): maintain backward compatibility for ApplyChanges conver…
u-kai Sep 22, 2025
63dd99d
fix(webhook): improve type conversion and maintain backward compatibi…
u-kai Sep 23, 2025
8d70d35
fix lint
u-kai Sep 23, 2025
061b7ca
add endpoint adapter tests
u-kai Sep 23, 2025
c054b37
Merge branch 'master' of https://github.com/kubernetes-sigs/external-…
u-kai Sep 23, 2025
b2a6334
fix: resolve merge error
u-kai Sep 23, 2025
92d91e0
add provider specific test coverage
u-kai Sep 25, 2025
17052da
fix and rename endpoint adapter
u-kai Sep 25, 2025
440d865
Merge branch 'master' of https://github.com/kubernetes-sigs/external-…
u-kai Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions apis/v1alpha1/dnsendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"sigs.k8s.io/external-dns/endpoint"
)

// +genclient
Expand Down Expand Up @@ -51,7 +49,37 @@ type DNSEndpointList struct {

// DNSEndpointSpec defines the desired state of DNSEndpoint
type DNSEndpointSpec struct {
Endpoints []*endpoint.Endpoint `json:"endpoints,omitempty"`
Endpoints []*Endpoint `json:"endpoints,omitempty"`
}

// ProviderSpecificProperty holds the name and value of a configuration which is specific to individual DNS providers
type ProviderSpecificProperty struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
}

// ProviderSpecific holds configuration which is specific to individual DNS providers
type ProviderSpecific []ProviderSpecificProperty

// Endpoint is a high-level way of a connection between a service and an IP
// +kubebuilder:object:generate=true
type Endpoint struct {
// The hostname of the DNS record
DNSName string `json:"dnsName,omitempty"`
// The targets the DNS record points to
Targets []string `json:"targets,omitempty"`
// RecordType type of record, e.g. CNAME, A, AAAA, SRV, TXT etc
RecordType string `json:"recordType,omitempty"`
// Identifier to distinguish multiple records with the same name and type (e.g. Route53 records with routing policies other than 'simple')
SetIdentifier string `json:"setIdentifier,omitempty"`
// TTL for the record
RecordTTL int64 `json:"recordTTL,omitempty"`
// Labels stores labels defined for the Endpoint
// +optional
Labels map[string]string `json:"labels,omitempty"`
// ProviderSpecific stores provider specific config
// +optional
ProviderSpecific ProviderSpecific `json:"providerSpecific,omitempty"`
}

// DNSEndpointStatus defines the observed state of DNSEndpoint
Expand Down
71 changes: 68 additions & 3 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 22 additions & 27 deletions endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,21 @@ func (t Targets) IsLess(o Targets) bool {
return false
}

// ProviderSpecificProperty holds the name and value of a configuration which is specific to individual DNS providers
type ProviderSpecificProperty struct {
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
// ProviderSpecific holds configuration which is specific to individual DNS providers
type ProviderSpecific map[string]string

func (ps ProviderSpecific) Set(key, value string) {
ps[key] = value
}

// ProviderSpecific holds configuration which is specific to individual DNS providers
type ProviderSpecific []ProviderSpecificProperty
func (ps ProviderSpecific) Get(key string) (string, bool) {
value, ok := ps[key]
return value, ok
}

func (ps ProviderSpecific) Delete(key string) {
delete(ps, key)
}

// EndpointKey is the type of a map key for separating endpoints or targets.
type EndpointKey struct {
Expand All @@ -224,7 +231,6 @@ type EndpointKey struct {
}

// Endpoint is a high-level way of a connection between a service and an IP
// +kubebuilder:object:generate=true
type Endpoint struct {
// The hostname of the DNS record
DNSName string `json:"dnsName,omitempty"`
Expand Down Expand Up @@ -300,37 +306,26 @@ func (e *Endpoint) WithProviderSpecific(key, value string) *Endpoint {

// GetProviderSpecificProperty returns the value of a ProviderSpecificProperty if the property exists.
func (e *Endpoint) GetProviderSpecificProperty(key string) (string, bool) {
for _, providerSpecific := range e.ProviderSpecific {
if providerSpecific.Name == key {
return providerSpecific.Value, true
}
if e.ProviderSpecific == nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-09-25 at 10 16 25

return "", false
}
return "", false
return e.ProviderSpecific.Get(key)
}

// SetProviderSpecificProperty sets the value of a ProviderSpecificProperty.
func (e *Endpoint) SetProviderSpecificProperty(key string, value string) {
for i, providerSpecific := range e.ProviderSpecific {
if providerSpecific.Name == key {
e.ProviderSpecific[i] = ProviderSpecificProperty{
Name: key,
Value: value,
}
return
}
if e.ProviderSpecific == nil {
e.ProviderSpecific = make(ProviderSpecific)
}

e.ProviderSpecific = append(e.ProviderSpecific, ProviderSpecificProperty{Name: key, Value: value})
e.ProviderSpecific.Set(key, value)
}

// DeleteProviderSpecificProperty deletes any ProviderSpecificProperty of the specified name.
func (e *Endpoint) DeleteProviderSpecificProperty(key string) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-09-25 at 10 16 53

for i, providerSpecific := range e.ProviderSpecific {
if providerSpecific.Name == key {
e.ProviderSpecific = append(e.ProviderSpecific[:i], e.ProviderSpecific[i+1:]...)
return
}
if e.ProviderSpecific == nil {
return
}
e.ProviderSpecific.Delete(key)
}

// WithLabel adds or updates a label for the Endpoint.
Expand Down
Loading
Loading