mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
api: Allow submission of jobs with volumes
This commit is contained in:
@@ -189,6 +189,7 @@ func (s *HTTPServer) ValidateJobRequest(resp http.ResponseWriter, req *http.Requ
|
||||
}
|
||||
|
||||
job := ApiJobToStructJob(validateRequest.Job)
|
||||
|
||||
args := structs.JobValidateRequest{
|
||||
Job: job,
|
||||
WriteRequest: structs.WriteRequest{
|
||||
@@ -740,6 +741,29 @@ func ApiTgToStructsTG(taskGroup *api.TaskGroup, tg *structs.TaskGroup) {
|
||||
}
|
||||
}
|
||||
|
||||
if l := len(taskGroup.Volumes); l != 0 {
|
||||
tg.Volumes = make(map[string]*structs.VolumeRequest, l)
|
||||
for k, v := range taskGroup.Volumes {
|
||||
if v.Type != structs.VolumeTypeHost {
|
||||
// Ignore non-host volumes in this iteration currently.
|
||||
continue
|
||||
}
|
||||
|
||||
vol := &structs.Volume{
|
||||
Name: v.Name,
|
||||
Type: v.Type,
|
||||
ReadOnly: v.ReadOnly,
|
||||
Hidden: v.Hidden,
|
||||
Config: v.Config,
|
||||
}
|
||||
|
||||
tg.Volumes[k] = &structs.VolumeRequest{
|
||||
Volume: vol,
|
||||
Config: v.Config,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if taskGroup.Update != nil {
|
||||
tg.Update = &structs.UpdateStrategy{
|
||||
Stagger: *taskGroup.Update.Stagger,
|
||||
@@ -788,6 +812,17 @@ func ApiTaskToStructsTask(apiTask *api.Task, structsTask *structs.Task) {
|
||||
structsTask.Constraints = ApiConstraintsToStructs(apiTask.Constraints)
|
||||
structsTask.Affinities = ApiAffinitiesToStructs(apiTask.Affinities)
|
||||
|
||||
if l := len(apiTask.VolumeMounts); l != 0 {
|
||||
structsTask.VolumeMounts = make([]*structs.VolumeMount, l)
|
||||
for i, mount := range apiTask.VolumeMounts {
|
||||
structsTask.VolumeMounts[i] = &structs.VolumeMount{
|
||||
Volume: mount.Volume,
|
||||
Destination: mount.Destination,
|
||||
ReadOnly: mount.ReadOnly,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if l := len(apiTask.Services); l != 0 {
|
||||
structsTask.Services = make([]*structs.Service, l)
|
||||
for i, service := range apiTask.Services {
|
||||
|
||||
Reference in New Issue
Block a user