From 115ac6d5296789c0d5d9bf387d1e516f5af3cf53 Mon Sep 17 00:00:00 2001 From: ThedosiouTh Date: Thu, 30 Jun 2022 18:49:28 +0300 Subject: [PATCH] Use switch/case instead of static map for simplicity Signed-off-by: ThedosiouTh --- cmd/compatibility/convert.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/compatibility/convert.go b/cmd/compatibility/convert.go index c92a6fdae..c9fbf7df2 100644 --- a/cmd/compatibility/convert.go +++ b/cmd/compatibility/convert.go @@ -43,15 +43,6 @@ func getStringFlags() []string { } } -var argToActualArgument = map[string]string{ - "--verbose": "--debug", - // docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it - "-h": "--help", - // redirect --version pseudo-command to actual command - "--version": "version", - "-v": "version", -} - // Convert transforms standalone docker-compose args into CLI plugin compliant ones func Convert(args []string) []string { var rootFlags []string @@ -67,9 +58,18 @@ func Convert(args []string) []string { command = append(command, args[i:]...) break } - if actualArgument, ok := argToActualArgument[arg]; ok { - arg = actualArgument + + switch arg { + case "--verbose": + arg = "--debug" + case "-h": + // docker cli has deprecated -h to avoid ambiguity with -H, while docker-compose still support it + arg = "--help" + case "--version", "-v": + // redirect --version pseudo-command to actual command + arg = "version" } + if contains(getBoolFlags(), arg) { rootFlags = append(rootFlags, arg) continue