Compare commits

...

14 Commits

Author SHA1 Message Date
ee2e4fb856 1.0.33 2019-08-14 20:56:57 +02:00
ff5cecb07e fix(core): update 2019-08-14 20:56:57 +02:00
e50b028c00 1.0.32 2019-08-14 14:19:46 +02:00
867dda8e7c fix(core): update 2019-08-14 14:19:45 +02:00
d12d595f21 1.0.31 2019-01-18 02:42:13 +01:00
6117228ea4 fix(core): update 2019-01-18 02:42:13 +01:00
b6b584f808 1.0.30 2019-01-10 00:43:46 +01:00
48fe6ce0a8 fix(core): update 2019-01-10 00:43:45 +01:00
55acb39071 1.0.29 2019-01-10 00:37:32 +01:00
f7b17a4684 fix(core): update 2019-01-10 00:37:32 +01:00
d95f6c8e7f 1.0.28 2019-01-10 00:31:49 +01:00
001cdadb6b fix(core): update 2019-01-10 00:31:48 +01:00
82655623d1 1.0.27 2019-01-10 00:28:13 +01:00
ea117bc391 fix(core): update 2019-01-10 00:28:12 +01:00
18 changed files with 810 additions and 448 deletions

22
.gitignore vendored
View File

@ -1,4 +1,22 @@
.yarn/
node_modules/
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -1,62 +1,119 @@
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:dind
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
before_script:
- npmci prepare docker-gitlab
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
test:
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- priv
- docker
- notpriv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
image: hosttoday/ht-docker-node:npmci
stage: release
script:
- npmci publish npm
- npmci node install lts
- npmci npm publish
only:
- tags
- tags
tags:
- lossless
- priv
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
trigger:
image: hosttoday/ht-docker-node:npmci
stage: trigger
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- lossless
- priv
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:18-dind
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage --publish gitlab
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

View File

