implement listContainers and listContainersDetailed
This commit is contained in:
parent
24c32a3008
commit
880655b4e2
8
dist/dockersock.class.dockersock.d.ts
vendored
8
dist/dockersock.class.dockersock.d.ts
vendored
@ -1,6 +1,12 @@
|
||||
import "typings-global";
|
||||
export declare class dockersock {
|
||||
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;
|
||||
}
|
||||
|
53
dist/dockersock.class.dockersock.js
vendored
53
dist/dockersock.class.dockersock.js
vendored
File diff suppressed because one or more lines are too long
@ -3,16 +3,62 @@ import * as plugins from "./dockersock.plugins";
|
||||
|
||||
export class dockersock {
|
||||
sockPath:string;
|
||||
constructor(pathArg:string){
|
||||
constructor(pathArg:string = "http://unix:/var/run/docker.sock:"){
|
||||
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 = {}){
|
||||
let done = plugins.q.defer();
|
||||
let jsonArg:string = JSON.stringify(dataArg);
|
||||
let options = {
|
||||
method:methodArg,
|
||||
url:"http://unix:/var/run/docker.sock:" + routeArg + "/json",
|
||||
url:this.sockPath + routeArg + "/json",
|
||||
headers:{
|
||||
"Content-Type":"application/json"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user