From 5ba4c17d78deb42c125f927af960c2f7e6aab4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Tue, 14 Oct 2025 14:40:27 +0200 Subject: [PATCH] cli/command/container: Simplify with slices.Contains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- cli/command/container/opts.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index 35c85acf57..c2253d6c00 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -14,6 +14,7 @@ import ( "path" "path/filepath" "reflect" + "slices" "strings" "time" @@ -1133,10 +1134,8 @@ func validateLinuxPath(val string, validator func(string) bool) (string, error) // validateAttach validates that the specified string is a valid attach option. func validateAttach(val string) (string, error) { s := strings.ToLower(val) - for _, str := range []string{"stdin", "stdout", "stderr"} { - if s == str { - return s, nil - } + if slices.Contains([]string{"stdin", "stdout", "stderr"}, s) { + return s, nil } return val, errors.New("valid streams are STDIN, STDOUT and STDERR") }