remove img-type

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca
2016-02-29 11:27:43 +01:00
parent 7d7fb3c4b0
commit e5d9bee80c
2 changed files with 29 additions and 14 deletions

View File

@@ -2,34 +2,54 @@ package main
import (
"fmt"
"strings"
"github.com/codegangsta/cli"
"github.com/runcom/skopeo/docker"
"github.com/runcom/skopeo/types"
)
type imgKind int
const (
imgTypeDocker = "docker"
imgTypeAppc = "appc"
imgTypeDocker = "docker://"
imgTypeAppc = "appc://"
kindUnknown = iota
kindDocker
kindAppc
)
func getImgType(img string) imgKind {
if strings.HasPrefix(img, imgTypeDocker) {
return kindDocker
}
if strings.HasPrefix(img, imgTypeAppc) {
return kindAppc
}
// TODO(runcom): v2 will support this
//return kindUnknown
return kindDocker
}
func inspect(c *cli.Context) (*types.ImageInspect, error) {
var (
imgInspect *types.ImageInspect
err error
name = c.Args().First()
imgType = c.GlobalString("img-type")
kind = getImgType(name)
)
switch imgType {
case imgTypeDocker:
imgInspect, err = docker.GetData(c, name)
switch kind {
case kindDocker:
imgInspect, err = docker.GetData(c, strings.Replace(name, imgTypeDocker, "", -1))
if err != nil {
return nil, err
}
case imgTypeAppc:
return nil, fmt.Errorf("sorry, not implemented yet")
case kindAppc:
return nil, fmt.Errorf("not implemented yet")
default:
return nil, fmt.Errorf("%s image type is invalid, please use either 'docker' or 'appc'", imgType)
return nil, fmt.Errorf("%s image is invalid, please use either 'docker://' or 'appc://'", name)
}
return imgInspect, nil
}

View File

@@ -52,11 +52,6 @@ func main() {
Value: cliconfig.ConfigDir(),
Usage: "Docker's cli config for auth",
},
cli.StringFlag{
Name: "img-type",
Value: imgTypeDocker,
Usage: "Either docker or appc",
},
}
app.Before = func(c *cli.Context) error {
if c.GlobalBool("debug") {