added rxjs, added getChangeObservable
This commit is contained in:
parent
4a90510ff4
commit
de05d432b1
34
dist/dockersock.classes.dockersock.d.ts
vendored
34
dist/dockersock.classes.dockersock.d.ts
vendored
@ -1,22 +1,26 @@
|
||||
/// <reference types="q" />
|
||||
import "typings-global";
|
||||
import * as plugins from "./dockersock.plugins";
|
||||
import { Observable } from "rxjs";
|
||||
export declare class Dockersock {
|
||||
sockPath: string;
|
||||
constructor(pathArg?: string);
|
||||
auth(userArg: string, passArg: string): any;
|
||||
listContainers(): any;
|
||||
listContainersDetailed(): any;
|
||||
listContainersRunning(): any;
|
||||
listContainersStopped(): any;
|
||||
listImages(): any;
|
||||
listImagesDangling(): any;
|
||||
pullImage(imageLabel: string): any;
|
||||
createContainer(optionsArg: any, pullFirstArg?: boolean): any;
|
||||
auth(userArg: string, passArg: string): plugins.q.Promise<{}>;
|
||||
listContainers(): plugins.q.Promise<{}>;
|
||||
listContainersDetailed(): plugins.q.Promise<{}>;
|
||||
listContainersRunning(): plugins.q.Promise<{}>;
|
||||
listContainersStopped(): plugins.q.Promise<{}>;
|
||||
listImages(): plugins.q.Promise<{}>;
|
||||
listImagesDangling(): plugins.q.Promise<{}>;
|
||||
pullImage(imageLabel: string): plugins.q.Promise<{}>;
|
||||
createContainer(optionsArg: any, pullFirstArg?: boolean): plugins.q.Promise<{}>;
|
||||
getContainerId(): void;
|
||||
startContainer(containerNameArg: any): any;
|
||||
stopContainer(containerNameArg: any): any;
|
||||
removeContainer(containerNameArg: any): any;
|
||||
clean(): any;
|
||||
startContainer(containerNameArg: any): plugins.q.Promise<{}>;
|
||||
stopContainer(containerNameArg: any): plugins.q.Promise<{}>;
|
||||
removeContainer(containerNameArg: any): plugins.q.Promise<{}>;
|
||||
clean(): plugins.q.Promise<{}>;
|
||||
callOnChange(cb: Function): void;
|
||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any;
|
||||
requestStream(methodArg: any, routeArg: any, endArg?: boolean): any;
|
||||
getChangeObservable(): Observable<{}>;
|
||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||
requestStream(methodArg: any, routeArg: any, endArg?: boolean): plugins.q.Promise<{}>;
|
||||
}
|
||||
|
23
dist/dockersock.classes.dockersock.js
vendored
23
dist/dockersock.classes.dockersock.js
vendored
File diff suppressed because one or more lines are too long
3
dist/dockersock.plugins.d.ts
vendored
3
dist/dockersock.plugins.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export declare let q: any;
|
||||
export import q = require("q");
|
||||
export declare let request: any;
|
||||
export import rxjs = require("rxjs");
|
||||
|
4
dist/dockersock.plugins.js
vendored
4
dist/dockersock.plugins.js
vendored
@ -3,5 +3,5 @@ require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.q = require("q");
|
||||
exports.request = require("request");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRvY2tlcnNvY2sucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNwQyxTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUMiLCJmaWxlIjoiZG9ja2Vyc29jay5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgcSA9IHJlcXVpcmUoXCJxXCIpO1xuZXhwb3J0IGxldCByZXF1ZXN0ID0gcmVxdWlyZShcInJlcXVlc3RcIik7Il19
|
||||
exports.rxjs = require("rxjs");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9ja2Vyc29jay5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZG9ja2Vyc29jay5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNwQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQyJ9
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -2,5 +2,4 @@
|
||||
require("typings-global");
|
||||
var dockersock_classes_dockersock_1 = require("./dockersock.classes.dockersock");
|
||||
exports.Dockersock = dockersock_classes_dockersock_1.Dockersock;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsOENBQXlCLGlDQUFpQyxDQUFDO0FBQW5ELGdFQUFrRCIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XG5leHBvcnQge0RvY2tlcnNvY2t9IGZyb20gXCIuL2RvY2tlcnNvY2suY2xhc3Nlcy5kb2NrZXJzb2NrXCIiXX0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLDhDQUF5QixpQ0FBaUMsQ0FBQztBQUFuRCxnRUFBa0QifQ==
|
@ -28,9 +28,13 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
||||
"dependencies": {
|
||||
"@types/es6-promise": "0.0.27-alpha",
|
||||
"@types/q": "0.0.26-alpha",
|
||||
"beautylog": "^5.0.12",
|
||||
"es6-promise": "^3.2.1",
|
||||
"q": "^1.4.1",
|
||||
"request": "^2.72.0",
|
||||
"rxjs": "^5.0.0-beta.10",
|
||||
"typings-global": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -25,7 +25,7 @@ describe("dockersock", function () {
|
||||
});
|
||||
});
|
||||
it("should pull an image from imagetag", function (done) {
|
||||
this.timeout(30000);
|
||||
this.timeout(60000);
|
||||
testDockersock.pullImage("hosttoday%2Fht-docker-dbase")
|
||||
.then(function (dataArg) {
|
||||
done();
|
||||
@ -33,5 +33,4 @@ describe("dockersock", function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUVQLENBQUMsQ0FGYztBQUVmLHNCQUF5QixlQUV6QixDQUFDLENBRnVDO0FBRXhDLFFBQVEsQ0FBQyxZQUFZLEVBQUM7SUFDbEIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLGNBQXlCLENBQUM7UUFDOUIsRUFBRSxDQUFDLHlDQUF5QyxFQUFDO1lBQ3pDLGNBQWMsR0FBRyxJQUFJLGtCQUFVLE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ICAgICAgICAgICAudGhlbigoZGF0YUFyZyk9PntcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coZGF0YUFyZyk7XG4gICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgICAgIGl0KFwic2hvdWxkIHB1bGwgYW4gaW1hZ2UgZnJvbSBpbWFnZXRhZ1wiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDMwMDAwKTtcbiAgICAgICAgICAgIHRlc3REb2NrZXJzb2NrLnB1bGxJbWFnZShcImhvc3R0b2RheSUyRmh0LWRvY2tlci1kYmFzZVwiKVxuICAgICAgICAgICAgICAgIC50aGVuKChkYXRhQXJnKT0+e1xuICAgICAgICAgICAgICAgICAgICBkb25lKCk7XG4gICAgICAgICAgICAgICAgfSxkb25lKTtcbiAgICAgICAgfSlcbiAgICB9KTtcbn0pOyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixzQkFBeUIsZUFFekIsQ0FBQyxDQUZ1QztBQUV4QyxRQUFRLENBQUMsWUFBWSxFQUFDO0lBQ2xCLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsSUFBSSxjQUF5QixDQUFDO1FBQzlCLEVBQUUsQ0FBQyx5Q0FBeUMsRUFBQztZQUN6QyxjQUFjLEdBQUcsSUFBSSxrQkFBVSxFQUFFLENBQUM7WUFDbEMsY0FBYyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLGtCQUFVLENBQUMsQ0FBQztRQUNwRCxDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyx3QkFBd0IsRUFBQyxVQUFTLElBQUk7WUFDckMsY0FBYyxDQUFDLGNBQWMsRUFBRTtpQkFDMUIsSUFBSSxDQUFDLFVBQUMsT0FBTztnQkFDVixPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDO2dCQUNyQixJQUFJLEVBQUUsQ0FBQztZQUNYLENBQUMsQ0FBQyxDQUFDO1FBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDSCxFQUFFLENBQUMsaUNBQWlDLEVBQUMsVUFBUyxJQUFJO1lBQzlDLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7WUFDbkIsY0FBYyxDQUFDLHNCQUFzQixFQUFFO2lCQUNsQyxJQUFJLENBQUMsVUFBQyxPQUFPO2dCQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUM7Z0JBQ3JCLElBQUksRUFBRSxDQUFDO1lBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDWCxDQUFDLENBQUMsQ0FBQztRQUNILEVBQUUsQ0FBQyxvQ0FBb0MsRUFBQyxVQUFTLElBQUk7WUFDakQsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztZQUNwQixjQUFjLENBQUMsU0FBUyxDQUFDLDZCQUE2QixDQUFDO2lCQUNsRCxJQUFJLENBQUMsVUFBQyxPQUFPO2dCQUNWLElBQUksRUFBRSxDQUFDO1lBQ1gsQ0FBQyxFQUFDLElBQUksQ0FBQyxDQUFDO1FBQ2hCLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9
|
@ -1,5 +1,6 @@
|
||||
import "typings-global"
|
||||
import * as plugins from "./dockersock.plugins";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
export class Dockersock {
|
||||
sockPath:string;
|
||||
@ -118,9 +119,7 @@ export class Dockersock {
|
||||
|
||||
});
|
||||
};
|
||||
getChangeEmitter(){
|
||||
class EventEmitter extends plugins.events.EventEmitter {};
|
||||
let emitterInstance = new EventEmitter();
|
||||
getChangeObservable(){
|
||||
let requestStream = plugins.request.get(this.sockPath + "/events");
|
||||
requestStream.on("response",(response) => {
|
||||
if(response.statusCode == 200){
|
||||
@ -129,15 +128,11 @@ export class Dockersock {
|
||||
plugins.beautylog.error("request returned error: " + response.statusCode);
|
||||
}
|
||||
});
|
||||
requestStream.on("data",(data:Buffer) => {
|
||||
let status = JSON.parse(data.toString()).status;
|
||||
plugins.beautylog.logReduced(status);
|
||||
emitterInstance.emit("change",data);
|
||||
});
|
||||
let changeObservable = Observable.fromEvent(requestStream,"data");
|
||||
requestStream.on("end",()=> {
|
||||
|
||||
});
|
||||
return emitterInstance;
|
||||
return changeObservable;
|
||||
}
|
||||
request(methodArg:string,routeArg:string,queryArg:string = "", dataArg = {}){
|
||||
let done = plugins.q.defer();
|
||||
@ -168,12 +163,12 @@ export class Dockersock {
|
||||
let done = plugins.q.defer();
|
||||
if(methodArg == "POST"){
|
||||
let requestStream = plugins.request.post(this.sockPath + routeArg);
|
||||
requestStream.on("response",(response) => {
|
||||
requestStream.on("response",(response,err) => {
|
||||
if(response.statusCode == 200){
|
||||
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||
} else {
|
||||
plugins.beautylog.error("request returned error: " + response.statusCode);
|
||||
done.reject();
|
||||
done.reject(err);
|
||||
}
|
||||
});
|
||||
requestStream.on("data",(data:Buffer) => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import events = require("events");
|
||||
export let q = require("q");
|
||||
export import q = require("q");
|
||||
export let request = require("request");
|
||||
eventEmitter.
|
||||
export import rxjs = require("rxjs");
|
Loading…
Reference in New Issue
Block a user