diff --git a/agent/structs/config_entry_exports.go b/agent/structs/config_entry_exports.go index 5ae15ca68..044f9d62a 100644 --- a/agent/structs/config_entry_exports.go +++ b/agent/structs/config_entry_exports.go @@ -1,6 +1,7 @@ package structs import ( + "encoding/json" "fmt" "github.com/hashicorp/consul/acl" @@ -158,3 +159,19 @@ func (e *PartitionExportsConfigEntry) GetEnterpriseMeta() *EnterpriseMeta { return &e.EnterpriseMeta } + +// MarshalJSON adds the Kind field so that the JSON can be decoded back into the +// correct type. +// This method is implemented on the structs type (as apposed to the api type) +// because that is what the API currently uses to return a response. +func (e *PartitionExportsConfigEntry) MarshalJSON() ([]byte, error) { + type Alias PartitionExportsConfigEntry + source := &struct { + Kind string + *Alias + }{ + Kind: PartitionExports, + Alias: (*Alias)(e), + } + return json.Marshal(source) +} diff --git a/api/config_entry_cluster.go b/api/config_entry_mesh.go similarity index 100% rename from api/config_entry_cluster.go rename to api/config_entry_mesh.go