Пример #1
0
// NewDockerImage returns a new Image interface type after setting up
// a client to the registry hosting the given image.
func NewDockerImage(img, certPath string, tlsVerify bool) (types.Image, error) {
	s, err := newDockerImageSource(img, certPath, tlsVerify)
	if err != nil {
		return nil, err
	}
	return &Image{Image: image.FromSource(s), src: s}, nil
}
Пример #2
0
// ParseImage converts image URL-like string to an initialized handler for that image.
func parseImage(c *cli.Context) (types.Image, error) {
	var (
		imgName   = c.Args().First()
		certPath  = c.GlobalString("cert-path")
		tlsVerify = c.GlobalBool("tls-verify")
	)
	switch {
	case strings.HasPrefix(imgName, dockerPrefix):
		return docker.NewDockerImage(strings.TrimPrefix(imgName, dockerPrefix), certPath, tlsVerify)
		//case strings.HasPrefix(img, appcPrefix):
		//
	case strings.HasPrefix(imgName, directoryPrefix):
		src := directory.NewDirImageSource(strings.TrimPrefix(imgName, directoryPrefix))
		return image.FromSource(src), nil
	}
	return nil, fmt.Errorf("no valid prefix provided")
}