935144fadd
This setup will now correctly set the version number from the git tag. When using `--version`, we will see the binary name, the package it was built from and a git hash based on the tag: ```console $./bin/dist -v ./bin/dist github.com/docker/containerd 0b45d91.m ``` Note that in the above example, if we set a tag of `v1.0.0-dev`, that will show up in the version number, as follows: ```console $./bin/dist -v ./bin/dist github.com/docker/containerd v1.0.0-dev ``` Once commits are made past that tag, the version number will be expressed relative to that tag and include a git hash: ```console $./bin/dist -v ./bin/dist github.com/docker/containerd v1.0.0-dev-1-g7953e96.m ``` Some these examples include a `.m` postfix. This indicates that the binary was build from a source tree with local modifications. We can add a dev tag to start getting 1.0 version numbers for test builds. Signed-off-by: Stephen J Day <stephen.day@docker.com>
81 lines
1.6 KiB
Go
81 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
contextpkg "context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/docker/containerd"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var (
|
|
background = contextpkg.Background()
|
|
)
|
|
|
|
func main() {
|
|
cli.VersionPrinter = func(c *cli.Context) {
|
|
fmt.Println(os.Args[0], containerd.Package, containerd.Version)
|
|
}
|
|
app := cli.NewApp()
|
|
app.Name = "dist"
|
|
app.Version = containerd.Version
|
|
app.Usage = `
|
|
___ __
|
|
____/ (_)____/ /_
|
|
/ __ / / ___/ __/
|
|
/ /_/ / (__ ) /_
|
|
\__,_/_/____/\__/
|
|
|
|
distribution tool
|
|
`
|
|
app.Flags = []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "debug",
|
|
Usage: "enable debug output in logs",
|
|
},
|
|
cli.DurationFlag{
|
|
Name: "timeout",
|
|
Usage: "total timeout for fetch",
|
|
EnvVar: "CONTAINERD_FETCH_TIMEOUT",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "root",
|
|
Usage: "path to content store root",
|
|
Value: "/tmp/content", // TODO(stevvooe): for now, just use the PWD/.content
|
|
},
|
|
cli.StringFlag{
|
|
Name: "socket, s",
|
|
Usage: "socket path for containerd's GRPC server",
|
|
Value: "/run/containerd/containerd.sock",
|
|
},
|
|
}
|
|
app.Commands = []cli.Command{
|
|
fetchCommand,
|
|
ingestCommand,
|
|
activeCommand,
|
|
getCommand,
|
|
deleteCommand,
|
|
listCommand,
|
|
applyCommand,
|
|
}
|
|
app.Before = func(context *cli.Context) error {
|
|
var (
|
|
debug = context.GlobalBool("debug")
|
|
timeout = context.GlobalDuration("timeout")
|
|
)
|
|
if debug {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
}
|
|
|
|
if timeout > 0 {
|
|
background, _ = contextpkg.WithTimeout(background, timeout)
|
|
}
|
|
return nil
|
|
}
|
|
if err := app.Run(os.Args); err != nil {
|
|
fmt.Fprintf(os.Stderr, "dist: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|