diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index bfe81ff71..63d31eb3c 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -24,26 +24,13 @@ func (j *Job) Register(args *structs.JobRegisterRequest, reply *structs.JobRegis if args.Job == nil { return fmt.Errorf("missing job for registration") } - if args.Job.ID == "" { - return fmt.Errorf("missing job ID for registration") - } - if args.Job.Name == "" { - return fmt.Errorf("missing job name for registration") - } - if args.Job.Type == "" { - return fmt.Errorf("missing job type for registration") + if err := args.Job.Validate(); err != nil { + return err } if args.Job.Type == structs.JobTypeCore { return fmt.Errorf("job type cannot be core") } - // Ensure priorities are bounded - if args.Job.Priority < structs.JobMinPriority { - args.Job.Priority = structs.JobMinPriority - } else if args.Job.Priority > structs.JobMaxPriority { - args.Job.Priority = structs.JobMaxPriority - } - // Commit this update via Raft _, index, err := j.srv.raftApply(structs.JobRegisterRequestType, args) if err != nil {