Merge pull request #650 from stevvooe/move-image-to-images
images: move image package to images
This commit is contained in:
commit
65e2c02ee1
10 changed files with 28 additions and 28 deletions
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/crosbymichael/console"
|
"github.com/crosbymichael/console"
|
||||||
"github.com/docker/containerd/api/services/execution"
|
"github.com/docker/containerd/api/services/execution"
|
||||||
rootfsapi "github.com/docker/containerd/api/services/rootfs"
|
rootfsapi "github.com/docker/containerd/api/services/rootfs"
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
protobuf "github.com/gogo/protobuf/types"
|
protobuf "github.com/gogo/protobuf/types"
|
||||||
"github.com/opencontainers/image-spec/identity"
|
"github.com/opencontainers/image-spec/identity"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
@ -224,7 +224,7 @@ var runCommand = cli.Command{
|
||||||
|
|
||||||
ref := context.Args().First()
|
ref := context.Args().First()
|
||||||
|
|
||||||
im, err := image.Get(tx, ref)
|
image, err := images.Get(tx, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not resolve %q", ref)
|
return errors.Wrapf(err, "could not resolve %q", ref)
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ var runCommand = cli.Command{
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
db.Close()
|
db.Close()
|
||||||
|
|
||||||
diffIDs, err := im.RootFS(ctx, provider)
|
diffIDs, err := image.RootFS(ctx, provider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
rootfsapi "github.com/docker/containerd/api/services/rootfs"
|
rootfsapi "github.com/docker/containerd/api/services/rootfs"
|
||||||
"github.com/docker/containerd/api/types/container"
|
"github.com/docker/containerd/api/types/container"
|
||||||
"github.com/docker/containerd/content"
|
"github.com/docker/containerd/content"
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
contentservice "github.com/docker/containerd/services/content"
|
contentservice "github.com/docker/containerd/services/content"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/tonistiigi/fifo"
|
"github.com/tonistiigi/fifo"
|
||||||
|
@ -147,7 +147,7 @@ func getDB(ctx *cli.Context, readonly bool) (*bolt.DB, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !readonly {
|
if !readonly {
|
||||||
if err := image.InitDB(db); err != nil {
|
if err := images.InitDB(db); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
cmd/dist/common.go
vendored
4
cmd/dist/common.go
vendored
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/boltdb/bolt"
|
"github.com/boltdb/bolt"
|
||||||
"github.com/docker/containerd/content"
|
"github.com/docker/containerd/content"
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
@ -50,7 +50,7 @@ func getDB(ctx *cli.Context, readonly bool) (*bolt.DB, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !readonly {
|
if !readonly {
|
||||||
if err := image.InitDB(db); err != nil {
|
if err := images.InitDB(db); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
cmd/dist/fetch.go
vendored
8
cmd/dist/fetch.go
vendored
|
@ -10,7 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
contentapi "github.com/docker/containerd/api/services/content"
|
contentapi "github.com/docker/containerd/api/services/content"
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
"github.com/docker/containerd/log"
|
"github.com/docker/containerd/log"
|
||||||
"github.com/docker/containerd/progress"
|
"github.com/docker/containerd/progress"
|
||||||
"github.com/docker/containerd/remotes"
|
"github.com/docker/containerd/remotes"
|
||||||
|
@ -79,13 +79,13 @@ Most of this is experimental and there are few leaps to make this work.`,
|
||||||
log.G(ctx).WithField("image", name).Debug("fetching")
|
log.G(ctx).WithField("image", name).Debug("fetching")
|
||||||
close(resolved)
|
close(resolved)
|
||||||
|
|
||||||
return image.Dispatch(ctx,
|
return images.Dispatch(ctx,
|
||||||
image.Handlers(image.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
images.Handlers(images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
||||||
ongoing.add(remotes.MakeRefKey(ctx, desc))
|
ongoing.add(remotes.MakeRefKey(ctx, desc))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}),
|
}),
|
||||||
remotes.FetchHandler(ingester, fetcher),
|
remotes.FetchHandler(ingester, fetcher),
|
||||||
image.ChildrenHandler(provider),
|
images.ChildrenHandler(provider),
|
||||||
),
|
),
|
||||||
desc)
|
desc)
|
||||||
})
|
})
|
||||||
|
|
4
cmd/dist/images.go
vendored
4
cmd/dist/images.go
vendored
|
@ -5,7 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
"github.com/docker/containerd/progress"
|
"github.com/docker/containerd/progress"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
@ -29,7 +29,7 @@ var imagesCommand = cli.Command{
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
|
|
||||||
images, err := image.List(tx)
|
images, err := images.List(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to list images")
|
return errors.Wrap(err, "failed to list images")
|
||||||
}
|
}
|
||||||
|
|
12
cmd/dist/pull.go
vendored
12
cmd/dist/pull.go
vendored
|
@ -10,7 +10,7 @@ import (
|
||||||
contentapi "github.com/docker/containerd/api/services/content"
|
contentapi "github.com/docker/containerd/api/services/content"
|
||||||
rootfsapi "github.com/docker/containerd/api/services/rootfs"
|
rootfsapi "github.com/docker/containerd/api/services/rootfs"
|
||||||
"github.com/docker/containerd/content"
|
"github.com/docker/containerd/content"
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
"github.com/docker/containerd/log"
|
"github.com/docker/containerd/log"
|
||||||
"github.com/docker/containerd/progress"
|
"github.com/docker/containerd/progress"
|
||||||
"github.com/docker/containerd/remotes"
|
"github.com/docker/containerd/remotes"
|
||||||
|
@ -87,7 +87,7 @@ command. As part of this process, we do the following:
|
||||||
close(resolved)
|
close(resolved)
|
||||||
|
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
return image.Register(tx, name, desc)
|
return images.Register(tx, name, desc)
|
||||||
})
|
})
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := tx.Commit(); err != nil {
|
if err := tx.Commit(); err != nil {
|
||||||
|
@ -95,13 +95,13 @@ command. As part of this process, we do the following:
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return image.Dispatch(ctx,
|
return images.Dispatch(ctx,
|
||||||
image.Handlers(image.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
images.Handlers(images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
||||||
ongoing.add(remotes.MakeRefKey(ctx, desc))
|
ongoing.add(remotes.MakeRefKey(ctx, desc))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}),
|
}),
|
||||||
remotes.FetchHandler(ingester, fetcher),
|
remotes.FetchHandler(ingester, fetcher),
|
||||||
image.ChildrenHandler(provider)),
|
images.ChildrenHandler(provider)),
|
||||||
desc)
|
desc)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -123,7 +123,7 @@ command. As part of this process, we do the following:
|
||||||
// root filesystem chainid for the image. For now, we just print
|
// root filesystem chainid for the image. For now, we just print
|
||||||
// it, but we should keep track of this in the metadata storage.
|
// it, but we should keep track of this in the metadata storage.
|
||||||
|
|
||||||
image, err := image.Get(tx, resolvedImageName)
|
image, err := images.Get(tx, resolvedImageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.G(ctx).Fatal(err)
|
log.G(ctx).Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package image
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package image
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package image
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/containerd/content"
|
"github.com/docker/containerd/content"
|
||||||
"github.com/docker/containerd/image"
|
"github.com/docker/containerd/images"
|
||||||
"github.com/docker/containerd/log"
|
"github.com/docker/containerd/log"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
@ -19,10 +19,10 @@ func MakeRefKey(ctx context.Context, desc ocispec.Descriptor) string {
|
||||||
// product of the context, which may include information about the ongoing
|
// product of the context, which may include information about the ongoing
|
||||||
// fetch process.
|
// fetch process.
|
||||||
switch desc.MediaType {
|
switch desc.MediaType {
|
||||||
case image.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,
|
case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,
|
||||||
image.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
||||||
return "manifest-" + desc.Digest.String()
|
return "manifest-" + desc.Digest.String()
|
||||||
case image.MediaTypeDockerSchema2Layer, image.MediaTypeDockerSchema2LayerGzip:
|
case images.MediaTypeDockerSchema2Layer, images.MediaTypeDockerSchema2LayerGzip:
|
||||||
return "layer-" + desc.Digest.String()
|
return "layer-" + desc.Digest.String()
|
||||||
case "application/vnd.docker.container.image.v1+json":
|
case "application/vnd.docker.container.image.v1+json":
|
||||||
return "config-" + desc.Digest.String()
|
return "config-" + desc.Digest.String()
|
||||||
|
@ -35,7 +35,7 @@ func MakeRefKey(ctx context.Context, desc ocispec.Descriptor) string {
|
||||||
// FetchHandler returns a handler that will fetch all content into the ingester
|
// FetchHandler returns a handler that will fetch all content into the ingester
|
||||||
// discovered in a call to Dispatch. Use with ChildrenHandler to do a full
|
// discovered in a call to Dispatch. Use with ChildrenHandler to do a full
|
||||||
// recursive fetch.
|
// recursive fetch.
|
||||||
func FetchHandler(ingester content.Ingester, fetcher Fetcher) image.HandlerFunc {
|
func FetchHandler(ingester content.Ingester, fetcher Fetcher) images.HandlerFunc {
|
||||||
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
|
return func(ctx context.Context, desc ocispec.Descriptor) (subdescs []ocispec.Descriptor, err error) {
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{
|
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(logrus.Fields{
|
||||||
"digest": desc.Digest,
|
"digest": desc.Digest,
|
||||||
|
@ -44,7 +44,7 @@ func FetchHandler(ingester content.Ingester, fetcher Fetcher) image.HandlerFunc
|
||||||
}))
|
}))
|
||||||
|
|
||||||
switch desc.MediaType {
|
switch desc.MediaType {
|
||||||
case image.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
case images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
||||||
return nil, fmt.Errorf("%v not yet supported", desc.MediaType)
|
return nil, fmt.Errorf("%v not yet supported", desc.MediaType)
|
||||||
default:
|
default:
|
||||||
err := fetch(ctx, ingester, fetcher, desc)
|
err := fetch(ctx, ingester, fetcher, desc)
|
||||||
|
|
Loading…
Reference in a new issue