daemon: Job types as dedicated type

refs #67
This commit is contained in:
Christian Schwarz
2018-04-05 22:22:55 +02:00
parent 0895e02844
commit aa3865d0a3
6 changed files with 44 additions and 5 deletions

View File

@ -162,20 +162,25 @@ func parseJob(c JobParsingContext, i map[string]interface{}) (j Job, err error)
}
}
jobtype, err := extractStringField(i, "type", true)
jobtypeStr, err := extractStringField(i, "type", true)
if err != nil {
return
}
jobtype, err := ParseUserJobType(jobtypeStr)
if err != nil {
return
}
switch jobtype {
case "pull":
case JobTypePull:
return parsePullJob(c, name, i)
case "source":
case JobTypeSource:
return parseSourceJob(c, name, i)
case "local":
case JobTypeLocal:
return parseLocalJob(c, name, i)
default:
return nil, errors.Errorf("unknown job type '%s'", jobtype)
panic(fmt.Sprintf("implementation error: unknown job type %s", jobtype))
}
}