From 251caad83344126a3f884ee1a3dc107dc982fdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Garcia?= Date: Fri, 17 Nov 2023 10:51:04 -0300 Subject: [PATCH] Fix flux install command so it returns an error when unexpected arguments are passed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Max Jonas Werner Signed-off-by: Vinícius Garcia --- cmd/flux/install.go | 1 + cmd/flux/install_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/cmd/flux/install.go b/cmd/flux/install.go index 795cc1aad7..bf0ee758de 100644 --- a/cmd/flux/install.go +++ b/cmd/flux/install.go @@ -36,6 +36,7 @@ import ( var installCmd = &cobra.Command{ Use: "install", + Args: cobra.NoArgs, Short: "Install or upgrade Flux", Long: `The install command deploys Flux in the specified namespace. If a previous version is installed, then an in-place upgrade will be performed.`, diff --git a/cmd/flux/install_test.go b/cmd/flux/install_test.go index f10f7d62a2..5cb0fa6643 100644 --- a/cmd/flux/install_test.go +++ b/cmd/flux/install_test.go @@ -37,6 +37,11 @@ func TestInstall(t *testing.T) { args: "install --namespace='@#[]'", assert: assertError("namespace must be a valid DNS label: \"@#[]\""), }, + { + name: "invalid sub-command", + args: "install unexpectedPosArg --namespace=example", + assert: assertError(`unknown command "unexpectedPosArg" for "flux install"`), + }, } for _, tt := range tests {