Compare commits

...

3 Commits

Author SHA1 Message Date
7049ddc5f2 1.0.2 2016-06-16 01:35:40 +02:00
2b6088b1d7 tests now also run before releases 2016-06-16 01:35:34 +02:00
880655b4e2 implement listContainers and listContainersDetailed 2016-06-16 01:34:23 +02:00
5 changed files with 108 additions and 9 deletions

View File

@ -27,8 +27,6 @@ test:
stage: test stage: test
script: script:
- npmci test docker - npmci test docker
only:
- master
tags: tags:
- lossless - lossless
- priv - priv

View File

@ -1,6 +1,12 @@
import "typings-global"; import "typings-global";
export declare class dockersock { export declare class dockersock {
sockPath: string; sockPath: string;
constructor(pathArg: string); constructor(pathArg?: string);
listContainers(): any;
listContainersDetailed(): any;
listContainersRunning(): any;
listContainersStopped(): any;
listImages(): any;
clean(): any;
request(methodArg: string, routeArg: string, dataArg?: {}): any; request(methodArg: string, routeArg: string, dataArg?: {}): any;
} }

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "dockersock", "name": "dockersock",
"version": "1.0.1", "version": "1.0.2",
"description": "easy communication with docker from node, TypeScript ready", "description": "easy communication with docker from node, TypeScript ready",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {

View File

@ -3,16 +3,62 @@ import * as plugins from "./dockersock.plugins";
export class dockersock { export class dockersock {
sockPath:string; sockPath:string;
constructor(pathArg:string){ constructor(pathArg:string = "http://unix:/var/run/docker.sock:"){
this.sockPath = pathArg; this.sockPath = pathArg;
} }
// methods
listContainers() {
let done = plugins.q.defer();
this.request("GET","/containers")
.then(done.resolve);
return done.promise;
};
listContainersDetailed() {
let done = plugins.q.defer();
let detailedDataObject = [];
this.listContainers()
.then((dataArg) => {
let recursiveCounter = 0;
let makeDetailed = function(){
if(typeof dataArg[recursiveCounter] != "undefined"){
this.request.get("GET","/containers/" + dataArg[recursiveCounter].Id)
.then((data) => {
recursiveCounter++;
detailedDataObject.push(data);
makeDetailed();
});
} else {
done.resolve(detailedDataObject);
}
};
makeDetailed();
});
return done.promise;
};
listContainersRunning() {
let done = plugins.q.defer();
return done.promise;
}
listContainersStopped() {
let done = plugins.q.defer();
return done.promise;
}
listImages() {
let done = plugins.q.defer();
return done.promise;
}
clean() {
let done = plugins.q.defer();
return done.promise;
}
request(methodArg:string,routeArg:string,dataArg = {}){ request(methodArg:string,routeArg:string,dataArg = {}){
let done = plugins.q.defer(); let done = plugins.q.defer();
let jsonArg:string = JSON.stringify(dataArg); let jsonArg:string = JSON.stringify(dataArg);
let options = { let options = {
method:methodArg, method:methodArg,
url:"http://unix:/var/run/docker.sock:" + routeArg + "/json", url:this.sockPath + routeArg + "/json",
headers:{ headers:{
"Content-Type":"application/json" "Content-Type":"application/json"
}, },