Renames agent API layer for service metadata to "meta" for consistency

This commit is contained in:
Preetha Appan 2018-03-28 09:04:50 -05:00
parent 9d3fa622fb
commit d9d9944179
No known key found for this signature in database
GPG Key ID: 9F7C19990A50EAFC
12 changed files with 31 additions and 33 deletions

View File

@ -515,7 +515,7 @@ func (s *HTTPServer) AgentRegisterService(resp http.ResponseWriter, req *http.Re
// Get the node service.
ns := args.NodeService()
if err := structs.ValidateMetadata(ns.ServiceMeta, false); err != nil {
if err := structs.ValidateMetadata(ns.Meta, false); err != nil {
resp.WriteHeader(http.StatusBadRequest)
fmt.Fprint(resp, fmt.Errorf("Invalid Service Meta: %v", err))
return nil, nil

View File

@ -4096,9 +4096,9 @@ func TestSanitize(t *testing.T) {
"Checks": [],
"EnableTagOverride": false,
"ID": "",
"Meta": {},
"Name": "foo",
"Port": 0,
"ServiceMeta": {},
"Tags": [],
"Token": "hidden"
}

View File

@ -614,7 +614,7 @@ func (s *Store) ensureServiceTxn(tx *memdb.Txn, idx uint64, node string, svc *st
return fmt.Errorf("failed service lookup: %s", err)
}
if err = structs.ValidateMetadata(svc.ServiceMeta, false); err != nil {
if err = structs.ValidateMetadata(svc.Meta, false); err != nil {
return fmt.Errorf("Invalid Service Meta for node %s and serviceID %s: %v", node, svc.ID, err)
}
// Create the service node entry and populate the indexes. Note that

View File

@ -69,17 +69,17 @@ func TestStateStore_EnsureRegistration(t *testing.T) {
}
verifyNode()
// Add in a invalid service definition with too long Key value for ServiceMeta
// Add in a invalid service definition with too long Key value for Meta
req.Service = &structs.NodeService{
ID: "redis1",
Service: "redis",
Address: "1.1.1.1",
Port: 8080,
ServiceMeta: map[string]string{strings.Repeat("a", 129): "somevalue"},
Tags: []string{"master"},
ID: "redis1",
Service: "redis",
Address: "1.1.1.1",
Port: 8080,
Meta: map[string]string{strings.Repeat("a", 129): "somevalue"},
Tags: []string{"master"},
}
if err := s.EnsureRegistration(9, req); err == nil {
t.Fatalf("Service should not have been registered since ServiceMeta is invalid")
t.Fatalf("Service should not have been registered since Meta is invalid")
}
// Add in a service definition.

View File

@ -6,7 +6,7 @@ type ServiceDefinition struct {
Name string
Tags []string
Address string
ServiceMeta map[string]string
Meta map[string]string
Port int
Check CheckType
Checks CheckTypes
@ -20,7 +20,7 @@ func (s *ServiceDefinition) NodeService() *NodeService {
Service: s.Name,
Tags: s.Tags,
Address: s.Address,
ServiceMeta: s.ServiceMeta,
Meta: s.Meta,
Port: s.Port,
EnableTagOverride: s.EnableTagOverride,
}

View File

@ -412,7 +412,7 @@ func (s *ServiceNode) ToNodeService() *NodeService {
Tags: s.ServiceTags,
Address: s.ServiceAddress,
Port: s.ServicePort,
ServiceMeta: s.ServiceMeta,
Meta: s.ServiceMeta,
EnableTagOverride: s.ServiceEnableTagOverride,
RaftIndex: RaftIndex{
CreateIndex: s.CreateIndex,
@ -429,7 +429,7 @@ type NodeService struct {
Service string
Tags []string
Address string
ServiceMeta map[string]string
Meta map[string]string
Port int
EnableTagOverride bool
@ -446,7 +446,7 @@ func (s *NodeService) IsSame(other *NodeService) bool {
!reflect.DeepEqual(s.Tags, other.Tags) ||
s.Address != other.Address ||
s.Port != other.Port ||
!reflect.DeepEqual(s.ServiceMeta, other.ServiceMeta) ||
!reflect.DeepEqual(s.Meta, other.Meta) ||
s.EnableTagOverride != other.EnableTagOverride {
return false
}
@ -466,7 +466,7 @@ func (s *NodeService) ToServiceNode(node string) *ServiceNode {
ServiceTags: s.Tags,
ServiceAddress: s.Address,
ServicePort: s.Port,
ServiceMeta: s.ServiceMeta,
ServiceMeta: s.Meta,
ServiceEnableTagOverride: s.EnableTagOverride,
RaftIndex: RaftIndex{
CreateIndex: s.CreateIndex,

View File

@ -187,7 +187,7 @@ func TestStructs_ServiceNode_PartialClone(t *testing.T) {
}
sn.ServiceMeta["new_meta"] = "new_value"
if reflect.DeepEqual(sn, clone) {
t.Fatalf("clone wasn't independent of the original for ServiceMeta")
t.Fatalf("clone wasn't independent of the original for Meta")
}
}
@ -214,7 +214,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) {
Service: "theservice",
Tags: []string{"foo", "bar"},
Address: "127.0.0.1",
ServiceMeta: map[string]string{
Meta: map[string]string{
"meta1": "value1",
"meta2": "value2",
},
@ -232,7 +232,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) {
Address: "127.0.0.1",
Port: 1234,
EnableTagOverride: true,
ServiceMeta: map[string]string{
Meta: map[string]string{
// We don't care about order
"meta2": "value2",
"meta1": "value1",
@ -268,7 +268,7 @@ func TestStructs_NodeService_IsSame(t *testing.T) {
check(func() { other.Tags = []string{"foo"} }, func() { other.Tags = []string{"foo", "bar"} })
check(func() { other.Address = "XXX" }, func() { other.Address = "127.0.0.1" })
check(func() { other.Port = 9999 }, func() { other.Port = 1234 })
check(func() { other.ServiceMeta["meta2"] = "wrongValue" }, func() { other.ServiceMeta["meta2"] = "value2" })
check(func() { other.Meta["meta2"] = "wrongValue" }, func() { other.Meta["meta2"] = "value2" })
check(func() { other.EnableTagOverride = false }, func() { other.EnableTagOverride = true })
}

View File

@ -66,7 +66,7 @@ type AgentServiceRegistration struct {
Port int `json:",omitempty"`
Address string `json:",omitempty"`
EnableTagOverride bool `json:",omitempty"`
ServiceMeta map[string]string `json:",omitempty"`
Meta map[string]string `json:",omitempty"`
Check *AgentServiceCheck
Checks AgentServiceChecks
}

View File

@ -53,7 +53,7 @@ $ curl \
"Service": "redis",
"Tags": [],
"Address": "",
"ServiceMeta": {
"Meta": {
"redis_version": "4.0"
},
"Port": 8000
@ -99,7 +99,7 @@ The table below shows this endpoint's support for
provided, the agent's address is used as the address for the service during
DNS queries.
- `ServiceMeta` `(map<string|string>: nil)` - Specifies arbitrary KV metadata
- `Meta` `(map<string|string>: nil)` - Specifies arbitrary KV metadata
linked to the service instance.
- `Port` `(int: 0)` - Specifies the port of the service.
@ -153,7 +153,7 @@ The table below shows this endpoint's support for
],
"Address": "127.0.0.1",
"Port": 8000,
"ServiceMeta": {
"Meta": {
"redis_version": "4.0"
},
"EnableTagOverride": false,

View File

@ -105,7 +105,7 @@ and vice versa. A catalog entry can have either, neither, or both.
"v1"
],
"Address": "127.0.0.1",
"ServiceMeta": {
"Meta": {
"redis_version": "4.0"
},
"Port": 8000
@ -537,7 +537,7 @@ $ curl \
"ID": "consul",
"Service": "consul",
"Tags": null,
"ServiceMeta": {},
"Meta": {},
"Port": 8300
},
"redis": {
@ -546,7 +546,7 @@ $ curl \
"Tags": [
"v1"
],
"ServiceMeta": {
"Meta": {
"redis_version": "4.0"
},
"Port": 8000

View File

@ -216,7 +216,7 @@ $ curl \
"Service": "redis",
"Tags": ["primary"],
"Address": "10.1.10.12",
"ServiceMeta": {
"Meta": {
"redis_version": "4.0"
},
"Port": 8000

View File

@ -241,7 +241,6 @@ The table below shows this endpoint's support for
"Near": "node1",
"OnlyPassing": false,
"Tags": ["primary", "!experimental"],
"ServiceMeta": {"redis_version": "4.0"},
"NodeMeta": {"instance_type": "m3.large"}
},
"DNS": {
@ -314,7 +313,6 @@ $ curl \
},
"OnlyPassing": false,
"Tags": ["primary", "!experimental"],
"ServiceMeta": {"redis_version": "4.0"},
"NodeMeta": {"instance_type": "m3.large"}
},
"DNS": {
@ -512,7 +510,7 @@ $ curl \
"ID": "redis",
"Service": "redis",
"Tags": null,
"ServiceMeta": {"redis_version": "4.0"},
"Meta": {"redis_version": "4.0"},
"Port": 8000
},
"Checks": [
@ -619,7 +617,7 @@ $ curl \
},
"OnlyPassing": true,
"Tags": ["primary"],
"ServiceMeta": { "mysql_version": "5.7.20" },
"Meta": { "mysql_version": "5.7.20" },
"NodeMeta": {"instance_type": "m3.large"}
}
}