prepare container creation

This commit is contained in:
Philipp Kunz 2016-06-16 06:43:34 +02:00
parent 16ffe53f30
commit 5cbcba2f1e
3 changed files with 51 additions and 16 deletions

View File

@ -8,10 +8,14 @@ export declare class Dockersock {
listContainersRunning(): any;
listContainersStopped(): any;
listImages(): any;
listImagesDangling(): any;
pullImage(imageLabel: string): void;
createContainer(): any;
getContainerId(): void;
startContainer(containerNameArg: any): any;
stopContainer(): any;
stopContainer(containerNameArg: any): any;
removeContainer(containerNameArg: any): any;
clean(): any;
getChange(): void;
request(methodArg: string, routeArg: string, dataArg?: {}): any;
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any;
}

File diff suppressed because one or more lines are too long

View File

@ -51,18 +51,31 @@ export class Dockersock {
return done.promise;
}
listImages() {
let done = plugins.q.defer();
return done.promise;
return this.request("GET","/images","?all=true");
}
listImagesDangling(){
return this.request("GET","/images","?dangling=true");
}
pullImage(imageLabel:string){
};
createContainer(){
return this.request("POST","/containers/create","",{
"image":""
});
};
getContainerId(){
}
};
startContainer(containerNameArg){
return this.request("POST","/containers/"+ containerNameArg +"/start");
};
stopContainer(){
stopContainer(containerNameArg){
return this.request("POST","/containers/"+ containerNameArg +"/stop");
}
};
removeContainer(containerNameArg){
return this.request("DELETE","/containers/" + containerNameArg + "?v=1");
};
clean() {
let done = plugins.q.defer();
return done.promise;
@ -70,14 +83,14 @@ export class Dockersock {
getChange(){
};
request(methodArg:string,routeArg:string,dataArg = {}){
request(methodArg:string,routeArg:string,queryArg:string = "", dataArg = {}){
let done = plugins.q.defer();
let jsonArg:string = JSON.stringify(dataArg);
let suffix:string = ""
let suffix:string = "";
if(methodArg == "GET") suffix = "/json";
let options = {
method:methodArg,
url:this.sockPath + routeArg + suffix,
url:this.sockPath + routeArg + suffix + queryArg,
headers:{
"Content-Type":"application/json"
},