func searchImagesByTenantID(tenantID string) ([]*docker.Image, error) { images, err := docker.Images() if err != nil { return nil, err } var result []*docker.Image for i, image := range images { if image.ID.User == tenantID { result = append(result, images[i]) } } return result, nil }
func findImages(tenantID, tag string) ([]*docker.Image, error) { images, err := docker.Images() if err != nil { return nil, err } var result []*docker.Image for _, image := range images { if image.ID.Tag == tag && image.ID.User == tenantID { result = append(result, image) } } return result, nil }
func get_docker_image_tags(t log, imageId string) (map[string]bool, error) { images, err := docker.Images() if err != nil { t.Log("Failure to list docker images") return nil, err } result := make(map[string]bool) for _, image := range images { if image.ID.BaseName() == imageId { result[image.ID.Tag] = true } } if len(result) == 0 { return nil, fmt.Errorf("No such docker image: %s", imageId) } return result, nil }
func loadImage(filename string, uuid string, tags []string) error { // look up the image by UUID images, err := docker.Images() if err != nil { glog.Errorf("Could not look up images: %s", err) return err } var image *docker.Image for _, i := range images { if i.UUID == uuid { image = i break } } // image not found so import if image == nil { glog.Warningf("Importing image from file, don't forget to sync (serviced docker sync)") if err := docker.ImportImage(tags[0], filename); err != nil { glog.Errorf("Could not import image from file %s: %s", filename, err) return err } else if image, err = docker.FindImage(tags[0], false); err != nil { glog.Errorf("Could not look up docker image %s: %s", tags[0], err) return err } glog.Infof("Tagging images %v at %s", tags, image.UUID) tags = tags[1:] } // tag the remaining images for _, tag := range tags { if _, err := image.Tag(tag); err != nil { glog.Errorf("Could not tag image %s as %s: %s", image.UUID, tag, err) return err } } return nil }
func (dfs *DistributedFilesystem) registerImages(basename string) error { images, err := docker.Images() if err != nil { return err } for _, image := range images { imageID := image.ID if imageID.BaseName() == basename { imageID.Host, imageID.Port = dfs.dockerHost, dfs.dockerPort if t, err := image.Tag(imageID.String()); err != nil { glog.Errorf("Could not add tag %s to %s: %s", imageID, image.ID, err) return err } else if err := docker.PushImage(t.ID.String()); err != nil { glog.Errorf("Could not push image %s: %s", t.ID, err) return err } } } return nil }