Exemple #1
0
func main() {
	flag.Usage = usage
	flag.Parse()
	args := flag.Args()

	if len(args) < 1 || len(args) > 2 {
		usage()
		return
	}

	if err := convert.RunOCI2ACI(args, *flagDebug, *flagName); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	return
}
Exemple #2
0
func oci2aciProc(c *cli.Context) {
	bDebug := c.GlobalBool("debug")

	args := c.Args()

	switch len(args) {
	case 1:
		err := convert.RunOCI2ACI(args[0], bDebug)
		if err != nil {
			fmt.Fprintf(os.Stderr, "Error: %v\n", err)
			os.Exit(1)
		}
	case 2:
		outFile := args[1]
		ext := filepath.Ext(outFile)
		if ext != schema.ACIExtension {
			fmt.Fprintf(os.Stderr, "oci2aci: Extension must be %s (given %s)", schema.ACIExtension, ext)
			os.Exit(1)
		}

		aciImgPath, err := convert.Oci2aciImage(args[0])
		if err != nil {
			fmt.Fprintf(os.Stderr, "oci2aci: Convert failed: %s", err)
			os.Exit(1)
		}

		if err = run(exec.Command("mv", aciImgPath, args[1])); err != nil {
			os.Exit(1)
		}

	default:
		cli.ShowCommandHelp(c, "convert")

	}

	return
}