From 6d5156bbba4543f6bb885c8f3dc1a8dfecdee575 Mon Sep 17 00:00:00 2001 From: Drew Bailey <2614075+drewbailey@users.noreply.github.com> Date: Thu, 21 Nov 2019 14:51:48 -0500 Subject: [PATCH] Allows a node uuid prefix to be passed in --- command/agent_monitor.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/command/agent_monitor.go b/command/agent_monitor.go index 4d50faf6a..4dc466d2a 100644 --- a/command/agent_monitor.go +++ b/command/agent_monitor.go @@ -89,6 +89,28 @@ func (c *MonitorCommand) Run(args []string) int { return 1 } + // Query the node info and lookup prefix + if len(nodeID) == 1 { + c.Ui.Error(fmt.Sprintf("Node identifier must contain at least two characters.")) + return 1 + } + + if nodeID != "" { + nodeID = sanitizeUUIDPrefix(nodeID) + nodes, _, err := client.Nodes().PrefixList(nodeID) + if err != nil { + c.Ui.Error(fmt.Sprintf("Error querying node: %v", err)) + return 1 + } + + if len(nodes) > 1 { + out := formatNodeStubList(nodes, false) + c.Ui.Output(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", out)) + return 1 + } + nodeID = nodes[0].ID + } + params := map[string]string{ "log_level": logLevel, "node_id": nodeID,