diff --git a/cmd/plural/cd.go b/cmd/plural/cd.go index a8901268..881c42ed 100644 --- a/cmd/plural/cd.go +++ b/cmd/plural/cd.go @@ -59,9 +59,10 @@ func (p *Plural) cdRepositoriesCommands() []cli.Command { func (p *Plural) cdServiceCommands() []cli.Command { return []cli.Command{ { - Name: "list", - Action: latestVersion(p.handleListClusterServices), - Usage: "list cluster services", + Name: "list", + ArgsUsage: "CLUSTER_ID", + Action: latestVersion(requireArgs(p.handleListClusterServices, []string{"CLUSTER_ID"})), + Usage: "list cluster services", }, } } @@ -112,12 +113,14 @@ func (p *Plural) handleListClusterServices(c *cli.Context) error { if err := p.InitConsoleClient(consoleToken, consoleURL); err != nil { return err } - sd, err := p.ConsoleClient.ListClusterServices() + clusterId := c.Args().Get(0) + + sd, err := p.ConsoleClient.ListClusterServices(clusterId) if err != nil { return err } - headers := []string{"Id", "Name", "Namespace", "Git URL", "Git Folder"} + headers := []string{"Id", "Name", "Namespace", "Git Ref", "Git Folder"} return utils.PrintTable(sd, headers, func(sd console.ServiceDeployment) ([]string, error) { return []string{sd.Id, sd.Name, sd.Namespace, sd.Git.Ref, sd.Git.Folder}, nil }) diff --git a/go.mod b/go.mod index e952ab2a..819fe0fd 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/packethost/packngo v0.29.0 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pluralsh/cluster-api-migration v0.2.15 - github.com/pluralsh/console-client-go v0.0.7 + github.com/pluralsh/console-client-go v0.0.8 github.com/pluralsh/gqlclient v1.10.0 github.com/pluralsh/plural-operator v0.5.5 github.com/pluralsh/polly v0.1.1 diff --git a/go.sum b/go.sum index f3202f42..b74fc4a3 100644 --- a/go.sum +++ b/go.sum @@ -1389,8 +1389,8 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pluralsh/cluster-api-migration v0.2.15 h1:TIfusD+wnhZTGmwNfIlKlKJOT2dE3rUaZawDJw98GjY= github.com/pluralsh/cluster-api-migration v0.2.15/go.mod h1:J6lEvC/70KouikX16mE331cxc3y3sBwtmfHGwZqu06w= -github.com/pluralsh/console-client-go v0.0.7 h1:Jb3jhMueTma7oE1+roGt+TKvIYK8cl0qsHfVxWhMCbQ= -github.com/pluralsh/console-client-go v0.0.7/go.mod h1:kZjk0pXAWnvyj+miXveCho4kKQaX1Tm3CGAM+iwurWU= +github.com/pluralsh/console-client-go v0.0.8 h1:BwWOt1ggBX/fxzY2+01dk8sBTz1jqT57o2y1Iz9Zxzk= +github.com/pluralsh/console-client-go v0.0.8/go.mod h1:kZjk0pXAWnvyj+miXveCho4kKQaX1Tm3CGAM+iwurWU= github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E= github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s= github.com/pluralsh/gqlclient v1.10.0 h1:ccYB+A0JbPYkEeVzdfajd29l65N6x/buSKPMMxM8OIA= diff --git a/pkg/console/console.go b/pkg/console/console.go index a9904fd6..142ead80 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -15,7 +15,7 @@ type consoleClient struct { type ConsoleClient interface { ListClusters() ([]Cluster, error) - ListClusterServices() ([]ServiceDeployment, error) + ListClusterServices(clusterId string) ([]ServiceDeployment, error) CreateRepository(url string, privateKey, passphrase, username, password *string) (*GitRepository, error) ListRepositories() ([]GitRepository, error) } diff --git a/pkg/console/services.go b/pkg/console/services.go index dc7e0f72..df69e02e 100644 --- a/pkg/console/services.go +++ b/pkg/console/services.go @@ -2,15 +2,15 @@ package console import "github.com/pluralsh/plural/pkg/api" -func (c *consoleClient) ListClusterServices() ([]ServiceDeployment, error) { +func (c *consoleClient) ListClusterServices(clusterId string) ([]ServiceDeployment, error) { output := []ServiceDeployment{} - result, err := c.pluralClient.ListServiceDeployment(c.ctx) + result, err := c.pluralClient.ListServiceDeployment(c.ctx, nil, nil, nil, &clusterId) if err != nil { return nil, api.GetErrorResponse(err, "ListClusterServices") } - for _, cs := range result.ClusterServices { - output = append(output, *convertServiceDeployment(cs)) + for _, cs := range result.ServiceDeployments.Edges { + output = append(output, *convertServiceDeployment(cs.Node)) } return output, nil }