From 362192931cbba702c023a3eef500d96ef4182a52 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Thu, 14 Nov 2024 16:18:25 -0500 Subject: [PATCH] Fix an issue where path prefix was presumed for variables --- command/meta.go | 6 +++++- command/var_list.go | 28 +++++++++++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/command/meta.go b/command/meta.go index 55532a67171..51653844080 100644 --- a/command/meta.go +++ b/command/meta.go @@ -482,9 +482,13 @@ var CommandUIRoutes = map[string]UIRoute{ Description: "View allocation details", }, "var list": { - Path: "/variables/path/:prefix", + Path: "/variables", Description: "View Nomad variables", }, + "var list prefix": { + Path: "/variables/path/:prefix", + Description: "View Nomad variables at this path", + }, "var get": { Path: "/variables/var/:path@:namespace", Description: "View variable details", diff --git a/command/var_list.go b/command/var_list.go index dfceef4146c..71a1a5155cf 100644 --- a/command/var_list.go +++ b/command/var_list.go @@ -217,15 +217,25 @@ func (c *VarListCommand) Run(args []string) int { c.Ui.Warn(fmt.Sprintf("Next page token: %s", qm.NextToken)) } - hint, _ := c.Meta.showUIPath(UIHintContext{ - Command: "var list", - PathParams: map[string]string{ - "prefix": prefix, - }, - OpenURL: openURL, - }) - if hint != "" { - c.Ui.Output(hint) + if prefix != "" { + hint, _ := c.Meta.showUIPath(UIHintContext{ + Command: "var list prefix", + PathParams: map[string]string{ + "prefix": prefix, + }, + OpenURL: openURL, + }) + if hint != "" { + c.Ui.Output(hint) + } + } else { + hint, _ := c.Meta.showUIPath(UIHintContext{ + Command: "var list", + OpenURL: openURL, + }) + if hint != "" { + c.Ui.Output(hint) + } } return 0