Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
b4c6bff74d | |||
4da7f5194a | |||
c356042075 |
4
dist/dockersock.classes.dockersock.d.ts
vendored
4
dist/dockersock.classes.dockersock.d.ts
vendored
@ -10,13 +10,13 @@ export declare class Dockersock {
|
|||||||
listImages(): any;
|
listImages(): any;
|
||||||
listImagesDangling(): any;
|
listImagesDangling(): any;
|
||||||
pullImage(imageLabel: string): any;
|
pullImage(imageLabel: string): any;
|
||||||
createContainer(imageNameArg: any, pullFirst?: boolean): any;
|
createContainer(optionsArg: any, pullFirstArg?: boolean): any;
|
||||||
getContainerId(): void;
|
getContainerId(): void;
|
||||||
startContainer(containerNameArg: any): any;
|
startContainer(containerNameArg: any): any;
|
||||||
stopContainer(containerNameArg: any): any;
|
stopContainer(containerNameArg: any): any;
|
||||||
removeContainer(containerNameArg: any): any;
|
removeContainer(containerNameArg: any): any;
|
||||||
clean(): any;
|
clean(): any;
|
||||||
getChange(): void;
|
callOnChange(cb: Function): void;
|
||||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any;
|
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any;
|
||||||
requestStream(methodArg: any, routeArg: any, endArg?: boolean): any;
|
requestStream(methodArg: any, routeArg: any, endArg?: boolean): any;
|
||||||
}
|
}
|
||||||
|
53
dist/dockersock.classes.dockersock.js
vendored
53
dist/dockersock.classes.dockersock.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dockersock",
|
"name": "dockersock",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"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": {
|
||||||
|
@ -59,10 +59,20 @@ export class Dockersock {
|
|||||||
pullImage(imageLabel:string){
|
pullImage(imageLabel:string){
|
||||||
return this.requestStream("POST","/images/create?fromImage=" + imageLabel);
|
return this.requestStream("POST","/images/create?fromImage=" + imageLabel);
|
||||||
};
|
};
|
||||||
createContainer(imageNameArg,pullFirst:boolean = true){
|
createContainer(optionsArg,pullFirstArg:boolean = true){
|
||||||
return this.request("POST","/containers/create","",{
|
let done = plugins.q.defer();
|
||||||
"image":imageNameArg
|
let create = () => {
|
||||||
});
|
return this.request("POST","/containers/create","",optionsArg);
|
||||||
|
}
|
||||||
|
if(pullFirstArg){
|
||||||
|
this.pullImage(optionsArg.Image)
|
||||||
|
.then(create)
|
||||||
|
.then(done.resolve);
|
||||||
|
} else {
|
||||||
|
create()
|
||||||
|
.then(done.resolve)
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
};
|
};
|
||||||
getContainerId(){
|
getContainerId(){
|
||||||
|
|
||||||
@ -80,8 +90,33 @@ export class Dockersock {
|
|||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
getChange(){
|
callOnChange(cb:Function){
|
||||||
|
let cbPromise;
|
||||||
|
let changeBuffered:boolean = false; // when cb is running then buffer any consequent change
|
||||||
|
let requestStream = plugins.request.get(this.sockPath + "/events");
|
||||||
|
requestStream.on("response",(response) => {
|
||||||
|
if(response.statusCode == 200){
|
||||||
|
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.error("request returned error: " + response.statusCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
requestStream.on("data",(data:Buffer) => {
|
||||||
|
let status = JSON.parse(data.toString()).status;
|
||||||
|
plugins.beautylog.logReduced(status);
|
||||||
|
if(typeof cbPromise == "undefined" || cbPromise.state == "pending"){
|
||||||
|
cbPromise = cb();
|
||||||
|
} else if (changeBuffered) {
|
||||||
|
changeBuffered = true;
|
||||||
|
cbPromise.then(() => {
|
||||||
|
changeBuffered = false;
|
||||||
|
cbPromise = cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
requestStream.on("end",()=> {
|
||||||
|
|
||||||
|
});
|
||||||
};
|
};
|
||||||
request(methodArg:string,routeArg:string,queryArg:string = "", dataArg = {}){
|
request(methodArg:string,routeArg:string,queryArg:string = "", dataArg = {}){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
Reference in New Issue
Block a user