Example #1
0
func cmdExportImage(img *jetpack.Image, args []string) error {
	var output *os.File

	if len(args) == 0 || args[0] == "-" {
		output = os.Stdout
	} else {
		if of, err := os.Create(args[0]); err != nil {
			return errors.Trace(err)
		} else {
			output = of
			defer output.Close()
		}
	}

	if flExportFlat {
		if hash, err := img.WriteFlatACI(output); err != nil {
			return errors.Trace(err)
		} else {
			fmt.Println(hash)
			return nil
		}
	} else {
		if aci, err := os.Open(img.Path("aci")); err != nil {
			return errors.Trace(err)
		} else {
			defer aci.Close()
			_, err = io.Copy(output, aci)
			return errors.Trace(err)
		}
	}
}
Example #2
0
func cmdBuild(img *jetpack.Image, args []string) error {
	if nimg, err := img.Build(flBuildDir, flBuildCp, args); err != nil {
		return errors.Trace(err)
	} else {
		if err := cmdShowImage(nimg); err != nil {
			return errors.Trace(err)
		}
		if SaveID != "" {
			return errors.Trace(ioutil.WriteFile(SaveID,
				[]byte(nimg.Hash.String()+"\n"), 0644))
		}
		return nil
	}
}
Example #3
0
func cmdDestroyImage(img *jetpack.Image) error {
	return errors.Trace(img.Destroy())
}