mirror of
https://github.com/status-im/consul.git
synced 2025-02-19 17:14:37 +00:00
Rename EnableTagOverride and update formatting
This commit is contained in:
parent
d7ce0b3c6b
commit
66fd8fb2a0
@ -379,7 +379,7 @@ func (l *localState) setSyncState() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If our definition is different, we need to update it
|
// If our definition is different, we need to update it
|
||||||
if existing.EnableTagDrift {
|
if existing.EnableTagOverride {
|
||||||
existing.Tags = service.Tags
|
existing.Tags = service.Tags
|
||||||
}
|
}
|
||||||
equal := reflect.DeepEqual(existing, service)
|
equal := reflect.DeepEqual(existing, service)
|
||||||
|
@ -169,7 +169,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgentAntiEntropy_EnableTagDrift(t *testing.T) {
|
func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
|
||||||
conf := nextConfig()
|
conf := nextConfig()
|
||||||
dir, agent := makeAgent(t, conf)
|
dir, agent := makeAgent(t, conf)
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@ -184,13 +184,13 @@ func TestAgentAntiEntropy_EnableTagDrift(t *testing.T) {
|
|||||||
}
|
}
|
||||||
var out struct{}
|
var out struct{}
|
||||||
|
|
||||||
// EnableTagDrift = true
|
// EnableTagOverride = true
|
||||||
srv1 := &structs.NodeService{
|
srv1 := &structs.NodeService{
|
||||||
ID: "svc_id1",
|
ID: "svc_id1",
|
||||||
Service: "svc1",
|
Service: "svc1",
|
||||||
Tags: []string{"tag1"},
|
Tags: []string{"tag1"},
|
||||||
Port: 6100,
|
Port: 6100,
|
||||||
EnableTagDrift: true,
|
EnableTagOverride: true,
|
||||||
}
|
}
|
||||||
agent.state.AddService(srv1, "")
|
agent.state.AddService(srv1, "")
|
||||||
srv1_mod := new(structs.NodeService)
|
srv1_mod := new(structs.NodeService)
|
||||||
@ -202,13 +202,13 @@ func TestAgentAntiEntropy_EnableTagDrift(t *testing.T) {
|
|||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnableTagDrift = false
|
// EnableTagOverride = false
|
||||||
srv2 := &structs.NodeService{
|
srv2 := &structs.NodeService{
|
||||||
ID: "svc_id2",
|
ID: "svc_id2",
|
||||||
Service: "svc2",
|
Service: "svc2",
|
||||||
Tags: []string{"tag2"},
|
Tags: []string{"tag2"},
|
||||||
Port: 6200,
|
Port: 6200,
|
||||||
EnableTagDrift: false,
|
EnableTagOverride: false,
|
||||||
}
|
}
|
||||||
agent.state.AddService(srv2, "")
|
agent.state.AddService(srv2, "")
|
||||||
srv2_mod := new(structs.NodeService)
|
srv2_mod := new(structs.NodeService)
|
||||||
@ -238,18 +238,18 @@ func TestAgentAntiEntropy_EnableTagDrift(t *testing.T) {
|
|||||||
for id, serv := range services.NodeServices.Services {
|
for id, serv := range services.NodeServices.Services {
|
||||||
switch id {
|
switch id {
|
||||||
case "svc_id1":
|
case "svc_id1":
|
||||||
if serv.ID!="svc_id1" ||
|
if serv.ID != "svc_id1" ||
|
||||||
serv.Service!="svc1" ||
|
serv.Service != "svc1" ||
|
||||||
serv.Port!=6100 ||
|
serv.Port != 6100 ||
|
||||||
!reflect.DeepEqual(serv.Tags, []string{"tag1_mod"}) {
|
!reflect.DeepEqual(serv.Tags, []string{"tag1_mod"}) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv1)
|
t.Fatalf("bad: %v %v", serv, srv1)
|
||||||
}
|
}
|
||||||
case "svc_id2":
|
case "svc_id2":
|
||||||
if serv.ID!="svc_id2" ||
|
if serv.ID != "svc_id2" ||
|
||||||
serv.Service!="svc2" ||
|
serv.Service != "svc2" ||
|
||||||
serv.Port!=6200 ||
|
serv.Port != 6200 ||
|
||||||
!reflect.DeepEqual(serv.Tags, []string{"tag2"}) {
|
!reflect.DeepEqual(serv.Tags, []string{"tag2"}) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv2)
|
t.Fatalf("bad: %v %v", serv, srv2)
|
||||||
}
|
}
|
||||||
case "consul":
|
case "consul":
|
||||||
// ignore
|
// ignore
|
||||||
|
@ -6,25 +6,25 @@ import (
|
|||||||
|
|
||||||
// ServiceDefinition is used to JSON decode the Service definitions
|
// ServiceDefinition is used to JSON decode the Service definitions
|
||||||
type ServiceDefinition struct {
|
type ServiceDefinition struct {
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
Tags []string
|
Tags []string
|
||||||
Address string
|
Address string
|
||||||
Port int
|
Port int
|
||||||
Check CheckType
|
Check CheckType
|
||||||
Checks CheckTypes
|
Checks CheckTypes
|
||||||
Token string
|
Token string
|
||||||
EnableTagDrift bool
|
EnableTagOverride bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceDefinition) NodeService() *structs.NodeService {
|
func (s *ServiceDefinition) NodeService() *structs.NodeService {
|
||||||
ns := &structs.NodeService{
|
ns := &structs.NodeService{
|
||||||
ID: s.ID,
|
ID: s.ID,
|
||||||
Service: s.Name,
|
Service: s.Name,
|
||||||
Tags: s.Tags,
|
Tags: s.Tags,
|
||||||
Address: s.Address,
|
Address: s.Address,
|
||||||
Port: s.Port,
|
Port: s.Port,
|
||||||
EnableTagDrift: s.EnableTagDrift,
|
EnableTagOverride: s.EnableTagOverride,
|
||||||
}
|
}
|
||||||
if ns.ID == "" && ns.Service != "" {
|
if ns.ID == "" && ns.Service != "" {
|
||||||
ns.ID = ns.Service
|
ns.ID = ns.Service
|
||||||
|
@ -245,12 +245,12 @@ type ServiceNodes []ServiceNode
|
|||||||
|
|
||||||
// NodeService is a service provided by a node
|
// NodeService is a service provided by a node
|
||||||
type NodeService struct {
|
type NodeService struct {
|
||||||
ID string
|
ID string
|
||||||
Service string
|
Service string
|
||||||
Tags []string
|
Tags []string
|
||||||
Address string
|
Address string
|
||||||
Port int
|
Port int
|
||||||
EnableTagDrift bool
|
EnableTagOverride bool
|
||||||
}
|
}
|
||||||
type NodeServices struct {
|
type NodeServices struct {
|
||||||
Node Node
|
Node Node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user