Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
91d7f583e2 | |||
a77ed42e9f | |||
499c6cc3b7 | |||
19283fb695 | |||
b2d84b1399 | |||
7cc2374130 | |||
526bb5bbd0 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
docs/
|
.yarn/
|
||||||
coverage/
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
@ -1,38 +1,31 @@
|
|||||||
image: hosttoday/ht-docker-dbase:npmts
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .yarn/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- trigger
|
||||||
|
- pages
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- npmci prepare docker-gitlab
|
- npmci prepare docker-gitlab
|
||||||
|
|
||||||
|
|
||||||
build:
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- npm install
|
|
||||||
- npm test
|
|
||||||
- npmci build docker
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- priv
|
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test docker
|
- npmci test stable
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
image: hosttoday/ht-docker-node:npmts
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish npm
|
- npmci publish npm
|
||||||
@ -43,7 +36,7 @@ release:
|
|||||||
- priv
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
image: hosttoday/ht-docker-node:npmts
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: trigger
|
stage: trigger
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
@ -51,4 +44,19 @@ trigger:
|
|||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
stage: pages
|
||||||
|
script:
|
||||||
|
- npmci command yarn global add npmpage
|
||||||
|
- npmci command npmpage --publish gitlab
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
29
README.md
29
README.md
@ -1,11 +1,25 @@
|
|||||||
# dockersock
|
# dockersock
|
||||||
easy communication with docker remote api from node, TypeScript ready
|
easy communication with docker remote api from node, TypeScript ready
|
||||||
|
|
||||||
## Status
|
## Availabililty
|
||||||
[](https://gitlab.com/pushrocks/dockersock/commits/master)
|
[](https://www.npmjs.com/package/dockersock)
|
||||||
|
[](https://GitLab.com/mojoio/dockersock)
|
||||||
|
[](https://github.com/mojoio/dockersock)
|
||||||
|
[](https://mojoio.gitlab.io/dockersock/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
||||||
|
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/dockersock)
|
||||||
|
[](https://david-dm.org/mojoio/dockersock)
|
||||||
|
[](https://www.bithound.io/github/mojoio/dockersock/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/mojoio/dockersock)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
We recommend the use of TypeScript for best Intellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```TypeScript
|
```TypeScript
|
||||||
import {Dockersock} from "dockersock"; // require Dockersock class
|
import {Dockersock} from "dockersock"; // require Dockersock class
|
||||||
@ -25,4 +39,11 @@ myDockersock.newContainer({ // start new Container, equals "docker run" shell co
|
|||||||
image: "someimagetag"
|
image: "someimagetag"
|
||||||
})
|
})
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://mojo.io)
|
||||||
|
7
dist/dockersock.classes.dockersock.d.ts
vendored
7
dist/dockersock.classes.dockersock.d.ts
vendored
@ -1,10 +1,12 @@
|
|||||||
|
/// <reference types="request" />
|
||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import "typings-global";
|
import "typings-global";
|
||||||
import * as plugins from "./dockersock.plugins";
|
import * as plugins from "./dockersock.plugins";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
import { Objectmap } from 'lik';
|
||||||
export declare class Dockersock {
|
export declare class Dockersock {
|
||||||
sockPath: string;
|
sockPath: string;
|
||||||
requestObjectmap: plugins.lik.Objectmap;
|
requestObjectmap: Objectmap<plugins.request.Request>;
|
||||||
constructor(pathArg?: string);
|
constructor(pathArg?: string);
|
||||||
auth(userArg: string, passArg: string): plugins.q.Promise<{}>;
|
auth(userArg: string, passArg: string): plugins.q.Promise<{}>;
|
||||||
listContainers(): plugins.q.Promise<{}>;
|
listContainers(): plugins.q.Promise<{}>;
|
||||||
@ -21,6 +23,9 @@ export declare class Dockersock {
|
|||||||
removeContainer(containerNameArg: any): plugins.q.Promise<{}>;
|
removeContainer(containerNameArg: any): plugins.q.Promise<{}>;
|
||||||
clean(): plugins.q.Promise<{}>;
|
clean(): plugins.q.Promise<{}>;
|
||||||
callOnChange(cb: Function): void;
|
callOnChange(cb: Function): void;
|
||||||
|
/**
|
||||||
|
* gets you an observable that reports changes in the docker infrastructure
|
||||||
|
*/
|
||||||
getChangeObservable(): Observable<{}>;
|
getChangeObservable(): Observable<{}>;
|
||||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||||
requestStream(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
requestStream(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||||
|
18
dist/dockersock.classes.dockersock.js
vendored
18
dist/dockersock.classes.dockersock.js
vendored
File diff suppressed because one or more lines are too long
3
dist/dockersock.plugins.js
vendored
3
dist/dockersock.plugins.js
vendored
@ -1,8 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.lik = require("lik");
|
exports.lik = require("lik");
|
||||||
exports.q = require("q");
|
exports.q = require("q");
|
||||||
exports.request = require("request");
|
exports.request = require("request");
|
||||||
exports.rxjs = require("rxjs");
|
exports.rxjs = require("rxjs");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9ja2Vyc29jay5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZG9ja2Vyc29jay5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFdBQUcsV0FBVyxLQUFLLENBQUMsQ0FBQztBQUNyQixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQyJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9ja2Vyc29jay5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvZG9ja2Vyc29jay5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsMEJBQXdCO0FBQ3hCLHlDQUErQztBQUMvQyw2QkFBbUM7QUFDbkMseUJBQStCO0FBQy9CLHFDQUEyQztBQUMzQywrQkFBcUMifQ==
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
var dockersock_classes_dockersock_1 = require("./dockersock.classes.dockersock");
|
var dockersock_classes_dockersock_1 = require("./dockersock.classes.dockersock");
|
||||||
exports.Dockersock = dockersock_classes_dockersock_1.Dockersock;
|
exports.Dockersock = dockersock_classes_dockersock_1.Dockersock;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLDhDQUEyQixpQ0FBaUMsQ0FBQztBQUFwRCxnRUFBb0QifQ==
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF3QjtBQUN4QixpRkFBNkQ7QUFBcEQscURBQUEsVUFBVSxDQUFBIn0=
|
49
docs/README.md
Normal file
49
docs/README.md
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# dockersock
|
||||||
|
easy communication with docker remote api from node, TypeScript ready
|
||||||
|
|
||||||
|
## Availabililty
|
||||||
|
[](https://www.npmjs.com/package/dockersock)
|
||||||
|
[](https://GitLab.com/mojoio/dockersock)
|
||||||
|
[](https://github.com/mojoio/dockersock)
|
||||||
|
[](https://mojoio.gitlab.io/dockersock/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
||||||
|
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/dockersock)
|
||||||
|
[](https://david-dm.org/mojoio/dockersock)
|
||||||
|
[](https://www.bithound.io/github/mojoio/dockersock/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/mojoio/dockersock)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
```TypeScript
|
||||||
|
import {Dockersock} from "dockersock"; // require Dockersock class
|
||||||
|
|
||||||
|
let myDockersock = new Dockersock(); // optional: you can pass a domain to the contructor, defaults to /var/run/docker.sock
|
||||||
|
|
||||||
|
myDockersock.listContainers() // promise, resolve gets container data
|
||||||
|
myDockersock.listContainersDetailed() // promise, resolve gets more detailed container data (by combining several requests internally)
|
||||||
|
myDockersock.listContainersRunning() // promise, resolve gets container data for currently running containers
|
||||||
|
myDockersock.listContainersStopped() // promise, resolve gets container data for stopped containers
|
||||||
|
|
||||||
|
myDockersock.startContainer({ // starts a already present container
|
||||||
|
name: "somecontainername"
|
||||||
|
})
|
||||||
|
|
||||||
|
myDockersock.newContainer({ // start new Container, equals "docker run" shell command
|
||||||
|
image: "someimagetag"
|
||||||
|
})
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://mojo.io)
|
@ -4,8 +4,14 @@
|
|||||||
"coverageTreshold":10
|
"coverageTreshold":10
|
||||||
},
|
},
|
||||||
"npmdocker":{
|
"npmdocker":{
|
||||||
"baseImage":"hosttoday/ht-docker-node:npmts",
|
"baseImage":"hosttoday/ht-docker-node:npmci",
|
||||||
"command":"npmts",
|
"command":"(npmci command yarn global add npmts) && npmts",
|
||||||
"dockerSock":"true"
|
"dockerSock":"true"
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [
|
||||||
|
"npmts",
|
||||||
|
"npmdocker"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
21
package.json
21
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dockersock",
|
"name": "dockersock",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"description": "easy communication with docker remote api from node, TypeScript ready",
|
"description": "easy communication with docker remote api from node, TypeScript ready",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@ -25,18 +25,17 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "0.x.x",
|
"@types/q": "1.x.x",
|
||||||
"@types/request": "0.x.x",
|
"@types/request": "0.x.x",
|
||||||
"beautylog": "^5.0.20",
|
"beautylog": "^6.1.5",
|
||||||
"lik": "^1.0.9",
|
"lik": "^1.0.27",
|
||||||
"q": "^1.4.1",
|
"q": "^1.5.0",
|
||||||
"request": "^2.74.0",
|
"request": "^2.81.0",
|
||||||
"rxjs": "^5.0.0-beta.10",
|
"rxjs": "^5.2.0",
|
||||||
"typings-global": "^1.0.6"
|
"typings-global": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.8",
|
"observable-to-promise": "^0.5.0",
|
||||||
"should": "^10.0.0",
|
"tapbundle": "^1.0.5"
|
||||||
"typings-test": "^1.0.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/test.d.ts
vendored
2
test/test.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
import "typings-test";
|
|
||||||
import "should";
|
|
42
test/test.js
42
test/test.js
@ -1,42 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
require("should");
|
|
||||||
const index_1 = require("../dist/index");
|
|
||||||
describe("dockersock", function () {
|
|
||||||
describe(".Dockersock()", function () {
|
|
||||||
let testDockersock;
|
|
||||||
it("should create a new Dockersock instance", function () {
|
|
||||||
testDockersock = new index_1.Dockersock();
|
|
||||||
testDockersock.should.be.instanceof(index_1.Dockersock);
|
|
||||||
});
|
|
||||||
it("should list containers", function (done) {
|
|
||||||
testDockersock.listContainers()
|
|
||||||
.then((dataArg) => {
|
|
||||||
console.log(dataArg);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should list detailed containers", function (done) {
|
|
||||||
this.timeout(5000);
|
|
||||||
testDockersock.listContainersDetailed()
|
|
||||||
.then((dataArg) => {
|
|
||||||
console.log(dataArg);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should pull an image from imagetag", function (done) {
|
|
||||||
this.timeout(60000);
|
|
||||||
testDockersock.pullImage("hosttoday/ht-docker-dbase")
|
|
||||||
.then((dataArg) => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should return a change Objservable", function (done) {
|
|
||||||
this.timeout(10000);
|
|
||||||
testDockersock.getChangeObservable();
|
|
||||||
testDockersock.endRequests();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQix3QkFBMkIsZUFBZSxDQUFDLENBQUE7QUFFM0MsUUFBUSxDQUFDLFlBQVksRUFBRTtJQUNuQixRQUFRLENBQUMsZUFBZSxFQUFFO1FBQ3RCLElBQUksY0FBMEIsQ0FBQztRQUMvQixFQUFFLENBQUMseUNBQXlDLEVBQUU7WUFDMUMsY0FBYyxHQUFHLElBQUksa0JBQVUsRUFBRSxDQUFDO1lBQ2xDLGNBQWMsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxrQkFBVSxDQUFDLENBQUM7UUFDcEQsQ0FBQyxDQUFDLENBQUM7UUFDSCxFQUFFLENBQUMsd0JBQXdCLEVBQUUsVUFBVSxJQUFJO1lBQ3ZDLGNBQWMsQ0FBQyxjQUFjLEVBQUU7aUJBQzFCLElBQUksQ0FBQyxDQUFDLE9BQU87Z0JBQ1YsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDckIsSUFBSSxFQUFFLENBQUM7WUFDWCxDQUFDLENBQUMsQ0FBQztRQUNYLENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLGlDQUFpQyxFQUFFLFVBQVUsSUFBSTtZQUNoRCxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQ25CLGNBQWMsQ0FBQyxzQkFBc0IsRUFBRTtpQkFDbEMsSUFBSSxDQUFDLENBQUMsT0FBTztnQkFDVixPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxDQUFDO2dCQUNyQixJQUFJLEVBQUUsQ0FBQztZQUNYLENBQUMsQ0FBQyxDQUFDO1FBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDSCxFQUFFLENBQUMsb0NBQW9DLEVBQUUsVUFBVSxJQUFJO1lBQ25ELElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUM7WUFDcEIsY0FBYyxDQUFDLFNBQVMsQ0FBQywyQkFBMkIsQ0FBQztpQkFDaEQsSUFBSSxDQUFDLENBQUMsT0FBTztnQkFDVixJQUFJLEVBQUUsQ0FBQztZQUNYLENBQUMsQ0FBQyxDQUFDO1FBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDSCxFQUFFLENBQUMsb0NBQW9DLEVBQUUsVUFBVSxJQUFJO1lBQ25ELElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUM7WUFDcEIsY0FBYyxDQUFDLG1CQUFtQixFQUFFLENBQUM7WUFDckMsY0FBYyxDQUFDLFdBQVcsRUFBRSxDQUFDO1lBQzdCLElBQUksRUFBRSxDQUFDO1FBQ1gsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQyxDQUFDIn0=
|
|
70
test/test.ts
70
test/test.ts
@ -1,42 +1,36 @@
|
|||||||
import "typings-test";
|
import "typings-global";
|
||||||
import "should";
|
import { expect, tap } from 'tapbundle'
|
||||||
|
import * as observableToPromise from 'observable-to-promise'
|
||||||
import { Dockersock } from "../dist/index";
|
import { Dockersock } from "../dist/index";
|
||||||
|
|
||||||
describe("dockersock", function () {
|
let testDockersock: Dockersock;
|
||||||
describe(".Dockersock()", function () {
|
|
||||||
let testDockersock: Dockersock;
|
tap.test("should create a new Dockersock instance", async () => {
|
||||||
it("should create a new Dockersock instance", function () {
|
testDockersock = new Dockersock();
|
||||||
testDockersock = new Dockersock();
|
return expect(testDockersock).to.be.instanceof(Dockersock);
|
||||||
testDockersock.should.be.instanceof(Dockersock);
|
}).catch(tap.threw);
|
||||||
|
|
||||||
|
tap.test("should list containers", async () => {
|
||||||
|
await testDockersock.listContainers()
|
||||||
|
.then(async (dataArg) => {
|
||||||
|
console.log(dataArg);
|
||||||
});
|
});
|
||||||
it("should list containers", function (done) {
|
}).catch(tap.threw);
|
||||||
testDockersock.listContainers()
|
|
||||||
.then((dataArg) => {
|
tap.test("should list detailed containers", async () => {
|
||||||
console.log(dataArg);
|
await testDockersock.listContainersDetailed()
|
||||||
done();
|
.then(async (dataArg) => {
|
||||||
});
|
console.log(dataArg);
|
||||||
});
|
});
|
||||||
it("should list detailed containers", function (done) {
|
}).catch(tap.threw);
|
||||||
this.timeout(5000);
|
|
||||||
testDockersock.listContainersDetailed()
|
tap.test("should pull an image from imagetag", async () => {
|
||||||
.then((dataArg) => {
|
await testDockersock.pullImage("hosttoday/ht-docker-node:npmci")
|
||||||
console.log(dataArg);
|
}).catch(tap.threw);
|
||||||
done();
|
|
||||||
});
|
/*tap.test("should return a change Objservable", async () => {
|
||||||
});
|
let myObservable = testDockersock.getChangeObservable();
|
||||||
it("should pull an image from imagetag", function (done) {
|
testDockersock.endRequests();
|
||||||
this.timeout(60000);
|
let testPromise = observableToPromise(myObservable)
|
||||||
testDockersock.pullImage("hosttoday/ht-docker-dbase")
|
return await expect(testPromise).to.eventually.be.fulfilled
|
||||||
.then((dataArg) => {
|
}).catch(tap.threw);*/
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should return a change Objservable", function (done) {
|
|
||||||
this.timeout(10000);
|
|
||||||
testDockersock.getChangeObservable();
|
|
||||||
testDockersock.endRequests();
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
@ -2,9 +2,12 @@ import "typings-global"
|
|||||||
import * as plugins from "./dockersock.plugins";
|
import * as plugins from "./dockersock.plugins";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
|
// interfaces
|
||||||
|
import { Objectmap } from 'lik'
|
||||||
|
|
||||||
export class Dockersock {
|
export class Dockersock {
|
||||||
sockPath: string;
|
sockPath: string;
|
||||||
requestObjectmap: plugins.lik.Objectmap = new plugins.lik.Objectmap();
|
requestObjectmap = new plugins.lik.Objectmap<plugins.request.Request>();
|
||||||
constructor(pathArg: string = "http://unix:/var/run/docker.sock:") {
|
constructor(pathArg: string = "http://unix:/var/run/docker.sock:") {
|
||||||
this.sockPath = pathArg;
|
this.sockPath = pathArg;
|
||||||
}
|
}
|
||||||
@ -121,6 +124,10 @@ export class Dockersock {
|
|||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets you an observable that reports changes in the docker infrastructure
|
||||||
|
*/
|
||||||
getChangeObservable() {
|
getChangeObservable() {
|
||||||
let options = {
|
let options = {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@ -137,8 +144,10 @@ export class Dockersock {
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
let incomingMessage
|
||||||
requestStream.on("response", (response) => {
|
requestStream.on("response", (response) => {
|
||||||
this.requestObjectmap.add(response);
|
incomingMessage = response
|
||||||
|
this.requestObjectmap.add(incomingMessage);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
plugins.beautylog.ok("request returned status 200, so we are good!");
|
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||||
} else {
|
} else {
|
||||||
@ -147,7 +156,7 @@ export class Dockersock {
|
|||||||
});
|
});
|
||||||
let changeObservable = Observable.fromEvent(requestStream, "data");
|
let changeObservable = Observable.fromEvent(requestStream, "data");
|
||||||
requestStream.on("end", () => {
|
requestStream.on("end", () => {
|
||||||
this.requestObjectmap.remove(requestStream);
|
this.requestObjectmap.remove(incomingMessage);
|
||||||
});
|
});
|
||||||
return changeObservable;
|
return changeObservable;
|
||||||
}
|
}
|
||||||
@ -200,8 +209,10 @@ export class Dockersock {
|
|||||||
done.reject(err);
|
done.reject(err);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
let incomingMessage
|
||||||
requestStream.on("response", (response) => {
|
requestStream.on("response", (response) => {
|
||||||
this.requestObjectmap.add(response);
|
incomingMessage = response
|
||||||
|
this.requestObjectmap.add(incomingMessage);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
plugins.beautylog.ok("request returned status 200, so we are good!");
|
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||||
} else {
|
} else {
|
||||||
@ -215,10 +226,12 @@ export class Dockersock {
|
|||||||
plugins.beautylog.logReduced(status);
|
plugins.beautylog.logReduced(status);
|
||||||
});
|
});
|
||||||
requestStream.on("end", () => {
|
requestStream.on("end", () => {
|
||||||
this.requestObjectmap.remove(requestStream);
|
this.requestObjectmap.remove(incomingMessage);
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
endRequests() {
|
endRequests() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.requestObjectmap.forEach((itemArg: plugins.request.Request) => {
|
this.requestObjectmap.forEach((itemArg: plugins.request.Request) => {
|
||||||
|
Reference in New Issue
Block a user