mirror of https://github.com/status-im/consul.git
Merge pull request #2798 from hashicorp/f-lower-id
Forces user-supplied node IDs to lower case for consistency.
This commit is contained in:
commit
de78d70a33
|
@ -646,6 +646,7 @@ func (a *Agent) setupNodeID(config *Config) error {
|
|||
// If they've configured a node ID manually then just use that, as
|
||||
// long as it's valid.
|
||||
if config.NodeID != "" {
|
||||
config.NodeID = types.NodeID(strings.ToLower(string(config.NodeID)))
|
||||
if _, err := uuid.ParseUUID(string(config.NodeID)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -674,6 +675,7 @@ func (a *Agent) setupNodeID(config *Config) error {
|
|||
}
|
||||
|
||||
nodeID := strings.TrimSpace(string(rawID))
|
||||
nodeID = strings.ToLower(nodeID)
|
||||
if _, err := uuid.ParseUUID(nodeID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ func TestAgent_NodeID(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
c.NodeID = types.NodeID(newID)
|
||||
c.NodeID = types.NodeID(strings.ToUpper(newID))
|
||||
if err := agent.setupNodeID(c); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ func TestAgent_NodeID(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set a valid ID via the file.
|
||||
if err := ioutil.WriteFile(fileID, []byte("adf4238a-882b-9ddc-4a9d-5b6758e4159e"), 0600); err != nil {
|
||||
if err := ioutil.WriteFile(fileID, []byte("ADF4238a-882b-9ddc-4a9d-5b6758e4159e"), 0600); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
c.NodeID = ""
|
||||
|
|
Loading…
Reference in New Issue