From 0b12b2525702bb5231255419143e659d40f2279a Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 12 Apr 2024 16:26:21 -0400 Subject: [PATCH] updated to run the labeler plugin if -l is given, also updated tests --- pkg/src/labeler.go | 26 ++- ...c68db81593d1f4de140738fc692d95c093c4624cd4 | 14 ++ ...4e9e826a5e24b3cd65bbb51b024ad0a19cf97f3f62 | 14 ++ test/alias-test.sh | 172 ++++++++++++++++++ test/{test.sh => piped-tests.sh} | 65 ------- 5 files changed, 217 insertions(+), 74 deletions(-) create mode 100644 test/.cache/9ed7e73414370c1671c47dc68db81593d1f4de140738fc692d95c093c4624cd4 create mode 100644 test/.cache/b4ddfcc3e52d3476e3263e4e9e826a5e24b3cd65bbb51b024ad0a19cf97f3f62 create mode 100755 test/alias-test.sh rename test/{test.sh => piped-tests.sh} (70%) diff --git a/pkg/src/labeler.go b/pkg/src/labeler.go index fff2cc5..7a5c674 100755 --- a/pkg/src/labeler.go +++ b/pkg/src/labeler.go @@ -193,17 +193,21 @@ func (p ParamsStruct) aliasRun(args []string) error { i-- } if strings.HasPrefix(args[i], "--label") { - p.params["labelKey"] = strings.Split(args[i], "=")[1] - p.params["labelVal"] = strings.Split(args[i], "=")[2] - args = append(args[:i], args[i+1:]...) - i-- + if strings.Contains(args[i], "=") { + p.params["labelKey"] = strings.Split(args[i], "=")[1] + p.params["labelVal"] = strings.Split(args[i], "=")[2] + args = append(args[:i], args[i+1:]...) + i-- + } } if strings.HasPrefix(args[i], "-l") { - p.params["labelKey"] = strings.Split(args[i+1], "=")[0] - p.params["labelVal"] = strings.Split(args[i+1], "=")[1] - args = append(args[:i], args[i+2:]...) - i-- - i-- + if len(args) > i+1 && !strings.HasPrefix(args[i+1], "-") { + p.params["labelKey"] = strings.Split(args[i+1], "=")[0] + p.params["labelVal"] = strings.Split(args[i+1], "=")[1] + args = append(args[:i], args[i+2:]...) + i-- + i-- + } } } if p.flags["l-debug"] { @@ -286,6 +290,10 @@ func (p ParamsStruct) aliasRun(args []string) error { fmt.Printf("labeler.go: [debug] resources: Key: %s, Value: %s\n", key, value) } } + if p.params["l"] != "" { + log.Printf("\nlabeler plugin: %q:\n\n", "PluginLabeler") + p.PluginLabeler(false) + } } return nil diff --git a/test/.cache/9ed7e73414370c1671c47dc68db81593d1f4de140738fc692d95c093c4624cd4 b/test/.cache/9ed7e73414370c1671c47dc68db81593d1f4de140738fc692d95c093c4624cd4 new file mode 100644 index 0000000..098dd87 --- /dev/null +++ b/test/.cache/9ed7e73414370c1671c47dc68db81593d1f4de140738fc692d95c093c4624cd4 @@ -0,0 +1,14 @@ + >I§Fó(wÐ,2Å.Ygç¶ã¶Ó