From f0c3f09c0ce674dc069976713fbdffe371934a5b Mon Sep 17 00:00:00 2001 From: Peter Dannemann Date: Wed, 22 Nov 2023 11:23:30 -0500 Subject: [PATCH] fix docstring and error message --- pkg/admin/types.go | 3 ++- pkg/cli/cli.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/admin/types.go b/pkg/admin/types.go index b7365adf..9d25b85b 100644 --- a/pkg/admin/types.go +++ b/pkg/admin/types.go @@ -89,7 +89,8 @@ type ACLInfo struct { PermissionType ACLPermissionType `json:"permissionType"` } -// String is used both by fmt.Print and by Cobra in help text. +// FormatACLInfo formats an ACLInfo struct as a string, using the +// string version of all the fields. func FormatACLInfo(a ACLInfo) string { alias := struct { ResourceType string diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 4dd5fc32..eae432cb 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -181,7 +181,11 @@ func (c *CLIRunner) DeleteACL(ctx context.Context, filter kafka.DeleteACLsFilter } if len(clusterACLs) > 1 { - return fmt.Errorf("Delete filter should only match a single ACL, got: \n%+v ", formatACLs(clusterACLs)) + var formattedClusterACLs []string + for _, clusterACL := range clusterACLs { + formattedClusterACLs = append(formattedClusterACLs, admin.FormatACLInfo(clusterACL)) + } + return fmt.Errorf("Delete filter should only match a single ACL. Use more specific filter flags to narrow down on a single ACL. ACLs matching filter: \n%+v", strings.Join(formattedClusterACLs, "\n")) } clusterACL := clusterACLs[0]