github.com/cloud-foundations/dominator@v0.0.0-20221004181915-6e4fee580046/imageserver/client/findLatestImage.go (about)

     1  package client
     2  
     3  import (
     4  	"github.com/Cloud-Foundations/Dominator/lib/errors"
     5  	"github.com/Cloud-Foundations/Dominator/lib/srpc"
     6  	"github.com/Cloud-Foundations/Dominator/proto/imageserver"
     7  )
     8  
     9  func findLatestImage(client *srpc.Client, dirname string,
    10  	ignoreExpiring bool) (string, error) {
    11  	request := imageserver.FindLatestImageRequest{
    12  		DirectoryName:        dirname,
    13  		IgnoreExpiringImages: ignoreExpiring,
    14  	}
    15  	var reply imageserver.FindLatestImageResponse
    16  	err := client.RequestReply("ImageServer.FindLatestImage", request, &reply)
    17  	if err == nil {
    18  		err = errors.New(reply.Error)
    19  	}
    20  	if err != nil {
    21  		return "", err
    22  	}
    23  	return reply.ImageName, nil
    24  }