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:
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
21
cmd/dist/fetchobject.go
vendored
21
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()
|
||||
ref = context.Args().First()
|
||||
)
|
||||
|
||||
if timeout > 0 {
|
||||
var cancel func()
|
||||
ctx, cancel = contextpkg.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
}
|
||||
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 {
|
||||
|
||||
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 {
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user