func()

in internal/fabric/stages.go [167:209]


func (s *Stage) Plan(verbose bool) error {
	var wg sync.WaitGroup
	var files []string

	// make some channels
	done := make(chan bool)
	result := make(chan terraform.PlanResult)

	// extract var files from stage
	for _, f := range s.StageVars {
		files = append(files, f.LocalPath)
	}

	// start an overwatch
	if !verbose {
		go utils.ProgressTicker(s.Type, &wg, done)
	}

	// do what we came here to do
	go func() {
		planResult := terraform.TfPlan(s.Path, files, nil, verbose)
		if !verbose {
			done <- true // only fire this channel if ticker is running
		}
		result <- planResult
	}()

	// catch the plan result
	planResult := <-result

	// wait for stuff to finish
	wg.Wait()

	// turndown the channels
	close(done)
	close(result)

	if planResult.Err != nil {
		return planResult.Err
	}

	return nil
}