예제 #1
0
func generateURL(options *flags.Options) string {
	if options.Arch == "arm" {
		options.Arch += "hf"
	}
	return fmt.Sprintf("%s/%s/%s/generic_%s/%s",
		baseURL, options.Release, options.OSChannel, options.Arch, dataFileName)
}
예제 #2
0
// extractVersionsFromList returns a list of image names that match the given
// release, channel and arch sorted in descendant version number order
func (c *Client) extractVersionsFromList(options flags.Options) ([]string, error) {
	options.Release = removeDot(options.Release)
	var imageIDs sort.StringSlice
	imageIDs, err := c.getImageList(imgTemplate(&options))
	if err != nil {
		return imageIDs, err
	}
	if len(imageIDs) > 0 {
		sort.Sort(sort.Reverse(imageIDs[:]))
		return imageIDs, nil
	}
	return []string{}, NewErrVersionNotFound(&options)
}
예제 #3
0
func (r *Runner) cleanup(options *flags.Options) (err error) {
	options.Release = strings.Replace(options.Release, ".", "", 1)
	imageList, err := r.imgDataTarget.GetVersions(options)
	if err != nil {
		log.Info("Error getting image list")
		return
	}
	if len(imageList) > imagesToKeep {
		// assumes that imageList is sorted in descending order,
		// the last items in the list will be the older ones
		log.Infof("Removing images %s", imageList[imagesToKeep:])
		err = r.imgDataTarget.Delete(imageList[imagesToKeep:]...)
	}
	return
}
예제 #4
0
// GetImageID returns the image name for the given parameters
func GetImageID(options *flags.Options, version int) (name string) {
	options.Release = removeDot(options.Release)
	imageNamePrefix := imgTemplate(options)

	finalVersion := strconv.Itoa(version)
	// The numeric version makes sense for system-image based images, on all-snaps
	// the version of the image, if any, should be determined by the versions of
	// the snaps that form it. For the time being we assume by convention that
	// version == 0 means all-snaps, and we replace it by a timestamp so that we are
	// able to sort images by date
	if version == 0 {
		finalVersion = time.Now().Format("20060102150405.000000")
	}

	return fmt.Sprintf("%s-%s-%s", imageNamePrefix, finalVersion, imageNameSufix)
}