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
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
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
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