Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cli/cmd/channel_inspect.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"

"github.com/spf13/cobra"
Expand All @@ -10,7 +11,7 @@ import (

// channelInspectCmd represents the channelInspect command
var channelInspectCmd = &cobra.Command{
Use: "inspect",
Use: "inspect CHANNEL_ID",
Short: "Show full details for a channel",
Long: "Show full details for a channel",
}
Expand All @@ -21,7 +22,7 @@ func init() {

func (r *runners) channelInspect(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf(cmd.UsageString())
return errors.New("channel ID is required")
}
chanID := args[0]

Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/channel_rm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"

"github.com/spf13/cobra"
Expand All @@ -19,7 +20,7 @@ func init() {

func (r *runners) channelRemove(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf("channel ID is required")
return errors.New("channel ID is required")
}
chanID := args[0]

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/release_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// releaseInspectCmd represents the inspect command
var releaseInspectCmd = &cobra.Command{
Use: "inspect",
Use: "inspect SEQUENCE",
Short: "Print the YAML config for a release",
Long: "Print the YAML config for a release",
}
Expand Down
7 changes: 3 additions & 4 deletions cli/cmd/release_promote.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cmd

import (
"errors"
"fmt"
"os"
"strconv"

"github.com/spf13/cobra"
Expand All @@ -14,7 +14,7 @@ var releaseVersion string

// releasePromoteCmd represents the releasePromote command
var releasePromoteCmd = &cobra.Command{
Use: "promote SEQUENCE CHANNEL",
Use: "promote SEQUENCE CHANNEL_ID",
Short: "Set the release for a channel",
Long: `Set the release for a channel

Expand All @@ -32,8 +32,7 @@ func init() {
func (r *runners) releasePromote(cmd *cobra.Command, args []string) error {
// parse sequence and channel ID positional arguments
if len(args) != 2 {
cmd.Usage()
os.Exit(1)
return errors.New("releasese sequence and channel ID are required")
}
seq, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/release_update.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"strconv"

Expand All @@ -26,7 +27,7 @@ func (r *runners) releaseUpdate(cmd *cobra.Command, args []string) error {
return fmt.Errorf("yaml is required")
}
if len(args) < 1 {
return fmt.Errorf("release sequence is required")
return errors.New("release sequence is required")
}
seq, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cli/print/channel_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package print

import (
"fmt"
"html/template"
"text/tabwriter"
"text/template"

channels "github.com/replicatedhq/replicated/gen/go/channels"
)

var channelReleasesTmplSrc = `CHANNEL_SEQUENCE RELEASE_SEQUENCE RELEASED VERSION REQUIRED AIRGAP_STATUS RELEASE_NOTES
{{ range . -}}
{{ .ChannelSequence }} {{ .ReleaseSequence }} {{ .Created }} {{ .Version }} {{ .Required }} {{ .AirgapBuildStatus}} {{ .ReleaseNotes }}
{{ .ChannelSequence }} {{ .ReleaseSequence }} {{ time .Created }} {{ .Version }} {{ .Required }} {{ .AirgapBuildStatus}} {{ .ReleaseNotes }}
{{ end }}`

var channelReleasesTmpl = template.Must(template.New("ChannelReleases").Parse(channelReleasesTmplSrc))
var channelReleasesTmpl = template.Must(template.New("ChannelReleases").Funcs(funcs).Parse(channelReleasesTmplSrc))

func ChannelReleases(w *tabwriter.Writer, releases []channels.ChannelRelease) error {
if len(releases) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion cli/print/channels.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package print

import (
"html/template"
"text/tabwriter"
"text/template"

channels "github.com/replicatedhq/replicated/gen/go/channels"
)
Expand Down
6 changes: 3 additions & 3 deletions cli/print/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
)

var releaseTmplSrc = `SEQUENCE: {{ .Sequence }}
CREATED: {{ .CreatedAt }}
EDITED: {{ .EditedAt }}
CREATED: {{ time .CreatedAt }}
EDITED: {{ time .EditedAt }}
CONFIG:
{{ .Config }}
`

var releaseTmpl = template.Must(template.New("Release").Parse(releaseTmplSrc))
var releaseTmpl = template.Must(template.New("Release").Funcs(funcs).Parse(releaseTmplSrc))

func Release(w *tabwriter.Writer, release *releases.AppRelease) error {
if err := releaseTmpl.Execute(w, release); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions cli/print/releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"strings"
"text/tabwriter"
"text/template"
"time"

releases "github.com/replicatedhq/replicated/gen/go/releases"
)

var releasesTmplSrc = `SEQUENCE VERSION CREATED EDITED ACTIVE_CHANNELS
{{ range . -}}
{{ .Sequence }} {{ .Version }} {{ .CreatedAt }} {{ .EditedAt }} {{ .ActiveChannels }}
{{ .Sequence }} {{ .Version }} {{ time .CreatedAt }} {{ .EditedAt }} {{ .ActiveChannels }}
{{ end }}`

var releasesTmpl = template.Must(template.New("Releases").Parse(releasesTmplSrc))
var releasesTmpl = template.Must(template.New("Releases").Funcs(funcs).Parse(releasesTmplSrc))

func Releases(w *tabwriter.Writer, appReleases []releases.AppReleaseInfo) error {
rs := make([]map[string]interface{}, len(appReleases))
Expand All @@ -27,7 +28,7 @@ func Releases(w *tabwriter.Writer, appReleases []releases.AppReleaseInfo) error
activeChansField := strings.Join(activeChans, ",")

// don't print edited if it's the same as created
edited := r.EditedAt.String()
edited := r.EditedAt.Format(time.RFC3339)
if r.CreatedAt.Equal(r.EditedAt) {
edited = ""
}
Expand Down
13 changes: 13 additions & 0 deletions cli/print/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package print

import (
"text/template"
"time"
)

var funcs = template.FuncMap{
// Use RFC 3339 for standard time printing in all output
"time": func(t time.Time) string {
return t.Format(time.RFC3339)
},
}