now working with npmdocker and the npmts 7.x.x

This commit is contained in:
Philipp Kunz 2017-04-02 15:30:43 +02:00
parent 499c6cc3b7
commit a77ed42e9f
7 changed files with 60 additions and 20 deletions

View File

@ -23,6 +23,9 @@ export declare class Dockersock {
removeContainer(containerNameArg: any): plugins.q.Promise<{}>;
clean(): plugins.q.Promise<{}>;
callOnChange(cb: Function): void;
/**
* gets you an observable that reports changes in the docker infrastructure
*/
getChangeObservable(): Observable<{}>;
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
requestStream(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
},
"npmdocker":{
"baseImage":"hosttoday/ht-docker-node:npmci",
"command":"npmci command yarn global add npmts && npmci command npmts",
"command":"(npmci command yarn global add npmts) && npmts",
"dockerSock":"true"
},
"npmci": {

View File

@ -35,6 +35,7 @@
"typings-global": "^1.0.14"
},
"devDependencies": {
"observable-to-promise": "^0.5.0",
"tapbundle": "^1.0.5"
}
}

View File

@ -1,6 +1,6 @@
import "typings-global";
import { expect, tap } from 'tapbundle'
import * as observableToPromise from 'observable-to-promise'
import { Dockersock } from "../dist/index";
let testDockersock: Dockersock;
@ -8,27 +8,29 @@ let testDockersock: Dockersock;
tap.test("should create a new Dockersock instance", async () => {
testDockersock = new Dockersock();
return expect(testDockersock).to.be.instanceof(Dockersock);
});
}).catch(tap.threw);
tap.test("should list containers", async () => {
await testDockersock.listContainers()
.then(async (dataArg) => {
console.log(dataArg);
});
});
}).catch(tap.threw);
tap.test("should list detailed containers", async () => {
await testDockersock.listContainersDetailed()
.then(async (dataArg) => {
console.log(dataArg);
});
});
}).catch(tap.threw);
tap.test("should pull an image from imagetag", async () => {
await testDockersock.pullImage("hosttoday/ht-docker-dbase")
});
await testDockersock.pullImage("hosttoday/ht-docker-node:npmci")
}).catch(tap.threw);
tap.test("should return a change Objservable", async () => {
testDockersock.getChangeObservable();
/*tap.test("should return a change Objservable", async () => {
let myObservable = testDockersock.getChangeObservable();
testDockersock.endRequests();
})
let testPromise = observableToPromise(myObservable)
return await expect(testPromise).to.eventually.be.fulfilled
}).catch(tap.threw);*/

View File

@ -124,6 +124,10 @@ export class Dockersock {
});
};
/**
* gets you an observable that reports changes in the docker infrastructure
*/
getChangeObservable() {
let options = {
method: "GET",
@ -140,8 +144,10 @@ export class Dockersock {
console.log(res);
};
});
let incomingMessage
requestStream.on("response", (response) => {
this.requestObjectmap.add(requestStream);
incomingMessage = response
this.requestObjectmap.add(incomingMessage);
if (response.statusCode == 200) {
plugins.beautylog.ok("request returned status 200, so we are good!");
} else {
@ -150,7 +156,7 @@ export class Dockersock {
});
let changeObservable = Observable.fromEvent(requestStream, "data");
requestStream.on("end", () => {
this.requestObjectmap.remove(requestStream);
this.requestObjectmap.remove(incomingMessage);
});
return changeObservable;
}
@ -203,8 +209,10 @@ export class Dockersock {
done.reject(err);
};
});
let incomingMessage
requestStream.on("response", (response) => {
this.requestObjectmap.add(requestStream);
incomingMessage = response
this.requestObjectmap.add(incomingMessage);
if (response.statusCode == 200) {
plugins.beautylog.ok("request returned status 200, so we are good!");
} else {
@ -218,10 +226,12 @@ export class Dockersock {
plugins.beautylog.logReduced(status);
});
requestStream.on("end", () => {
this.requestObjectmap.remove(requestStream);
this.requestObjectmap.remove(incomingMessage);
});
return done.promise;
};
endRequests() {
setTimeout(() => {
this.requestObjectmap.forEach((itemArg: plugins.request.Request) => {

View File

@ -848,6 +848,12 @@ is-number@^2.0.2, is-number@^2.1.0:
dependencies:
kind-of "^3.0.2"
is-observable@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/is-observable/-/is-observable-0.2.0.tgz#b361311d83c6e5d726cabf5e250b0237106f5ae2"
dependencies:
symbol-observable "^0.2.2"
is-posix-bracket@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
@ -1211,6 +1217,13 @@ object.omit@^2.0.0:
for-own "^0.1.4"
is-extendable "^0.1.1"
observable-to-promise@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/observable-to-promise/-/observable-to-promise-0.5.0.tgz#c828f0f0dc47e9f86af8a4977c5d55076ce7a91f"
dependencies:
is-observable "^0.2.0"
symbol-observable "^1.0.4"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
@ -1692,7 +1705,11 @@ supports-color@^3.1.2:
dependencies:
has-flag "^1.0.0"
symbol-observable@^1.0.1:
symbol-observable@^0.2.2:
version "0.2.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-0.2.4.tgz#95a83db26186d6af7e7a18dbd9760a2f86d08f40"
symbol-observable@^1.0.1, symbol-observable@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"