From 15fa8ad307d7b988b395446055ca23a3610859e1 Mon Sep 17 00:00:00 2001 From: catsby Date: Fri, 2 Dec 2022 13:07:26 -0600 Subject: [PATCH 1/2] filter out empty names from context list --- internal/clicontext/storage.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/clicontext/storage.go b/internal/clicontext/storage.go index f6c7502f527..7b1c176f419 100644 --- a/internal/clicontext/storage.go +++ b/internal/clicontext/storage.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strings" ) // Storage is the primary struct for interacting with stored CLI contexts. @@ -50,7 +51,10 @@ func (m *Storage) List() ([]string, error) { continue } - result = append(result, m.nameFromPath(n)) + // filter out possible non .hcl files + if strings.HasSuffix(n, ".hcl") { + result = append(result, m.nameFromPath(n)) + } } return result, nil From 8f814f4af2f283d2f842b8c31511fc4491dd439b Mon Sep 17 00:00:00 2001 From: catsby Date: Fri, 2 Dec 2022 13:35:25 -0600 Subject: [PATCH 2/2] changelog --- .changelog/4257.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/4257.txt diff --git a/.changelog/4257.txt b/.changelog/4257.txt new file mode 100644 index 00000000000..98f254a2a7e --- /dev/null +++ b/.changelog/4257.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli/context: fix possible error when listing contexts if a non waypoint context file exists in the context directory +``` \ No newline at end of file