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