github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/providers/gcloud/list_images.go (about)

     1  package gcloud
     2  
     3  import (
     4  	"github.com/solo-io/unik/pkg/types"
     5  )
     6  
     7  func (p *GcloudProvider) ListImages() ([]*types.Image, error) {
     8  	images := []*types.Image{}
     9  	for _, image := range p.state.GetImages() {
    10  		if p.verifyImage(image.Name) {
    11  			images = append(images, image)
    12  		} else {
    13  			p.state.RemoveImage(image)
    14  		}
    15  	}
    16  	return images, nil
    17  }
    18  
    19  func (p *GcloudProvider) verifyImage(imageName string) bool {
    20  	_, err := p.compute().Images.Get(p.config.ProjectID, imageName).Do()
    21  	return err == nil
    22  }