From 2343413bf032f7ce6fd366114a478f13e03ec450 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Fri, 6 Dec 2019 15:47:41 -0500 Subject: [PATCH] Fix the TestAPI_CatalogRegistration test --- agent/structs/structs.go | 17 +++++++++++++++++ api/catalog.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/agent/structs/structs.go b/agent/structs/structs.go index 9eb798bc39..14b50e5e67 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -322,6 +322,23 @@ func (r *DeregisterRequest) RequestDatacenter() string { return r.Datacenter } + +func (r *DeregisterRequest) UnmarshalJSON(data []byte) error { + type Alias DeregisterRequest + aux := &struct { + Address string // obsolete field - but we want to explicitly allow it + *Alias + }{ + Alias: (*Alias)(r), + } + + if err := lib.UnmarshalJSON(data, &aux); err != nil { + return err + } + return nil +} + + // QuerySource is used to pass along information about the source node // in queries so that we can adjust the response based on its network // coordinates. diff --git a/api/catalog.go b/api/catalog.go index 3fb055342c..d10f21ef9b 100644 --- a/api/catalog.go +++ b/api/catalog.go @@ -68,7 +68,7 @@ type CatalogRegistration struct { type CatalogDeregistration struct { Node string - Address string // Obsolete. + Address string `json:",omitempty"` // Obsolete. Datacenter string ServiceID string CheckID string