func()

in step_deprecate_images.go [78:111]


func (d *DeprecateImages) run(ctx context.Context, s *Step) DError {
	var wg sync.WaitGroup
	w := s.w
	e := make(chan DError)
	for _, di := range *d {
		wg.Add(1)
		go func(di *DeprecateImage) {
			defer wg.Done()
			var err error
			if di.DeprecationStatusAlpha.State != "" {
				w.LogStepInfo(s.name, "DeprecateImages", "%q --> %q with DefaultRolloutTime %s.", di.Image, di.DeprecationStatusAlpha.State, di.DeprecationStatusAlpha.StateOverride.DefaultRolloutTime)
				err = w.ComputeClient.DeprecateImageAlpha(di.Project, di.Image, &di.DeprecationStatusAlpha)
			} else {
				w.LogStepInfo(s.name, "DeprecateImages", "%q --> %q.", di.Image, di.DeprecationStatus.State)
				err = w.ComputeClient.DeprecateImage(di.Project, di.Image, &di.DeprecationStatus)
			}
			if err != nil {
				e <- newErr("failed to deprecate images", err)
			}
		}(di)
	}

	go func() {
		wg.Wait()
		e <- nil
	}()

	select {
	case err := <-e:
		return err
	case <-w.Cancel:
		return nil
	}
}