Skip to content

Commit 5ba4c17

Browse files
committed
cli/command/container: Simplify with slices.Contains
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent d252afa commit 5ba4c17

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cli/command/container/opts.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"path"
1515
"path/filepath"
1616
"reflect"
17+
"slices"
1718
"strings"
1819
"time"
1920

@@ -1133,10 +1134,8 @@ func validateLinuxPath(val string, validator func(string) bool) (string, error)
11331134
// validateAttach validates that the specified string is a valid attach option.
11341135
func validateAttach(val string) (string, error) {
11351136
s := strings.ToLower(val)
1136-
for _, str := range []string{"stdin", "stdout", "stderr"} {
1137-
if s == str {
1138-
return s, nil
1139-
}
1137+
if slices.Contains([]string{"stdin", "stdout", "stderr"}, s) {
1138+
return s, nil
11401139
}
11411140
return val, errors.New("valid streams are STDIN, STDOUT and STDERR")
11421141
}

0 commit comments

Comments
 (0)