Exemplo n.º 1
0
// parseImageSource converts image URL-like string to an ImageSource.
func parseImageSource(c *cli.Context, name string) (types.ImageSource, error) {
	var (
		certPath  = c.GlobalString("cert-path")
		tlsVerify = c.GlobalBool("tls-verify") // FIXME!! defaults to false?
	)
	switch {
	case strings.HasPrefix(name, dockerPrefix):
		return docker.NewDockerImageSource(strings.TrimPrefix(name, dockerPrefix), certPath, tlsVerify)
	case strings.HasPrefix(name, atomicPrefix):
		return openshift.NewOpenshiftImageSource(strings.TrimPrefix(name, atomicPrefix), certPath, tlsVerify)
	case strings.HasPrefix(name, directoryPrefix):
		return directory.NewDirImageSource(strings.TrimPrefix(name, directoryPrefix)), nil
	}
	return nil, fmt.Errorf("Unrecognized image reference %s", name)
}
Exemplo n.º 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")
}