code: func (r *RotateRequest) CheckAndSetDefaults(clock clockwork.Clock) error {
  	if r.TargetPhase == "" {
  		// if phase if not set, imply that the first meaningful phase
  		// is set as a target phase
  		r.TargetPhase = services.RotationPhaseInit
  	}
  	// if mode is not set, default to manual (as it's safer)
  	if r.Mode == "" {
  		r.Mode = services.RotationModeManual
  	}
  	switch r.Type {
  	case "", services.HostCA, services.UserCA:
  	default:
  		return trace.BadParameter("unsupported certificate authority type: %q", r.Type)
  	}
  	if r.GracePeriod == nil {
  		period := defaults.RotationGracePeriod
  		r.GracePeriod = &period
  	}
  	if r.Schedule == nil {
  		var err error
  		r.Schedule, err = services.GenerateSchedule(clock, *r.GracePeriod)
  		if err != nil {
  			return trace.Wrap(err)
  		}
  	} else {
  		if err := r.Schedule.CheckAndSetDefaults(clock); err != nil {
  			return trace.Wrap(err)
  		}
  	}
  	return nil
  }
docs: // CheckAndSetDefaults checks and sets default values.