mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-05-05 14:46:10 +02:00
add labels to endpoints (#121)
* add labels to endpoints * reset to first commit fix label key * compare using sameendpoint, add map initializer to newendpoint * fix(endpoint): drop superflous comment indicators
This commit is contained in:
parent
cd5af1f4c9
commit
2eb97f6a83
@ -16,12 +16,19 @@ limitations under the License.
|
||||
|
||||
package endpoint
|
||||
|
||||
const (
|
||||
// OwnerLabelKey is the name of the label that defines the owner of an Endpoint.
|
||||
OwnerLabelKey = "owner"
|
||||
)
|
||||
|
||||
// Endpoint is a high-level way of a connection between a service and an IP
|
||||
type Endpoint struct {
|
||||
// The hostname of the DNS record
|
||||
DNSName string
|
||||
// The target the DNS record points to
|
||||
Target string
|
||||
// Labels stores labels defined for the Endpoint
|
||||
Labels map[string]string
|
||||
}
|
||||
|
||||
// NewEndpoint initialization method to be used to create an endpoint
|
||||
@ -29,5 +36,6 @@ func NewEndpoint(dnsName, target string) *Endpoint {
|
||||
return &Endpoint{
|
||||
DNSName: dnsName,
|
||||
Target: target,
|
||||
Labels: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,4 +23,7 @@ func TestNewEndpoint(t *testing.T) {
|
||||
if e.DNSName != "example.org" || e.Target != "1.2.3.4" {
|
||||
t.Error("endpoint is not initialized correctly")
|
||||
}
|
||||
if e.Labels == nil {
|
||||
t.Error("Labels is not initialized")
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kubernetes-incubator/external-dns/endpoint"
|
||||
"github.com/kubernetes-incubator/external-dns/internal/testutils"
|
||||
)
|
||||
|
||||
// TestCalculate tests that a plan can calculate actions to move a list of
|
||||
@ -123,13 +124,13 @@ func ExamplePlan() {
|
||||
}
|
||||
// Output:
|
||||
// Create:
|
||||
// &{baz.example.com 6.6.6.6}
|
||||
// &{baz.example.com 6.6.6.6 map[]}
|
||||
// UpdateOld:
|
||||
// &{bar.example.com 8.8.8.8}
|
||||
// &{bar.example.com 8.8.8.8 map[]}
|
||||
// UpdateNew:
|
||||
// &{bar.example.com 8.8.4.4}
|
||||
// &{bar.example.com 8.8.4.4 map[]}
|
||||
// Delete:
|
||||
// &{foo.example.com 1.2.3.4}
|
||||
// &{foo.example.com 1.2.3.4 map[]}
|
||||
}
|
||||
|
||||
// validateEntries validates that the list of entries matches expected.
|
||||
@ -139,7 +140,7 @@ func validateEntries(t *testing.T, entries, expected []*endpoint.Endpoint) {
|
||||
}
|
||||
|
||||
for i := range entries {
|
||||
if entries[i] != expected[i] {
|
||||
if !testutils.SameEndpoint(entries[i], expected[i]) {
|
||||
t.Fatalf("expected %q to match %q", entries, expected)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user