Reduce scheduler validation scope to package of schedulerManager
@@ -49,7 +49,7 @@ func NewSchedulerManager(schedulerStorage ports.SchedulerStorage, operationManag
func (s *SchedulerManager) CreateScheduler(ctx context.Context, scheduler *entities.Scheduler) (*entities.Scheduler, error) {
scheduler.State = entities.StateCreating
- err := validator.Validate(scheduler)
+ err := s.validateScheduler(scheduler)
if err != nil {
return nil, err
}
@@ -72,3 +72,9 @@ func (s *SchedulerManager) CreateScheduler(ctx context.Context, scheduler *entit
func (s *SchedulerManager) GetAllSchedulers(ctx context.Context) ([]*entities.Scheduler, error) {
return s.schedulerStorage.GetAllSchedulers(ctx)
}
+
+// WARN: This function should be called only on private scope of SchedulerManager.
+// WARN: Other packages should NEVER call this function.
+func (s *SchedulerManager) validateScheduler(scheduler *entities.Scheduler) error {
+ return validator.Validate(scheduler)
+}
