From 51bf5cfd728c4c105cb4742c2833f14fa723f3c0 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 16 Jun 2016 08:47:21 +0200 Subject: [PATCH] implement pullImage() --- dist/dockersock.classes.dockersock.d.ts | 5 ++-- dist/dockersock.classes.dockersock.js | 31 ++++++++++++++++++++++--- test/test.js | 9 ++++++- test/test.ts | 7 ++++++ ts/dockersock.classes.dockersock.ts | 26 ++++++++++++++++++--- 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/dist/dockersock.classes.dockersock.d.ts b/dist/dockersock.classes.dockersock.d.ts index 75c1418..ff9146b 100644 --- a/dist/dockersock.classes.dockersock.d.ts +++ b/dist/dockersock.classes.dockersock.d.ts @@ -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; } diff --git a/dist/dockersock.classes.dockersock.js b/dist/dockersock.classes.dockersock.js index cc4c0a2..8d4e35d 100644 --- a/dist/dockersock.classes.dockersock.js +++ b/dist/dockersock.classes.dockersock.js @@ -60,11 +60,13 @@ var Dockersock = (function () { return this.request("GET", "/images", "?dangling=true"); }; Dockersock.prototype.pullImage = function (imageLabel) { + return this.requestStream("POST", "/images/create?fromImage=" + imageLabel); }; ; - Dockersock.prototype.createContainer = function () { + Dockersock.prototype.createContainer = function (imageNameArg, pullFirst) { + if (pullFirst === void 0) { pullFirst = true; } return this.request("POST", "/containers/create", "", { - "image": "" + "image": imageNameArg }); }; ; @@ -121,8 +123,31 @@ var Dockersock = (function () { }); return done.promise; }; + Dockersock.prototype.requestStream = function (methodArg, routeArg, endArg) { + if (endArg === void 0) { endArg = true; } + var done = plugins.q.defer(); + if (methodArg == "POST") { + var requestStream = plugins.request.post(this.sockPath + routeArg) + .on("response", function (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; + }; return Dockersock; }()); exports.Dockersock = Dockersock; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRvY2tlcnNvY2suY2xhc3Nlcy5kb2NrZXJzb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBWSxPQUFPLFdBQU0sc0JBQXNCLENBQUMsQ0FBQTtBQUVoRDtJQUVJLG9CQUFZLE9BQW9EO1FBQXBELHVCQUFvRCxHQUFwRCw2Q0FBb0Q7UUFDNUQsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUM7SUFDNUIsQ0FBQztJQUVELFVBQVU7SUFDVix5QkFBSSxHQUFKLFVBQUssT0FBYyxFQUFDLE9BQWM7UUFDOUIsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sRUFBQyxFQUFFLENBQUMsQ0FBQztRQUN4QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBQ0QsbUNBQWMsR0FBZDtRQUNJLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDN0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUMsYUFBYSxDQUFDO2FBQzVCLElBQUksQ0FBQyxJQUFJLENBQUMsT0F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ICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXF1ZXN0KFwiR0VUXCIsXCIvY29udGFpbmVycy9cIiArIGRhdGFBcmdbcmVjdXJzaXZlQ291bnRlcl0uSWQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbGVkRGF0YU9iamVjdC5wdXNoKGRhdGFBcmcyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaXZlQ291bnRlcisrO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZWN1cnNpdmUgY2FsbFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWtlRGV0YWlsZWQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShkZXRhaWxlZERhdGFPYmplY3QpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtYWtlRGV0YWlsZWQoKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH07XG4gICAgbGlzdENvbnRhaW5lcnNSdW5uaW5nKCkge1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICBsaXN0Q29udGFpbmVyc1N0b3BwZWQoKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIGxpc3RJbWFnZXMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoXCJHRVRcIixcIi9pbWFnZXNcIixcIj9hbGw9dHJ1ZVwiKTtcbiAgICB9XG4gICAgbGlzdEltYWdlc0RhbmdsaW5nKCl7XG4gICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoXCJHRVRcIixcIi9pbWFnZXNcIixcIj9kYW5nbGluZz10cnVlXCIpO1xuICAgIH1cbiAgICBwdWxsSW1hZ2UoaW1hZ2VMYWJlbDpzdHJpbmcpe1xuXG4gICAgfTtcbiAgICBjcmVhdGVDb250YWluZXIoKXtcbiAgICAgICAgcmV0dXJuIHRoaXMucmVxdWVzdChcIlBPU1RcIixcIi9jb250YWluZXJzL2NyZWF0ZVwiLFwiXCIse1xuICAgICAgICAgICAgXCJpbWFnZVwiOlwiXCJcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBnZXRDb250YWluZXJJZCgpe1xuXG4gICAgfTtcbiAgICBzdGFydENvbnRhaW5lcihjb250YWluZXJOYW1lQXJnKXtcbiAgICAgICAgcmV0dXJuIHRoaXMucmVxdWVzdChcIlBPU1RcIixcIi9jb250YWluZXJzL1wiKyBjb250YWluZXJOYW1lQXJnICtcIi9zdGFydFwiKTtcbiAgICB9O1xuICAgIHN0b3BDb250YWluZXIoY29udGFpbmVyTmFtZUFyZyl7XG4gICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoXCJQT1NUXCIsXCIvY29udGFpbmVycy9cIisgY29udGFpbmVyTmFtZUFyZyArXCIvc3RvcFwiKTtcbiAgICB9O1xuICAgIHJlbW92ZUNvbnRhaW5lcihjb250YWluZXJOYW1lQXJnKXtcbiAgICAgICAgcmV0dXJuIHRoaXMucmVxdWVzdChcIkRFTEVURVwiLFwiL2NvbnRhaW5lcnMvXCIgKyBjb250YWluZXJOYW1lQXJnICsgXCI/dj0xXCIpO1xuICAgIH07XG4gICAgY2xlYW4oKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfTtcbiAgICBnZXRDaGFuZ2UoKXtcblxuICAgIH07XG4gICAgcmVxdWVzdChtZXRob2RBcmc6c3RyaW5nLHJvdXRlQXJnOnN0cmluZyxxdWVyeUFyZzpzdHJpbmcgPSBcIlwiLCBkYXRhQXJnID0ge30pe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBsZXQganNvbkFyZzpzdHJpbmcgPSBKU09OLnN0cmluZ2lmeShkYXRhQXJnKTtcbiAgICAgICAgbGV0IHN1ZmZpeDpzdHJpbmcgPSBcIlwiO1xuICAgICAgICBpZihtZXRob2RBcmcgPT0gXCJHRVRcIikgc3VmZml4ID0gXCIvanNvblwiO1xuICAgICAgICBsZXQgb3B0aW9ucyA9IHtcbiAgICAgICAgICAgIG1ldGhvZDptZXRob2RBcmcsXG4gICAgICAgICAgICB1cmw6dGhpcy5zb2NrUGF0aCArIHJvdXRlQXJnICsgc3VmZml4ICsgcXVlcnlBcmcsXG4gICAgICAgICAgICBoZWFkZXJzOntcbiAgICAgICAgICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOlwiYXBwbGljYXRpb24vanNvblwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYm9keTpqc29uQXJnXG4gICAgICAgIH07XG4gICAgICAgIHBsdWdpbnMucmVxdWVzdChvcHRpb25zLChlcnIsIHJlcywgYm9keSkgPT4ge1xuICAgICAgICAgICAgaWYgKCFlcnIgJiYgcmVzLnN0YXR1c0NvZGUgPT0gMjAwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3BvbnNlT2JqID0gSlNPTi5wYXJzZShib2R5KTtcbiAgICAgICAgICAgICAgICBkb25lLnJlc29sdmUocmVzcG9uc2VPYmopO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhlcnIpO1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHJlcyk7XG4gICAgIC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l2ZUNvdW50ZXJdICE9IFwidW5kZWZpbmVkXCIpe1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXF1ZXN0KFwiR0VUXCIsXCIvY29udGFpbmVycy9cIiArIGRhdGFBcmdbcmVjdXJzaXZlQ291bnRlcl0uSWQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcyKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbGVkRGF0YU9iamVjdC5wdXNoKGRhdGFBcmcyKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdXJzaXZlQ291bnRlcisrO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZWN1cnNpdmUgY2FsbFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWtlRGV0YWlsZWQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShkZXRhaWxlZERhdGFPYmplY3QpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBtYWtlRGV0YWlsZWQoKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH07XG4gICAgbGlzdENvbnRhaW5lcnNSdW5uaW5nKCkge1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICBsaXN0Q29udGFpbmVyc1N0b3BwZWQoKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIGxpc3RJbWFnZXMoK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nKXtcbiAgICAgICAgcmV0dXJuIHRoaXMucmVxdWVzdChcIkRFTEVURVwiLFwiL2NvbnRhaW5lcnMvXCIgKyBjb250YWluZXJOYW1lQXJnICsgXCI/dj0xXCIpO1xuICAgIH07XG4gICAgY2xlYW4oKSB7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfTtcbiAgICBnZXRDaGFuZ2UoKXtcblxuICAgIH07XG4gICAgcmVxdWVzdChtZXRob2RBcmc6c3RyaW5nLHJvdXRlQXJnOnN0cmluZyxxdWVyeUFyZzpzdHJpbmcgPSBcIlwiLCBkYXRhQXJnID0ge30pe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBsZXQganNvbkFyZzpzdHJpbmcgPSBKU09OLnN0cmluZ2lmeShkYXRhQXJnKTtcbiAgICAgICAgbGV0IHN1ZmZpeDpzdHJpbmcgPSBcIlwiO1xuICAgICAgICBpZihtZXRob2RBcmcgPT0gXCJHRVRcIikgc3VmZml4ID0gXCIvanNvblwiO1xuICAgICAgICBsZXQgb3B0aW9ucyA9IHtcbiAgICAgICAgICAgIG1ldGhvZDptZXRob2RBcmcsXG4gICAgICAgICAgICB1cmw6dGhpcy5zb2NrUGF0aCArIHJvdXRlQXJnICsgc3VmZml4ICsgcXVlcnlBcmcsXG4gICAgICAgICAgICBoZWFkZXJzOntcbiAgICAgICAgICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOlwiYXBwbGljYXRpb24vanNvblwiXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYm9keTpqc29uQXJnXG4gICAgICAgIH07XG4gICAgICAgIHBsdWdpbnMucmVxdWVzdChvcHRpb25zLChlcnIsIHJlcywgYm9keSkgPT4ge1xuICAgICAgICAgICAgaWYgKCFlcnIgJiYgcmVzLnN0YXR1c0NvZGUgPT0gMjAwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlc3BvbnNlT2JqID0gSlNPTi5wYXJzZShib2R5KTtcbiAgICAgICAgICAgICAgICBkb25lLnJlc29sdmUocmVzcG9uc2VPYmopO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhlcnIpO1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHJlcyk7XG4gICAgICAgICAgICAgICAgZG9uZS5yZWplY3QoZXJyKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICByZXF1ZXN0U3RyZWFtKG1ldGhvZEFyZyxyb3V0ZUFyZyxlbmRBcmc6Ym9vbGVhbiA9IHRydWUpe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBpZihtZXRob2RBcmcgPT0gXCJQT1NUXCIpe1xuICAgICAgICAgICAgbGV0IHJlcXVlc3RTdHJlYW0gPSBwbHVnaW5zLnJlcXVlc3QucG9zdCh0aGlzLnNvY2tQYXRoICsgcm91dGVBcmcpXG4gICAgICAgICAgICAgICAgLm9uKFwicmVzcG9uc2VcIiwocmVzcG9uc2UpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgaWYocmVzcG9uc2Uuc3RhdHVzQ29kZSA9PSAyMDApe1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYoZW5kQXJnID09IHRydWUpe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiZW5kaW5nIHJlcXVlc3RcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2UuZW1pdChcImVuZFwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJzdHJlYW1pbmcgZm9yZXZlclwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShyZXNwb25zZSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkb25lLnJlamVjdCgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbn0iXX0= diff --git a/test/test.js b/test/test.js index f21c742..16e85d1 100644 --- a/test/test.js +++ b/test/test.js @@ -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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUVQLENBQUMsQ0FGYztBQUVmLHNCQUF5QixlQUV6QixDQUFDLENBRnVDO0FBRXhDLFFBQVEsQ0FBQyxZQUFZLEVBQUM7SUFDbEIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLGNBQXlCLENBQUM7UUFDOUIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDO1lBQ3pDLGNBQWMsR0FBRyxJQUFJLGtCQUFVLEVBQUUsQ0FBQztZQUNsQyxjQUFjLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsa0JBQVUsQ0FBQyxDQUFDO1FBQ3BELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLHdCQUF3QixFQUFDLFVBQVMsSUFBSTtZQUNyQyxjQUFjLENBQUMsY0FBYyxFQUFFO2lCQUMxQixJQUFJLENBQU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hbmNlb2YoRG9ja2Vyc29jayk7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBsaXN0IGNvbnRhaW5lcnNcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIHRlc3REb2NrZXJzb2NrLmxpc3RDb250YWluZXJzKClcbiAgICAgICAgICAgICAgICAudGhlbigoZGF0YUFyZyk9PntcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coZGF0YUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIGl0KFwic2hvdWxkIGxpc3QgZGV0YWlsZWQgY29udGFpbmVyc1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDUwMDApO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2subGlzdENvbnRhaW5lcnNEZXRhaWxlZCgpXG4gICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcpPT57XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGRhdGFBcmcpO1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH0pO1xufSk7Il19 +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUVQLENBQUMsQ0FGYztBQUVmLHNCQUF5QixlQUV6QixDQUFDLENBRnVDO0FBRXhDLFFBQVEsQ0FBQyxZQUFZLEVBQUM7SUFDbEIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLGNBQXlCLENBQUM7UUFDOUIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDO1lBQ3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BQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy10ZXN0XCI7XG5pbXBvcnQgXCJzaG91bGRcIlxuXG5pbXBvcnQge0RvY2tlcnNvY2t9IGZyb20gXCIuLi9kaXN0L2luZGV4XCJcblxuZGVzY3JpYmUoXCJkb2NrZXJzb2NrXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5Eb2NrZXJzb2NrKClcIixmdW5jdGlvbigpe1xuICAgICAgICBsZXQgdGVzdERvY2tlcnNvY2s6RG9ja2Vyc29jaztcbiAgICAgICAgaXQoXCJzaG91bGQgY3JlYXRlIGEgbmV3IERvY2tlcnNvY2sgaW5zdGFuY2VcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2sgPSBuZXcgRG9ja2Vyc29jaygpO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2suc2hvdWxkLmJlLmluc3RhbmNlb2YoRG9ja2Vyc29jayk7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBsaXN0IGNvbnRhaW5lcnNcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIHRlc3REb2NrZXJzb2NrLmxpc3RDb250YWluZXJzKClcbiAgICAgICAgICAgICAgICAudGhlbigoZGF0YUFyZyk9PntcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coZGF0YUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIGl0KFwic2hvdWxkIGxpc3QgZGV0YWlsZWQgY29udGFpbmVyc1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDUwMDApO1xuICAgICAgICAgICAgdGVzdERvY2tlcnNvY2subGlzdENvbnRhaW5lcnNEZXRhaWxlZCgpXG4gICAgICAgICAgICAgICAgLnRoZW4oKGRhdGFBcmcpPT57XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGRhdGFBcmcpO1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBwdWxsIGFuIGltYWdlIGZyb20gaW1hZ2V0YWdcIixmdW5jdGlvbihkb25lKXtcbiAgICAgICAgICAgIHRoaXMudGltZW91dCgxMDAwMCk7XG4gICAgICAgICAgICB0ZXN0RG9ja2Vyc29jay5wdWxsSW1hZ2UoXCJuZ2lueFwiKVxuICAgICAgICAgICAgICAgIC50aGVuKChkYXRhQXJnKT0+e1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSxkb25lKTtcbiAgICAgICAgfSlcbiAgICB9KTtcbn0pOyJdfQ== diff --git a/test/test.ts b/test/test.ts index 2efd9f9..de4eaa2 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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); + }) }); }); \ No newline at end of file diff --git a/ts/dockersock.classes.dockersock.ts b/ts/dockersock.classes.dockersock.ts index 149fe88..51fbe01 100644 --- a/ts/dockersock.classes.dockersock.ts +++ b/ts/dockersock.classes.dockersock.ts @@ -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; + } } \ No newline at end of file