in cli_tools/gce_image_publish/publish/publish.go [556:605]
func (p *Publish) createWorkflow(ctx context.Context, img *Image, varMap map[string]string, rb, sd, rep, noRoot bool, oauth string, rolloutStartTime time.Time, rolloutRate int, clientOptions ...option.ClientOption) (*daisy.Workflow, error) {
fmt.Printf(" - Creating publish workflow for %q\n", img.Prefix)
w := daisy.New()
for k, v := range varMap {
w.AddVar(k, v)
}
if oauth != "" {
w.OAuthPath = oauth
}
if p.ComputeEndpoint != "" {
w.ComputeEndpoint = p.ComputeEndpoint
}
if err := w.PopulateClients(ctx, clientOptions...); err != nil {
return nil, fmt.Errorf("PopulateClients failed: %s", err)
}
w.Name = img.Prefix
w.Project = p.WorkProject
cacheKey := w.ComputeClient.BasePath() + p.PublishProject
pubImgs, ok := p.imagesCache[cacheKey]
if !ok {
var err error
pubImgs, err = w.ComputeClient.ListImagesAlpha(p.PublishProject, daisyCompute.OrderBy("creationTimestamp desc"))
if err != nil {
return nil, fmt.Errorf("computeClient.ListImagesAlpha failed: %s", err)
}
if p.imagesCache != nil {
p.imagesCache[cacheKey] = pubImgs
}
}
zones, err := w.ComputeClient.ListZones(w.Project)
if err != nil {
return nil, fmt.Errorf("computeClient.GetZone failed: %s", err)
}
img.RolloutPolicy = createRollOut(zones, rolloutStartTime, rolloutRate)
if err := p.populateWorkflow(ctx, w, pubImgs, img, rb, sd, rep, noRoot); err != nil {
return nil, fmt.Errorf("populateWorkflow failed: %s", err)
}
if len(w.Steps) == 0 {
return nil, nil
}
return w, nil
}