(w http.ResponseWriter, r *http.Request)
| 1161 | } |
| 1162 | |
| 1163 | func (s *DockerServer) createExecContainer(w http.ResponseWriter, r *http.Request) { |
| 1164 | id := mux.Vars(r)["id"] |
| 1165 | container, err := s.findContainer(id) |
| 1166 | if err != nil { |
| 1167 | http.Error(w, err.Error(), http.StatusNotFound) |
| 1168 | return |
| 1169 | } |
| 1170 | |
| 1171 | execID := s.generateID() |
| 1172 | s.cMut.Lock() |
| 1173 | container.ExecIDs = append(container.ExecIDs, execID) |
| 1174 | s.cMut.Unlock() |
| 1175 | |
| 1176 | exec := docker.ExecInspect{ |
| 1177 | ID: execID, |
| 1178 | ContainerID: container.ID, |
| 1179 | } |
| 1180 | |
| 1181 | var params docker.CreateExecOptions |
| 1182 | err = json.NewDecoder(r.Body).Decode(¶ms) |
| 1183 | if err != nil { |
| 1184 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 1185 | return |
| 1186 | } |
| 1187 | if len(params.Cmd) > 0 { |
| 1188 | exec.ProcessConfig.EntryPoint = params.Cmd[0] |
| 1189 | if len(params.Cmd) > 1 { |
| 1190 | exec.ProcessConfig.Arguments = params.Cmd[1:] |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | exec.ProcessConfig.User = params.User |
| 1195 | exec.ProcessConfig.Tty = params.Tty |
| 1196 | |
| 1197 | s.execMut.Lock() |
| 1198 | s.execs = append(s.execs, &exec) |
| 1199 | s.execMut.Unlock() |
| 1200 | w.WriteHeader(http.StatusOK) |
| 1201 | w.Header().Set("Content-Type", "application/json") |
| 1202 | json.NewEncoder(w).Encode(map[string]string{"Id": exec.ID}) |
| 1203 | } |
| 1204 | |
| 1205 | func (s *DockerServer) startExecContainer(w http.ResponseWriter, r *http.Request) { |
| 1206 | id := mux.Vars(r)["id"] |
nothing calls this directly
no test coverage detected