Коммит
065626deec
|
@ -22,7 +22,6 @@ builds:
|
|||
-s
|
||||
-extldflags '-static'
|
||||
-X github.com/docker/index-cli-plugin/internal.version={{.Version}}
|
||||
-X github.com/docker/index-cli-plugin/internal.commit={{.Commit}}
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
|
|
|
@ -24,6 +24,8 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/index-cli-plugin/internal"
|
||||
|
||||
"github.com/moby/term"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -243,7 +245,18 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
|
|||
},
|
||||
}
|
||||
|
||||
cmd.AddCommand(loginCommand, logoutCommand, sbomCommand, cveCommand, uploadCommand, diffCommand, watchCommand)
|
||||
versionCommand := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print version",
|
||||
Args: cobra.NoArgs,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
v := internal.FromBuild()
|
||||
fmt.Printf("version: %s (%s - %s)\n", v.Version, v.GoVersion, v.Platform)
|
||||
fmt.Println("git commit:", v.Commit)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.AddCommand(loginCommand, logoutCommand, sbomCommand, cveCommand, uploadCommand, diffCommand, watchCommand, versionCommand)
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package internal
|
|||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
// build-time arguments
|
||||
|
@ -30,6 +31,16 @@ var (
|
|||
commit = "n/a"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
for _, setting := range info.Settings {
|
||||
if setting.Key == "vcs.revision" {
|
||||
commit = setting.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version information from build time args and environment
|
||||
type Version struct {
|
||||
Version string
|
||||
|
|
Загрузка…
Ссылка в новой задаче