From c6d4f20da7c7b4ef39b9cf544cac0ad18eda36a2 Mon Sep 17 00:00:00 2001 From: nitishfy Date: Tue, 1 Oct 2024 18:20:30 +0530 Subject: [PATCH] add a plugin Signed-off-by: nitishfy --- cmd/argocd/commands/plugin_test.go | 8 +++++++- cmd/argocd/commands/testdata/argocd-foo | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 cmd/argocd/commands/testdata/argocd-foo diff --git a/cmd/argocd/commands/plugin_test.go b/cmd/argocd/commands/plugin_test.go index 8f0c453871ef3..65b6d9c0b6f5e 100644 --- a/cmd/argocd/commands/plugin_test.go +++ b/cmd/argocd/commands/plugin_test.go @@ -59,7 +59,7 @@ func (t *testPluginHandler) LookForPlugin(filename string) (string, bool) { return "", false } -func (t testPluginHandler) ExecutePlugin(executablePath string, cmdArgs, environment []string) error { +func (t *testPluginHandler) ExecutePlugin(executablePath string, cmdArgs, environment []string) error { t.executed = true t.executedPlugin = executablePath t.withArgs = cmdArgs @@ -81,6 +81,12 @@ func Test_ArgoCDPluginHandler(t *testing.T) { expectedPlugin: "", expectPluginArgs: []string{}, }, + { + name: "test that a plugin executable is found based on command args", + args: []string{"argocd", "foo"}, + expectedPlugin: "testdata/argocd-foo", + expectPluginArgs: []string{}, + }, } for _, tt := range tests { diff --git a/cmd/argocd/commands/testdata/argocd-foo b/cmd/argocd/commands/testdata/argocd-foo new file mode 100644 index 0000000000000..5ef179a9f1810 --- /dev/null +++ b/cmd/argocd/commands/testdata/argocd-foo @@ -0,0 +1,18 @@ +#!/bin/bash + +# optional argument handling +if [[ "$1" == "version" ]] +then + echo "1.0.0" + exit 0 +fi + +# optional argument handling +if [[ "$1" == "config" ]] +then + echo "$KUBECONFIG" + exit 0 +fi + +echo "I am a plugin named argocd-foo" +