EnableTagDrift in NodeService struct

This commit is contained in:
Shawn Cook 2015-08-18 10:34:55 -07:00
parent 134db62937
commit 6a835939b8
5 changed files with 35 additions and 18 deletions

View File

@ -683,9 +683,19 @@ func TestDecodeConfig(t *testing.T) {
t.Fatalf("err: %s", err)
}
// EnableTagDrift
input = `{"enable_tag_drift": true}`
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
if err != nil {
t.Fatalf("err: %s", err)
}
if !config.DisableUpdateCheck {
t.Fatalf("bad: %#v", config)
}
if !config.EnableTagDrift {
t.Fatalf("bad: %#v", config)
}
if !config.DisableAnonymousSignature {
t.Fatalf("bad: %#v", config)
}
@ -1189,6 +1199,7 @@ func TestMergeConfig(t *testing.T) {
StatsitePrefix: "stats_prefix",
StatsdAddr: "127.0.0.1:7251",
DisableUpdateCheck: true,
EnableTagDrift: true,
DisableAnonymousSignature: true,
HTTPAPIResponseHeaders: map[string]string{
"Access-Control-Allow-Origin": "*",

View File

@ -379,6 +379,7 @@ func (l *localState) setSyncState() error {
}
// If our definition is different, we need to update it
l.logger.Printf("[ERR] services: %v", service)
equal := reflect.DeepEqual(existing, service)
l.serviceStatus[id] = syncStatus{inSync: equal}
}

View File

@ -6,23 +6,25 @@ import (
// ServiceDefinition is used to JSON decode the Service definitions
type ServiceDefinition struct {
ID string
Name string
Tags []string
Address string
Port int
Check CheckType
Checks CheckTypes
Token string
ID string
Name string
Tags []string
Address string
Port int
Check CheckType
Checks CheckTypes
Token string
EnableTagDrift bool
}
func (s *ServiceDefinition) NodeService() *structs.NodeService {
ns := &structs.NodeService{
ID: s.ID,
Service: s.Name,
Tags: s.Tags,
Address: s.Address,
Port: s.Port,
ID: s.ID,
Service: s.Name,
Tags: s.Tags,
Address: s.Address,
Port: s.Port,
EnableTagDrift: s.EnableTagDrift,
}
if ns.ID == "" && ns.Service != "" {
ns.ID = ns.Service

View File

@ -245,11 +245,12 @@ type ServiceNodes []ServiceNode
// NodeService is a service provided by a node
type NodeService struct {
ID string
Service string
Tags []string
Address string
Port int
ID string
Service string
Tags []string
Address string
Port int
EnableTagDrift bool
}
type NodeServices struct {
Node Node

View File

@ -55,6 +55,7 @@ type TestServerConfig struct {
DataDir string `json:"data_dir,omitempty"`
Datacenter string `json:"datacenter,omitempty"`
DisableCheckpoint bool `json:"disable_update_check"`
EnableTagDrift bool `json:"enable_tag_drift"`
LogLevel string `json:"log_level,omitempty"`
Bind string `json:"bind_addr,omitempty"`
Addresses *TestAddressConfig `json:"addresses,omitempty"`
@ -77,6 +78,7 @@ func defaultServerConfig() *TestServerConfig {
return &TestServerConfig{
NodeName: fmt.Sprintf("node%d", idx),
DisableCheckpoint: true,
EnableTagDrift: true,
Bootstrap: true,
Server: true,
LogLevel: "debug",