implement pullImage()

This commit is contained in:
2016-06-16 08:47:21 +02:00
parent 5cbcba2f1e
commit 51bf5cfd72
5 changed files with 69 additions and 9 deletions

View File

@ -57,11 +57,11 @@ export class Dockersock {
return this.request("GET","/images","?dangling=true");
}
pullImage(imageLabel:string){
return this.requestStream("POST","/images/create?fromImage=" + imageLabel);
};
createContainer(){
createContainer(imageNameArg,pullFirst:boolean = true){
return this.request("POST","/containers/create","",{
"image":""
"image":imageNameArg
});
};
getContainerId(){
@ -108,4 +108,24 @@ export class Dockersock {
});
return done.promise;
}
requestStream(methodArg,routeArg,endArg:boolean = true){
let done = plugins.q.defer();
if(methodArg == "POST"){
let requestStream = plugins.request.post(this.sockPath + routeArg)
.on("response",(response) => {
if(response.statusCode == 200){
if(endArg == true){
console.log("ending request");
response.emit("end");
} else {
console.log("streaming forever");
}
done.resolve(response);
} else {
done.reject();
}
})
}
return done.promise;
}
}