func RunStepsAndWait()

in internal/components/setup/common.go [37:80]


func RunStepsAndWait(steps []config.Step, waitTimeout time.Duration, k8sCluster *util.K8sClusterInfo) error {
	logger.Log.Debugf("wait timeout is %v", waitTimeout.String())

	// record time now
	timeNow := time.Now()

	for _, step := range steps {
		logger.Log.Infof("processing setup step [%s]", step.Name)

		if step.Path != "" && step.Command == "" {
			if k8sCluster == nil {
				return fmt.Errorf("not support path")
			}
			manifest := config.Manifest{
				Path:  step.Path,
				Waits: step.Waits,
			}
			err := createManifestAndWait(k8sCluster, manifest, waitTimeout)
			if err != nil {
				return err
			}
		} else if step.Command != "" && step.Path == "" {
			command := config.Run{
				Command: step.Command,
				Waits:   step.Waits,
			}

			err := RunCommandsAndWait(command, waitTimeout, k8sCluster)
			if err != nil {
				return err
			}
		} else {
			return fmt.Errorf("step parameter error, one Path or one Command should be specified, but got %+v", step)
		}

		waitTimeout = NewTimeout(timeNow, waitTimeout)
		timeNow = time.Now()

		if waitTimeout <= 0 {
			return fmt.Errorf("setup timeout")
		}
	}
	return nil
}