From 290305fcf0cf26bcf3cf94a89f24d016b5d4e529 Mon Sep 17 00:00:00 2001 From: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> Date: Thu, 2 May 2024 10:46:46 +0530 Subject: [PATCH] Fix positional args usage in kick (#1556) Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com> --- cli/pkg/kctrl/cmd/package/repository/kick.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/pkg/kctrl/cmd/package/repository/kick.go b/cli/pkg/kctrl/cmd/package/repository/kick.go index 54732be56..68cbb2a3f 100644 --- a/cli/pkg/kctrl/cmd/package/repository/kick.go +++ b/cli/pkg/kctrl/cmd/package/repository/kick.go @@ -42,7 +42,7 @@ func NewKickCmd(o *KickOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Comman cmd := &cobra.Command{ Use: "kick", Short: "Trigger reconciliation for repository", - RunE: func(_ *cobra.Command, _ []string) error { return o.Run() }, + RunE: func(_ *cobra.Command, args []string) error { return o.Run(args) }, Example: cmdcore.Examples{ cmdcore.Example{"Trigger reconciliation for repository", []string{"package", "repository", "kick", "-r", "sample-repo"}}, @@ -70,7 +70,13 @@ func NewKickCmd(o *KickOptions, flagsFactory cmdcore.FlagsFactory) *cobra.Comman return cmd } -func (o *KickOptions) Run() error { +func (o *KickOptions) Run(args []string) error { + if o.pkgCmdTreeOpts.PositionalArgs { + if len(args) > 0 { + o.Name = args[0] + } + } + if len(o.Name) == 0 { return fmt.Errorf("Expected repository name to be non empty") }