Skip to content

Commit

Permalink
fix list deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz committed Sep 26, 2023
1 parent 61bf7e8 commit d6f3e5e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
13 changes: 8 additions & 5 deletions cmd/plural/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
}
Expand Down Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion pkg/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/console/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit d6f3e5e

Please sign in to comment.