Skip to content

Commit e326955

Browse files
authored
Include channel ID and sequence in get versions command (#5553)
* Include channel ID and sequence in get versions command
1 parent db6e1dc commit e326955

2 files changed

Lines changed: 24 additions & 15 deletions

File tree

cmd/kots/cli/get-versions.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"net/url"
99
"os"
10+
"strconv"
1011

1112
"github.com/pkg/errors"
1213
"github.com/replicatedhq/kots/pkg/auth"
@@ -115,13 +116,19 @@ func getVersionsCmd(cmd *cobra.Command, args []string) error {
115116
appVersionResponse := []print.AppVersionResponse{}
116117

117118
for _, version := range appVersions.VersionHistory {
119+
channelSequence, err := strconv.ParseInt(version.UpdateCursor, 10, 64)
120+
if err != nil {
121+
return errors.Wrap(err, "failed to parse channel sequence")
122+
}
118123
response := print.AppVersionResponse{
119-
VersionLabel: version.VersionLabel,
120-
Sequence: version.Sequence,
121-
CreatedOn: *version.CreatedOn,
122-
DeployedAt: version.DeployedAt,
123-
Status: string(version.Status),
124-
Source: version.Source,
124+
VersionLabel: version.VersionLabel,
125+
Sequence: version.Sequence,
126+
CreatedOn: *version.CreatedOn,
127+
DeployedAt: version.DeployedAt,
128+
Status: string(version.Status),
129+
Source: version.Source,
130+
ChannelID: version.ChannelID,
131+
ChannelSequence: channelSequence,
125132
}
126133

127134
appVersionResponse = append(appVersionResponse, response)

pkg/print/versions.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import (
77
)
88

99
type AppVersionResponse struct {
10-
VersionLabel string `json:"versionLabel"`
11-
Sequence int64 `json:"sequence"`
12-
CreatedOn time.Time `json:"createdOn"`
13-
Status string `json:"status"`
14-
DeployedAt *time.Time `json:"deployedAt"`
15-
Source string `json:"source"`
10+
VersionLabel string `json:"versionLabel"`
11+
Sequence int64 `json:"sequence"`
12+
CreatedOn time.Time `json:"createdOn"`
13+
Status string `json:"status"`
14+
DeployedAt *time.Time `json:"deployedAt"`
15+
Source string `json:"source"`
16+
ChannelID string `json:"channelId"`
17+
ChannelSequence int64 `json:"channelSequence"`
1618
}
1719

1820
func Versions(versions []AppVersionResponse, format string) {
@@ -33,9 +35,9 @@ func printVersionsTable(versions []AppVersionResponse) {
3335
w := NewTabWriter()
3436
defer w.Flush()
3537

36-
fmtColumns := "%s\t%v\t%s\t%s\n"
37-
fmt.Fprintf(w, fmtColumns, "VERSION", "SEQUENCE", "STATUS", "SOURCE")
38+
fmtColumns := "%s\t%v\t%s\t%s\t%s\t%v\n"
39+
fmt.Fprintf(w, fmtColumns, "VERSION", "SEQUENCE", "STATUS", "SOURCE", "CHANNEL ID", "CHANNEL SEQUENCE")
3840
for _, version := range versions {
39-
fmt.Fprintf(w, fmtColumns, version.VersionLabel, version.Sequence, version.Status, version.Source)
41+
fmt.Fprintf(w, fmtColumns, version.VersionLabel, version.Sequence, version.Status, version.Source, version.ChannelID, version.ChannelSequence)
4042
}
4143
}

0 commit comments

Comments
 (0)