diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 7a6160966..3f7ce97c0 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -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{}, } } diff --git a/endpoint/endpoint_test.go b/endpoint/endpoint_test.go index 41dfdf73c..335198056 100644 --- a/endpoint/endpoint_test.go +++ b/endpoint/endpoint_test.go @@ -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") + } } diff --git a/plan/plan_test.go b/plan/plan_test.go index cd3432a7a..93df0b23d 100644 --- a/plan/plan_test.go +++ b/plan/plan_test.go @@ -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) } }