fix make vet failures, and enable make vet on CI
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
22
cmd/dist/main.go
vendored
22
cmd/dist/main.go
vendored
@@ -4,6 +4,7 @@ import (
|
||||
contextpkg "context"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/containerd/containerd"
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
background = contextpkg.Background()
|
||||
timeout time.Duration
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -21,6 +22,14 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
func appContext() (contextpkg.Context, contextpkg.CancelFunc) {
|
||||
background := contextpkg.Background()
|
||||
if timeout > 0 {
|
||||
return contextpkg.WithTimeout(background, timeout)
|
||||
}
|
||||
return contextpkg.WithCancel(background)
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "dist"
|
||||
@@ -70,17 +79,10 @@ distribution tool
|
||||
rootfsCommand,
|
||||
}
|
||||
app.Before = func(context *cli.Context) error {
|
||||
var (
|
||||
debug = context.GlobalBool("debug")
|
||||
timeout = context.GlobalDuration("timeout")
|
||||
)
|
||||
if debug {
|
||||
timeout = context.GlobalDuration("timeout")
|
||||
if context.GlobalBool("debug") {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
if timeout > 0 {
|
||||
background, _ = contextpkg.WithTimeout(background, timeout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user