From b4290524e94a7f338f5fa38a953de535fde4d2be Mon Sep 17 00:00:00 2001 From: James Netherton Date: Mon, 5 Aug 2019 08:54:48 +0100 Subject: [PATCH] fix: Improve kamel get to enable specifying integration name fixes #893 --- pkg/cmd/get.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/get.go b/pkg/cmd/get.go index 8a13d73941..6cfbd7b92e 100644 --- a/pkg/cmd/get.go +++ b/pkg/cmd/get.go @@ -38,16 +38,16 @@ func newCmdGet(rootCmdOptions *RootCmdOptions) *cobra.Command { RootCmdOptions: rootCmdOptions, } cmd := cobra.Command{ - Use: "get", - Short: "Get all integrations deployed on Kubernetes", - Long: `Get the status of all integrations deployed on on Kubernetes.`, + Use: "get [integration]", + Short: "Get integrations deployed on Kubernetes", + Long: `Get the status of integrations deployed on on Kubernetes.`, RunE: options.run, } return &cmd } -func (o *getCmdOptions) run(_ *cobra.Command, _ []string) error { +func (o *getCmdOptions) run(_ *cobra.Command, args []string) error { c, err := o.GetCmdClient() if err != nil { return err @@ -62,7 +62,14 @@ func (o *getCmdOptions) run(_ *cobra.Command, _ []string) error { namespace := o.Namespace - err = c.List(o.Context, &k8sclient.ListOptions{Namespace: namespace}, &integrationList) + options := k8sclient.ListOptions{Namespace: namespace} + if len(args) == 1 { + if err := options.SetFieldSelector("metadata.name=" + args[0]); err != nil { + return err + } + } + + err = c.List(o.Context, &options, &integrationList) if err != nil { return err }