@ -1,25 +1,20 @@
# @mojoio/dockersock
# @mojoio/docker
unofficial docker engine api abstraction package written in TypeScript
easy communication with docker remote api from node, TypeScript ready
## Availabililty
[![npm](https://mojoio.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/dockersock)
[![git](https://mojoio.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/mojoio/dockersock)
[![git](https://mojoio.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/mojoio/dockersock)
[![docs](https://mojoio.gitlab.io/assets/repo-button-docs.svg)](https://mojoio.gitlab.io/dockersock/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/docker)
* [gitlab.com (source)](https://gitlab.com/mojoio/docker)
* [github.com (source mirror)](https://github.com/mojoio/docker)
* [docs (typedoc)](https://mojoio.gitlab.io/docker/)
## Status for master
[![build status](https://GitLab.com/mojoio/dockersock/badges/master/build.svg)](https://GitLab.com/mojoio/dockersock/commits/master)
[![coverage report](https://GitLab.com/mojoio/dockersock/badges/master/coverage.svg)](https://GitLab.com/mojoio/dockersock/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/dockersock.svg)](https://www.npmjs.com/package/dockersock)
[![Dependency Status](https://david-dm.org/mojoio/dockersock.svg)](https://david-dm.org/mojoio/dockersock)
[![bitHound Dependencies](https://www.bithound.io/github/mojoio/dockersock/badges/dependencies.svg)](https://www.bithound.io/github/mojoio/dockersock/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/mojoio/dockersock/badges/code.svg)](https://www.bithound.io/github/mojoio/dockersock)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![build status](https://gitlab.com/mojoio/docker/badges/master/build.svg)](https://gitlab.com/mojoio/docker/commits/master)
[![coverage report](https://gitlab.com/mojoio/docker/badges/master/coverage.svg)](https://gitlab.com/mojoio/docker/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/docker.svg)](https://www.npmjs.com/package/@mojoio/docker)
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/docker/badge.svg)](https://snyk.io/test/npm/@mojoio/docker)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
@ -50,3 +45,10 @@ For further information read the linked docs at the top of this README.
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://mojoio.gitlab.io/assets/repo-footer.svg)](https://mojo.io)
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)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,15 +1,22 @@
{
"npmts": {
"mode": "default",
"coverageTreshold": 10
},
"npmdocker": {
"baseImage": "hosttoday/ht-docker-node:npmci",
"command":
"(ls -a && rm -r node_modules && yarn global add npmts && yarn install && npmts)",
"command": "(ls -a && rm -r node_modules && yarn global add npmts && yarn install && npmts)",
"dockerSock": true
},
"npmci": {
"globalNpmTools": ["npmts", "npmdocker"]
"npmGlobalTools": [],
"npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "mojoio",
"gitrepo": "docker",
"shortDescription": "unofficial docker engine api abstraction package written in TypeScript",
"npmPackagename": "@mojoio/docker",
"license": "MIT"
}
}
}
}

896
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
{
"name": "@mojoio/docker",
"version": "1.0.26",
"version": "1.0.33",
"description": "easy communication with docker remote api from node, TypeScript ready",
"private": false,
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "tsrun test/test.ts",
"build": "(npmts --notest && npmdocker)"
"test": "tstest test/",
"build": "tsbuild"
},
"repository": {
"type": "git",
@ -26,18 +27,30 @@
},
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
"dependencies": {
"@pushrocks/lik": "^3.0.4",
"@pushrocks/smartlog": "^2.0.9",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartrequest": "^1.1.14",
"rxjs": "^6.3.3"
"@pushrocks/lik": "^3.0.10",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.16",
"rxjs": "^6.5.2"
},
"devDependencies": {
"@gitzone/tsrun": "^1.1.17",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.18",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0"
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.11",
"@types/node": "^12.7.1",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0"
},
"private": false
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -13,12 +13,11 @@ tap.test('should list containers', async () => {
console.log(containers);
});
tap.skip.test('should pull an image from imagetag', async () => {
// await testDockerHost.pullImage('hosttoday/ht-docker-node:npmci');
});
tap.test('should return a change Objservable', async (tools) => {
tap.test('should return a change Objservable', async tools => {
const testObservable = await testDockerHost.getEventObservable();
const subscription = testObservable.subscribe(changeObject => {
console.log(changeObject);

View File

@ -11,9 +11,11 @@ export class DockerContainer {
/**
* get all containers
*/
static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
public static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
const result: DockerContainer[] = [];
const response = await dockerHostArg.request('GET', '/containers/json');
// TODO: Think about getting the config by inpsecting the container
for (const containerResult of response.body) {
result.push(new DockerContainer(containerResult));
}
@ -21,13 +23,15 @@ export class DockerContainer {
}
/**
*
* gets an container by Id
* @param containerId
*/
static async getContainerById(containerId: string) {
public static async getContainerById(containerId: string) {}
}
static async create() {}
/**
* create a container
*/
public static async create(creationSpecifier: interfaces.IContainerCreationSpecifier) {}
// ========
// INSTANCE
@ -36,7 +40,7 @@ export class DockerContainer {
constructor(dockerContainerObjectArg: any) {
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
this[keyArg] = dockerContainerObjectArg[keyArg];
})
});
}
Id: string;

View File

@ -37,13 +37,19 @@ export class DockerHost {
async getContainers() {
const containerArray = await DockerContainer.getContainers(this);
return containerArray;
};
}
async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
const response = await this.requestStreaming('GET', '/events');
return plugins.rxjs.Observable.create(observer => {
response.on('data', data => {
observer.next(data.toString());
const eventString = data.toString();
try {
const eventObject = JSON.parse(eventString);
observer.next(eventObject);
} catch (e) {
console.log(e);
}
});
return () => {
response.emit('end');
@ -70,15 +76,16 @@ export class DockerHost {
async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) {
const requestUrl = `${this.sockPath}${routeArg}`;
const response = await plugins.smartrequest.request(
requestUrl, {
method: methodArg,
headers: {
// 'Content-Type': 'application/json',
Host: 'docker.sock'
requestUrl,
{
method: methodArg,
headers: {
// 'Content-Type': 'application/json',
Host: 'docker.sock'
},
requestBody: null
},
requestBody: null
},
true
true
);
console.log(response.statusCode);
console.log(response.body);

View File

@ -2,13 +2,37 @@ import * as plugins from './dockersock.plugins';
import { DockerHost } from './docker.classes.host';
export class DockerImage {
// STATIC
public static async createFromRegistry(
dockerHostArg: DockerHost,
dockerImageTag
): Promise<DockerImage> {
const resultingImage = new DockerImage();
return resultingImage;
}
public static async createFromExistingImage(dockerHostArg: DockerHost, dockerImageTag) {}
// INSTANCE
/**
* the tags for an image
*/
tags: string[] = [];
public tags: string[] = [];
static async createFromRegsitry(dockerHostArg: DockerHost): Promise<DockerImage> {
const resultingImage = new DockerImage();
return resultingImage;
/**
* returns a boolean wether the image has a upstream image
*/
public isUpstreamImage(): boolean {
// TODO: implement isUpastreamImage
return true;
}
/**
*
*/
public async pullLatestImageFromRegistry(): Promise<boolean> {
// TODO: implement pullLatestImageFromRegistry
return true;
}
}

View File

@ -0,0 +1,6 @@
import * as plugins from './dockersock.plugins';
import * as interfaces from './interfaces';
import { DockerHost } from './docker.classes.host';
export class DockerNetwork {}

View File

@ -0,0 +1,6 @@
import * as plugins from './dockersock.plugins';
import * as interfaces from './interfaces';
import { DockerHost } from './docker.classes.host';
export class DockerService {}

View File

@ -4,16 +4,9 @@ import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
export {
lik,
smartlog,
smartpromise,
smartrequest
};
export { lik, smartlog, smartpromise, smartrequest };
// third party
import * as rxjs from 'rxjs';
export {
rxjs
};
export { rxjs };

View File

@ -1 +1,5 @@
export { DockerHost } from './docker.classes.host';
export * from './docker.classes.host';
export * from './docker.classes.container';
export * from './docker.classes.image';
export * from './docker.classes.network';
export * from './docker.classes.service';

View File

@ -0,0 +1,7 @@
import { DockerNetwork } from '../docker.classes.network';
export interface IContainerCreationSpecifier {
hostname: string;
domainName: string;
networks?: DockerNetwork[];
}

View File

@ -1,2 +1,3 @@
export * from './container';
export * from './label';
export * from './port';

View File

@ -1,2 +1,2 @@
// tslint:disable-next-line: interface-over-type-literal
export type TLabels = {[key: string]: string };
export type TLabels = { [key: string]: string };

View File

@ -3,4 +3,4 @@ export interface IPort {
Type: 'tcp';
}
export type TPorts = IPort[];
export type TPorts = IPort[];