Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Bug fix: Filter out empty names from context list #4257

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4257.txt
Original file line number Diff line number Diff line change
@@ -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
```
6 changes: 5 additions & 1 deletion internal/clicontext/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
)

// Storage is the primary struct for interacting with stored CLI contexts.
Expand Down Expand Up @@ -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
Expand Down