Skip to content

Commit 41857f3

Browse files
authored
fix(cd): update cluster provider handling to use Distro and CurrentVersion (#662)
1 parent e7ea708 commit 41857f3

File tree

5 files changed

+22
-43
lines changed

5 files changed

+22
-43
lines changed

cmd/command/cd/cd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import (
44
"fmt"
55
"os"
66

7+
"github.com/urfave/cli"
8+
"helm.sh/helm/v3/pkg/action"
9+
710
"github.com/pluralsh/plural-cli/pkg/cd"
811
"github.com/pluralsh/plural-cli/pkg/client"
912
"github.com/pluralsh/plural-cli/pkg/common"
1013
"github.com/pluralsh/plural-cli/pkg/config"
1114
"github.com/pluralsh/plural-cli/pkg/console"
1215
"github.com/pluralsh/plural-cli/pkg/utils"
13-
"github.com/urfave/cli"
14-
"helm.sh/helm/v3/pkg/action"
1516
)
1617

1718
func init() {
@@ -171,8 +172,8 @@ func confirmCluster(url, token string) (bool, error) {
171172
if clusterFragment.Handle != nil {
172173
handle = *clusterFragment.Handle
173174
}
174-
if clusterFragment.Provider != nil {
175-
provider = clusterFragment.Provider.Name
175+
if clusterFragment.Distro != nil {
176+
provider = string(*clusterFragment.Distro)
176177
}
177178
return common.Confirm(fmt.Sprintf("Are you sure you want to install deploy operator for the cluster:\nName: %s\nHandle: %s\nProvider: %s\n", myCluster.MyCluster.Name, handle, provider), "PLURAL_INSTALL_AGENT_CONFIRM"), nil
178179
}

cmd/command/cd/cd_clusters.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import (
66

77
"github.com/AlecAivazis/survey/v2"
88
gqlclient "github.com/pluralsh/console/go/client"
9+
"github.com/pluralsh/polly/containers"
10+
"github.com/samber/lo"
11+
"github.com/urfave/cli"
12+
913
"github.com/pluralsh/plural-cli/pkg/cd"
1014
"github.com/pluralsh/plural-cli/pkg/common"
1115
"github.com/pluralsh/plural-cli/pkg/console"
1216
"github.com/pluralsh/plural-cli/pkg/console/errors"
1317
"github.com/pluralsh/plural-cli/pkg/kubernetes/config"
1418
"github.com/pluralsh/plural-cli/pkg/utils"
15-
"github.com/pluralsh/polly/containers"
16-
"github.com/samber/lo"
17-
"github.com/urfave/cli"
1819
)
1920

2021
var providerSurvey = []*survey.Question{
@@ -126,19 +127,19 @@ func (p *Plural) handleListClusters(_ *cli.Context) error {
126127
}
127128
headers := []string{"Id", "Name", "Handle", "Version", "Provider"}
128129
return utils.PrintTable(clusters, headers, func(cl *gqlclient.ClusterEdgeFragment) ([]string, error) {
129-
provider := ""
130-
if cl.Node.Provider != nil {
131-
provider = cl.Node.Provider.Name
130+
var distro gqlclient.ClusterDistro
131+
if cl.Node.Distro != nil {
132+
distro = *cl.Node.Distro
132133
}
133134
handle := ""
134135
if cl.Node.Handle != nil {
135136
handle = *cl.Node.Handle
136137
}
137138
version := ""
138139
if cl.Node.Version != nil {
139-
version = *cl.Node.Version
140+
version = *cl.Node.CurrentVersion
140141
}
141-
return []string{cl.Node.ID, cl.Node.Name, handle, version, provider}, nil
142+
return []string{cl.Node.ID, cl.Node.Name, handle, version, string(distro)}, nil
142143
})
143144
}
144145

@@ -233,8 +234,8 @@ func (p *Plural) handleUpdateCluster(c *cli.Context) error {
233234
headers := []string{"Id", "Name", "Handle", "Version", "Provider"}
234235
return utils.PrintTable([]gqlclient.ClusterFragment{*result.UpdateCluster}, headers, func(cl gqlclient.ClusterFragment) ([]string, error) {
235236
provider := ""
236-
if cl.Provider != nil {
237-
provider = cl.Provider.Name
237+
if cl.Distro != nil {
238+
provider = string(*cl.Distro)
238239
}
239240
handle := ""
240241
if cl.Handle != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ require (
4040
github.com/mitchellh/mapstructure v1.5.0
4141
github.com/olekukonko/tablewriter v0.0.5
4242
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
43-
github.com/pluralsh/console/go/client v1.37.0
43+
github.com/pluralsh/console/go/client v1.49.0
4444
github.com/pluralsh/console/go/controller v0.0.0-20250430123026-a75a764f035b
4545
github.com/pluralsh/gqlclient v1.12.2
4646
github.com/pluralsh/plural-operator v0.5.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
567567
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
568568
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
569569
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
570-
github.com/pluralsh/console/go/client v1.37.0 h1:lO+WCfmw/p9aYn9zUDirkbRpmWLdT72k7z713XR74CY=
571-
github.com/pluralsh/console/go/client v1.37.0/go.mod h1:rPx6hufc/s17Wzy+7C4ZnA1nmn1JR0m4JeoxAQYj8+4=
570+
github.com/pluralsh/console/go/client v1.49.0 h1:XoGxQ5kUScuZWxLh+rGcPluOEFHVHzXaRQbxl+00uUw=
571+
github.com/pluralsh/console/go/client v1.49.0/go.mod h1:2rzO4sns8H+0QtvRqKrFfCnzrvmTcPpsEXmQAgSRFrE=
572572
github.com/pluralsh/console/go/controller v0.0.0-20250430123026-a75a764f035b h1:XtEoflAGAT+tPAEw5MNoyu+8ziaZuXVwjpTZbP1o050=
573573
github.com/pluralsh/console/go/controller v0.0.0-20250430123026-a75a764f035b/go.mod h1:TQ/AdKBjZqB9f9s0SHpOVRON7bktahs8Ieh00Rylxp8=
574574
github.com/pluralsh/controller-reconcile-helper v0.1.0 h1:BV3dYZFH5rn8ZvZjtpkACSv/GmLEtRftNQj/Y4ddHEo=

pkg/console/describe.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,17 @@ func DescribeCluster(cluster *consoleclient.ClusterFragment) (string, error) {
4242
if cluster.Handle != nil {
4343
w.Write(Level0, "Handle:\t@%s\n", *cluster.Handle)
4444
}
45-
if cluster.Version != nil {
46-
w.Write(Level0, "Version:\t%s\n", *cluster.Version)
47-
}
4845
if cluster.CurrentVersion != nil {
49-
w.Write(Level0, "Current Version:\t%s\n", *cluster.CurrentVersion)
46+
w.Write(Level0, "Version:\t%s\n", *cluster.CurrentVersion)
5047
}
5148
if cluster.PingedAt != nil {
5249
w.Write(Level0, "Pinged At:\t%s\n", *cluster.PingedAt)
5350
}
5451
if cluster.Self != nil {
5552
w.Write(Level0, "Self:\t%v\n", *cluster.Self)
5653
}
57-
58-
if cluster.Provider != nil {
59-
w.Write(Level0, "Provider:\n")
60-
w.Write(Level1, "Id:\t%s\n", cluster.Provider.ID)
61-
w.Write(Level1, "Name:\t%s\n", cluster.Provider.Name)
62-
w.Write(Level1, "Namespace:\t%s\n", cluster.Provider.Namespace)
63-
w.Write(Level1, "Editable:\t%v\n", *cluster.Provider.Editable)
64-
w.Write(Level1, "Cloud:\t%v\n", cluster.Provider.Cloud)
65-
if cluster.Provider.Repository != nil {
66-
w.Write(Level1, "Git:\n")
67-
w.Write(Level2, "Id:\t%s\n", cluster.Provider.Repository.ID)
68-
w.Write(Level2, "Url:\t%s\n", cluster.Provider.Repository.URL)
69-
if cluster.Provider.Repository.AuthMethod != nil {
70-
w.Write(Level2, "Auth Method:\t%v\n", *cluster.Provider.Repository.AuthMethod)
71-
}
72-
if cluster.Provider.Repository.Health != nil {
73-
w.Write(Level2, "Health:\t%v\n", *cluster.Provider.Repository.Health)
74-
}
75-
if cluster.Provider.Repository.Error != nil {
76-
w.Write(Level2, "Error:\t%s\n", *cluster.Provider.Repository.Error)
77-
}
78-
}
54+
if cluster.Distro != nil {
55+
w.Write(Level0, "Distro:\t%s\n", *cluster.Distro)
7956
}
8057

8158
return nil

0 commit comments

Comments
 (0)