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:
parent
25a161bf5d
commit
837205005f
@ -31,6 +31,7 @@ script:
|
||||
- export CGO_ENABLED=$TRAVIS_CGO_ENABLED
|
||||
- GIT_CHECK_EXCLUDE="./vendor" TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" make dco
|
||||
- make fmt
|
||||
- make vet
|
||||
- make binaries
|
||||
- if [ "$GOOS" != "windows" ]; then make coverage ; fi
|
||||
- if [ "$GOOS" != "windows" ]; then sudo PATH=$PATH GOPATH=$GOPATH make root-coverage ; fi
|
||||
|
2
Makefile
2
Makefile
@ -79,7 +79,7 @@ checkprotos: protos ## check if protobufs needs to be generated again
|
||||
# imports
|
||||
vet: binaries ## run go vet
|
||||
@echo "$(WHALE) $@"
|
||||
@test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"
|
||||
@test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | grep -v 'unrecognized printf verb 'r'' | egrep -v '(timestamp_test.go|duration_test.go|fetch.go|exit status 1)' | tee /dev/stderr)"
|
||||
|
||||
fmt: ## run go fmt
|
||||
@echo "$(WHALE) $@"
|
||||
|
@ -42,6 +42,5 @@ var eventsCommand = cli.Command{
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ func newExecRequest(context *cli.Context, tmpDir, id string) (*execution.ExecReq
|
||||
Value: data,
|
||||
},
|
||||
Terminal: context.Bool("tty"),
|
||||
Stdin: fmt.Sprintf(`%s\ctr-%s-stdin-`, pipeRoot, id, now),
|
||||
Stdout: fmt.Sprintf(`%s\ctr-%s-stdout-`, pipeRoot, id, now),
|
||||
Stdin: fmt.Sprintf(`%s\ctr-%s-stdin-%d`, pipeRoot, id, now),
|
||||
Stdout: fmt.Sprintf(`%s\ctr-%s-stdout-%d`, pipeRoot, id, now),
|
||||
}
|
||||
if !request.Terminal {
|
||||
request.Stderr = fmt.Sprintf(`%s\ctr-%s-stderr-`, pipeRoot, id, now)
|
||||
request.Stderr = fmt.Sprintf(`%s\ctr-%s-stderr-%d`, pipeRoot, id, now)
|
||||
}
|
||||
|
||||
return request, nil
|
||||
|
@ -285,7 +285,6 @@ var shimEventsCommand = cli.Command{
|
||||
}
|
||||
fmt.Printf("type=%s id=%s pid=%d status=%d\n", e.Type, e.ID, e.Pid, e.ExitStatus)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
|
4
cmd/dist/apply.go
vendored
4
cmd/dist/apply.go
vendored
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
contextpkg "context"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/archive"
|
||||
@ -17,9 +16,10 @@ var applyCommand = cli.Command{
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = contextpkg.Background()
|
||||
dir = context.Args().First()
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
log.G(ctx).Info("applying layer from stdin")
|
||||
|
||||
|
3
cmd/dist/delete.go
vendored
3
cmd/dist/delete.go
vendored
@ -22,10 +22,11 @@ var deleteCommand = cli.Command{
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
args = []string(context.Args())
|
||||
exitError error
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
conn, err := connectGRPC(context)
|
||||
if err != nil {
|
||||
|
3
cmd/dist/edit.go
vendored
3
cmd/dist/edit.go
vendored
@ -27,10 +27,11 @@ var editCommand = cli.Command{
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
validate = context.String("validate")
|
||||
object = context.Args().First()
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
if validate != "" {
|
||||
return errors.New("validating the edit result not supported")
|
||||
|
5
cmd/dist/fetch.go
vendored
5
cmd/dist/fetch.go
vendored
@ -42,9 +42,10 @@ Most of this is experimental and there are few leaps to make this work.`,
|
||||
Flags: registryFlags,
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
ref = clicontext.Args().First()
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
conn, err := connectGRPC(clicontext)
|
||||
if err != nil {
|
||||
@ -176,8 +177,6 @@ Most of this is experimental and there are few leaps to make this work.`,
|
||||
done = true // allow ui to update once more
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
|
17
cmd/dist/fetchobject.go
vendored
17
cmd/dist/fetchobject.go
vendored
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
contextpkg "context"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@ -18,25 +17,13 @@ var fetchObjectCommand = cli.Command{
|
||||
Usage: "retrieve objects from a remote",
|
||||
ArgsUsage: "[flags] <remote> <object> [<hint>, ...]",
|
||||
Description: `Fetch objects by identifier from a remote.`,
|
||||
Flags: append([]cli.Flag{
|
||||
cli.DurationFlag{
|
||||
Name: "timeout",
|
||||
Usage: "total timeout for fetch",
|
||||
EnvVar: "CONTAINERD_FETCH_TIMEOUT",
|
||||
},
|
||||
}, registryFlags...),
|
||||
Flags: registryFlags,
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
timeout = context.Duration("timeout")
|
||||
ref = context.Args().First()
|
||||
)
|
||||
|
||||
if timeout > 0 {
|
||||
var cancel func()
|
||||
ctx, cancel = contextpkg.WithTimeout(ctx, timeout)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
}
|
||||
|
||||
resolver, err := getResolver(ctx, context)
|
||||
if err != nil {
|
||||
|
5
cmd/dist/get.go
vendored
5
cmd/dist/get.go
vendored
@ -17,9 +17,8 @@ var getCommand = cli.Command{
|
||||
Description: "Display the image object.",
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
dgst, err := digest.Parse(context.Args().First())
|
||||
if err != nil {
|
||||
|
8
cmd/dist/images.go
vendored
8
cmd/dist/images.go
vendored
@ -21,9 +21,8 @@ var imagesListCommand = cli.Command{
|
||||
Description: `List images registered with containerd.`,
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
imageStore, err := resolveImageStore(clicontext)
|
||||
if err != nil {
|
||||
@ -66,9 +65,10 @@ var rmiCommand = cli.Command{
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
exitErr error
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
imageStore, err := resolveImageStore(clicontext)
|
||||
if err != nil {
|
||||
|
5
cmd/dist/ingest.go
vendored
5
cmd/dist/ingest.go
vendored
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
contextpkg "context"
|
||||
"os"
|
||||
|
||||
contentapi "github.com/containerd/containerd/api/services/content"
|
||||
@ -29,14 +28,12 @@ var ingestCommand = cli.Command{
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
cancel func()
|
||||
ref = context.Args().First()
|
||||
expectedSize = context.Int64("expected-size")
|
||||
expectedDigest = digest.Digest(context.String("expected-digest"))
|
||||
)
|
||||
|
||||
ctx, cancel = contextpkg.WithCancel(ctx)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
if err := expectedDigest.Validate(); expectedDigest != "" && err != nil {
|
||||
|
4
cmd/dist/list.go
vendored
4
cmd/dist/list.go
vendored
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
contextpkg "context"
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
@ -28,10 +27,11 @@ var listCommand = cli.Command{
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
ctx = contextpkg.Background()
|
||||
quiet = context.Bool("quiet")
|
||||
args = []string(context.Args())
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
cs, err := resolveContentStore(context)
|
||||
if err != nil {
|
||||
|
20
cmd/dist/main.go
vendored
20
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 {
|
||||
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 {
|
||||
|
9
cmd/dist/pull.go
vendored
9
cmd/dist/pull.go
vendored
@ -38,10 +38,12 @@ command. As part of this process, we do the following:
|
||||
Flags: registryFlags,
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
ref = clicontext.Args().First()
|
||||
)
|
||||
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
conn, err := connectGRPC(clicontext)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -104,8 +106,9 @@ command. As part of this process, we do the following:
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
ctx := background
|
||||
|
||||
// we need new ctx here
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
// TODO(stevvooe): This section unpacks the layers and resolves the
|
||||
// root filesystem chainid for the image. For now, we just print
|
||||
// it, but we should keep track of this in the metadata storage.
|
||||
|
10
cmd/dist/rootfs.go
vendored
10
cmd/dist/rootfs.go
vendored
@ -34,9 +34,8 @@ var rootfsUnpackCommand = cli.Command{
|
||||
ArgsUsage: "[flags] <digest>",
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
dgst, err := digest.Parse(clicontext.Args().First())
|
||||
if err != nil {
|
||||
@ -74,9 +73,8 @@ var rootfsPrepareCommand = cli.Command{
|
||||
ArgsUsage: "[flags] <digest> <target>",
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(clicontext *cli.Context) error {
|
||||
var (
|
||||
ctx = background
|
||||
)
|
||||
ctx, cancel := appContext()
|
||||
defer cancel()
|
||||
|
||||
if clicontext.NArg() != 2 {
|
||||
return cli.ShowSubcommandHelp(clicontext)
|
||||
|
@ -324,8 +324,6 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) Status(*api.StatusRequest, api.Content_StatusServer) error {
|
||||
|
@ -363,8 +363,6 @@ func parents(bkt *bolt.Bucket, parent *db.Snapshot) (parents []string, err error
|
||||
}
|
||||
parent = &ps
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func getSnapshot(bkt *bolt.Bucket, key string, ss *db.Snapshot) error {
|
||||
|
@ -80,7 +80,7 @@ func inReadTransaction(fn testFunc, pf populateFunc) testFunc {
|
||||
|
||||
ctx, tx, err := ms.TransactionContext(ctx, false)
|
||||
if err != nil {
|
||||
t.Fatal("Failed start transaction: %+v", err)
|
||||
t.Fatalf("Failed start transaction: %+v", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := tx.Rollback(); err != nil {
|
||||
@ -99,7 +99,7 @@ func inWriteTransaction(fn testFunc) testFunc {
|
||||
return func(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
ctx, tx, err := ms.TransactionContext(ctx, true)
|
||||
if err != nil {
|
||||
t.Fatal("Failed to start transaction: %+v", err)
|
||||
t.Fatalf("Failed to start transaction: %+v", err)
|
||||
}
|
||||
defer func() {
|
||||
if t.Failed() {
|
||||
@ -108,7 +108,7 @@ func inWriteTransaction(fn testFunc) testFunc {
|
||||
}
|
||||
} else {
|
||||
if err := tx.Commit(); err != nil {
|
||||
t.Fatal("Commit failed: %+v", err)
|
||||
t.Fatalf("Commit failed: %+v", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@ -311,7 +311,7 @@ func testGetActive(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
for key, expected := range activeMap {
|
||||
active, err := GetActive(ctx, key)
|
||||
if err != nil {
|
||||
t.Fatal("Failed to get active: %+v", err)
|
||||
t.Fatalf("Failed to get active: %+v", err)
|
||||
}
|
||||
assert.Equal(t, expected, active)
|
||||
}
|
||||
@ -366,7 +366,7 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
t.Fatal("Returned active identifiers must be unique")
|
||||
}
|
||||
if len(a3.ParentIDs) != 1 {
|
||||
t.Fatal("Expected 1 parent, got %d", len(a3.ParentIDs))
|
||||
t.Fatalf("Expected 1 parent, got %d", len(a3.ParentIDs))
|
||||
}
|
||||
if a3.ParentIDs[0] != commitID {
|
||||
t.Fatal("Expected active parent to be same as commit ID")
|
||||
@ -383,7 +383,7 @@ func testCreateActive(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
t.Fatal("Returned active identifiers must be unique")
|
||||
}
|
||||
if len(a3.ParentIDs) != 1 {
|
||||
t.Fatal("Expected 1 parent, got %d", len(a3.ParentIDs))
|
||||
t.Fatalf("Expected 1 parent, got %d", len(a3.ParentIDs))
|
||||
}
|
||||
if a3.ParentIDs[0] != commitID {
|
||||
t.Fatal("Expected active parent to be same as commit ID")
|
||||
@ -505,7 +505,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
t.Fatal("Expected remove ID to match create ID")
|
||||
}
|
||||
if k3 != snapshot.KindActive {
|
||||
t.Fatal("Expected active kind, got %v", k3)
|
||||
t.Fatalf("Expected active kind, got %v", k3)
|
||||
}
|
||||
|
||||
r2, k2, err := Remove(ctx, "active-2")
|
||||
@ -516,7 +516,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
t.Fatal("Expected remove ID to match create ID")
|
||||
}
|
||||
if k2 != snapshot.KindActive {
|
||||
t.Fatal("Expected active kind, got %v", k2)
|
||||
t.Fatalf("Expected active kind, got %v", k2)
|
||||
}
|
||||
|
||||
r1, k1, err := Remove(ctx, "committed-1")
|
||||
@ -527,7 +527,7 @@ func testRemove(ctx context.Context, t *testing.T, ms *MetaStore) {
|
||||
t.Fatal("Expected remove ID to match commit ID")
|
||||
}
|
||||
if k1 != snapshot.KindCommitted {
|
||||
t.Fatal("Expected committed kind, got %v", k1)
|
||||
t.Fatalf("Expected committed kind, got %v", k1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ type Configuration struct {
|
||||
|
||||
Layers []string `json:"layers"`
|
||||
|
||||
TerminateDuration time.Duration `json:"terminateDuration",omitempty`
|
||||
TerminateDuration time.Duration `json:"terminateDuration,omitempty"`
|
||||
|
||||
IgnoreFlushesDuringBoot bool `json:"ignoreFlushesDuringBoot,omitempty"`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user