implement pullImage()
This commit is contained in:
parent
5cbcba2f1e
commit
51bf5cfd72
5
dist/dockersock.classes.dockersock.d.ts
vendored
5
dist/dockersock.classes.dockersock.d.ts
vendored
@ -9,8 +9,8 @@ export declare class Dockersock {
|
||||
listContainersStopped(): any;
|
||||
listImages(): any;
|
||||
listImagesDangling(): any;
|
||||
pullImage(imageLabel: string): void;
|
||||
createContainer(): any;
|
||||
pullImage(imageLabel: string): any;
|
||||
createContainer(imageNameArg: any, pullFirst?: boolean): any;
|
||||
getContainerId(): void;
|
||||
startContainer(containerNameArg: any): any;
|
||||
stopContainer(containerNameArg: any): any;
|
||||
@ -18,4 +18,5 @@ export declare class Dockersock {
|
||||
clean(): any;
|
||||
getChange(): void;
|
||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any;
|
||||
requestStream(methodArg: any, routeArg: any, endArg?: boolean): any;
|
||||
}
|
||||
|
31
dist/dockersock.classes.dockersock.js
vendored
31
dist/dockersock.classes.dockersock.js
vendored
File diff suppressed because one or more lines are too long
@ -24,7 +24,14 @@ describe("dockersock", function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should pull an image from imagetag", function (done) {
|
||||
this.timeout(10000);
|
||||
testDockersock.pullImage("nginx")
|
||||
.then(function (dataArg) {
|
||||
done();
|
||||
}, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUVQLENBQUMsQ0FGYztBQUVmLHNCQUF5QixlQUV6QixDQUFDLENBRnVDO0FBRXhDLFFBQVEsQ0FBQyxZQUFZLEVBQUM7SUFDbEIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLGNBQXlCLENBQUM7UUFDOUIsRUFBRSxDQU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mliZShcIi5Eb2NrZXJzb2NrKClcIixmdW5jdGlvbigpe1xuICAgICAgICBsZXQgdGVzdERvY2tlcnNvY2s6RG9ja2Vyc29jaztcbiAgICAgICAgaXQoXCJzaG91bGQgY3JlYXRlIGEgbmV3IERvY2tlcnNvY2sgaW5zdGFuY2VcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2sgPSBuZXcgRG9ja2Vyc29jaygpO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2suc2hvdWxkLmJlLmluc3RhbmNlb2YoRG9ja2Vyc29jayk7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBsaXN0IGNvbnRhaW5lcnNcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIHRlc3REb2NrZXJzb2NrLmxpc3RDb250YWluZXJzKClcbiAgICAgICAgICAgICAgICAudGhlbigoZGF0YUFyZyk9PntcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coZGF0YUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIGl0KFwic2hvdWxkIGxpc3QgZGV0YWlsZWQgY29udGFpbmVyc1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDUwMDApO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2subGlzdENvbnRhaW5lcnNEZXRhaWxlZCgpXG4gICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcpPT57XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGRhdGFBcmcpO1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH0pO1xufSk7Il19
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIj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AgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coZGF0YUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIGl0KFwic2hvdWxkIGxpc3QgZGV0YWlsZWQgY29udGFpbmVyc1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDUwMDApO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2subGlzdENvbnRhaW5lcnNEZXRhaWxlZCgpXG4gICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcpPT57XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGRhdGFBcmcpO1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBwdWxsIGFuIGltYWdlIGZyb20gaW1hZ2V0YWdcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIHRoaXMudGltZW91dCgxMDAwMCk7XG4gICAgICAgICAgICB0ZXN0RG9ja2Vyc29jay5wdWxsSW1hZ2UoXCJuZ2lueFwiKVxuICAgICAgICAgICAgICAgIC50aGVuKChkYXRhQXJnKT0+e1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSxkb25lKTtcbiAgICAgICAgfSlcbiAgICB9KTtcbn0pOyJdfQ==
|
||||
|
@ -25,5 +25,12 @@ describe("dockersock",function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should pull an image from imagetag",function(done){
|
||||
this.timeout(10000);
|
||||
testDockersock.pullImage("nginx")
|
||||
.then((dataArg)=>{
|
||||
done();
|
||||
},done);
|
||||
})
|
||||
});
|
||||
});
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user