Skip to content

Commit

Permalink
🧹🐛 Don't show private resources in the shell auto complete (#4321)
Browse files Browse the repository at this point in the history
* feat: skip private packages in suggestions

* fix: test
  • Loading branch information
slntopp authored Jul 9, 2024
1 parent 73ce16e commit d183262
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions mqlc/mqlc.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,23 @@ func addResourceSuggestions(schema resources.ResourcesSchema, name string, res *

suggested := findFuzzy(name, names)

res.Suggestions = make([]*llx.Documentation, len(suggested))
var info *resources.ResourceInfo
for i := range suggested {
field := suggested[i].Target
info = resourceInfos[field]
if info != nil {
res.Suggestions[i] = &llx.Documentation{
if info.GetPrivate() {
continue
}
res.Suggestions = append(res.Suggestions, &llx.Documentation{
Field: field,
Title: info.Title,
Desc: info.Desc,
}
})
} else {
res.Suggestions[i] = &llx.Documentation{
res.Suggestions = append(res.Suggestions, &llx.Documentation{
Field: field,
}
})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mqlc/mqlc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ func TestSuggestions(t *testing.T) {
{
// resource suggestions
"ssh",
[]string{"os.unix.sshd", "sshd", "sshd.config", "sshd.config.matchBlock", "windows.security.health"},
[]string{"os.unix.sshd", "sshd", "sshd.config", "windows.security.health"},
errors.New("cannot find resource for identifier 'ssh'"),
nil,
},
Expand Down

0 comments on commit d183262

Please sign in to comment.