Esempio n. 1
0
func addImagefile(imageSClient *srpc.Client,
	objectClient *objectclient.ObjectClient,
	name, imageFilename, filterFilename, triggersFilename string) error {
	imageExists, err := client.CheckImage(imageSClient, name)
	if err != nil {
		return errors.New("error checking for image existance: " + err.Error())
	}
	if imageExists {
		return errors.New("image exists")
	}
	newImage := new(image.Image)
	if err := loadImageFiles(newImage, objectClient, filterFilename,
		triggersFilename); err != nil {
		return err
	}
	newImage.FileSystem, err = buildImage(imageSClient, newImage.Filter,
		imageFilename)
	if err != nil {
		return errors.New("error building image: " + err.Error())
	}
	if err := spliceComputedFiles(newImage.FileSystem); err != nil {
		return err
	}
	return addImage(imageSClient, name, newImage)
}
Esempio n. 2
0
func addImagesub(imageSClient *srpc.Client,
	objectClient *objectclient.ObjectClient,
	name, subName, filterFilename, triggersFilename string) error {
	imageExists, err := client.CheckImage(imageSClient, name)
	if err != nil {
		return errors.New("error checking for image existance: " + err.Error())
	}
	if imageExists {
		return errors.New("image exists")
	}
	newImage := new(image.Image)
	if err := loadImageFiles(newImage, objectClient, filterFilename,
		triggersFilename); err != nil {
		return err
	}
	fs, err := pollImage(subName)
	if err != nil {
		return err
	}
	if fs, err = applyDeleteFilter(fs); err != nil {
		return err
	}
	fs = fs.Filter(newImage.Filter)
	if err := spliceComputedFiles(fs); err != nil {
		return err
	}
	if err := copyMissingObjects(fs, imageSClient, objectClient,
		subName); err != nil {
		return err
	}
	newImage.FileSystem = fs
	return addImage(imageSClient, name, newImage)
}
Esempio n. 3
0
func addReplaceImage(imageSClient *srpc.Client,
	objectClient *objectclient.ObjectClient,
	name, baseImageName string, layerImageNames []string) error {
	imageExists, err := client.CheckImage(imageSClient, name)
	if err != nil {
		return errors.New("error checking for image existance: " + err.Error())
	}
	if imageExists {
		return errors.New("image exists")
	}
	newImage, err := getImage(imageSClient, baseImageName)
	if err != nil {
		return err
	}
	if !newImage.ExpiresAt.IsZero() {
		fmt.Fprintf(os.Stderr, "Skipping expiring image: %s\n", baseImageName)
		return nil
	}
	for _, layerImageName := range layerImageNames {
		fs, err := buildImage(imageSClient, newImage.Filter, layerImageName)
		if err != nil {
			return err
		}
		if err := layerImages(newImage.FileSystem, fs); err != nil {
			return err
		}
	}
	if err := spliceComputedFiles(newImage.FileSystem); err != nil {
		return err
	}
	return addImage(imageSClient, name, newImage)
}
Esempio n. 4
0
func checkImageSubcommand(args []string) {
	imageSClient, _ := getClients()
	imageExists, err := client.CheckImage(imageSClient, args[0])
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error checking image\t%s\n", err)
		os.Exit(1)
	}
	if imageExists {
		os.Exit(0)
	}
	os.Exit(1)
}