From afce1abbfbc34ed59e14f386a99238c5553363cd Mon Sep 17 00:00:00 2001 From: Aalok Ahluwalia Date: Mon, 7 Oct 2019 11:56:52 -0700 Subject: [PATCH] =?UTF-8?q?Issue=20#2396=20argocd=20list=20command=20shoul?= =?UTF-8?q?d=20have=20filter=20options=20like=20by=20pr=E2=80=A6=20(#2421)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/argocd/commands/app.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/argocd/commands/app.go b/cmd/argocd/commands/app.go index c71ce2d2b0..b6a86b7499 100644 --- a/cmd/argocd/commands/app.go +++ b/cmd/argocd/commands/app.go @@ -1031,7 +1031,8 @@ func printApplicationTable(apps []argoappv1.Application, output *string) { // NewApplicationListCommand returns a new instance of an `argocd app list` command func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { var ( - output string + output string + projects []string ) var command = &cobra.Command{ Use: "list", @@ -1041,14 +1042,19 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co defer util.Close(conn) apps, err := appIf.List(context.Background(), &applicationpkg.ApplicationQuery{}) errors.CheckError(err) + appList := apps.Items + if len(projects) != 0 { + appList = argo.FilterByProjects(appList, projects) + } if output == "name" { - printApplicationNames(apps.Items) + printApplicationNames(appList) } else { - printApplicationTable(apps.Items, &output) + printApplicationTable(appList, &output) } }, } command.Flags().StringVarP(&output, "output", "o", "wide", "Output format. One of: wide|name") + command.Flags().StringArrayVarP(&projects, "project", "p", []string{}, "Filter by project name") return command }