summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/completion.go7
-rw-r--r--cmd/podman/common/completion_test.go4
2 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index 0db9f7351..3c614c0e1 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -1084,7 +1084,12 @@ func getStructFields(f reflect.Value, prefix string) []string {
func getMethodNames(f reflect.Value, prefix string) []string {
suggestions := make([]string, 0, f.NumMethod())
for j := 0; j < f.NumMethod(); j++ {
- fname := f.Type().Method(j).Name
+ method := f.Type().Method(j)
+ // in a template we can only run functions with one return value
+ if method.Func.Type().NumOut() != 1 {
+ continue
+ }
+ fname := method.Name
if strings.HasPrefix(fname, prefix) {
// add method name with closing braces
suggestions = append(suggestions, fname+"}}")
diff --git a/cmd/podman/common/completion_test.go b/cmd/podman/common/completion_test.go
index c9e189961..63b99501f 100644
--- a/cmd/podman/common/completion_test.go
+++ b/cmd/podman/common/completion_test.go
@@ -37,6 +37,10 @@ func (c Car) internal() int {
return 0
}
+func (c Car) TwoOut() (string, string) {
+ return "", ""
+}
+
func TestAutocompleteFormat(t *testing.T) {
testStruct := struct {
Name string