forked from argoproj/argo-rollouts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
43 lines (38 loc) · 1.23 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package version
import (
"fmt"
"io"
"github.com/spf13/cobra"
"github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/options"
versionutils "github.com/argoproj/argo-rollouts/utils/version"
)
// NewCmdVersion returns a new instance of an `rollouts version` command
func NewCmdVersion(o *options.ArgoRolloutsOptions) *cobra.Command {
var (
short bool
)
var cmd = &cobra.Command{
Use: "version",
Short: "Print version",
SilenceUsage: true,
RunE: func(c *cobra.Command, args []string) error {
PrintVersion(o.Out, short)
return nil
},
}
cmd.Flags().BoolVar(&short, "short", false, "print just the version number")
return cmd
}
// PrintVersion prints the version to the output stream
func PrintVersion(out io.Writer, short bool) {
version := versionutils.GetVersion()
fmt.Fprintf(out, "%s: %s\n", "kubectl-argo-rollouts", version)
if !short {
fmt.Fprintf(out, " BuildDate: %s\n", version.BuildDate)
fmt.Fprintf(out, " GitCommit: %s\n", version.GitCommit)
fmt.Fprintf(out, " GitTreeState: %s\n", version.GitTreeState)
fmt.Fprintf(out, " GoVersion: %s\n", version.GoVersion)
fmt.Fprintf(out, " Compiler: %s\n", version.Compiler)
fmt.Fprintf(out, " Platform: %s\n", version.Platform)
}
}