Compare commits

...

12 Commits

Author SHA1 Message Date
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
16 changed files with 772 additions and 423 deletions

View File

@ -1,62 +1,141 @@
image: hosttoday/ht-docker-dbase:npmci # gitzone standard
services: image: hosttoday/ht-docker-node:npmci
- docker:dind
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: "$CI_BUILD_STAGE"
stages: stages:
- security
- test - test
- release - release
- trigger - metadata
- pages
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
sast:
stage: security
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
script:
- npmci npm prepare
- npmci npm install
- npmci command npm run build
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
reports:
sast: gl-sast-report.json
tags:
- docker
- priv
# ====================
# test stage
# ====================
testSTABLE:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:dind
stage: test stage: test
script: script:
- npmci test stable - npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless - docker
- priv - priv
release: release:
image: hosttoday/ht-docker-node:npmci
stage: release stage: release
script: script:
- npmci publish npm - npmci node install stable
- npmci npm publish
only: only:
- tags - tags
tags: tags:
- lossless - docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags:
- docker
- priv - priv
trigger: trigger:
image: hosttoday/ht-docker-node:npmci stage: metadata
stage: trigger
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- lossless - docker
- priv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: pages stage: metadata
script: script:
- npmci command yarn global add npmpage - npmci command npm install -g typedoc typescript
- npmci command npmpage --publish gitlab - npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags: tags:
- docker - docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true

View File

@ -1,8 +1,4 @@
{ {
"npmts": {
"mode": "default",
"coverageTreshold": 10
},
"npmdocker": { "npmdocker": {
"baseImage": "hosttoday/ht-docker-node:npmci", "baseImage": "hosttoday/ht-docker-node:npmci",
"command": "command":
@ -10,6 +6,8 @@
"dockerSock": true "dockerSock": true
}, },
"npmci": { "npmci": {
"globalNpmTools": ["npmts", "npmdocker"] "npmGlobalTools": [],
"npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
} }
} }

896
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -37,13 +37,19 @@ export class DockerHost {
async getContainers() { async getContainers() {
const containerArray = await DockerContainer.getContainers(this); const containerArray = await DockerContainer.getContainers(this);
return containerArray; return containerArray;
}; }
async getEventObservable(): Promise<plugins.rxjs.Observable<any>> { async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
const response = await this.requestStreaming('GET', '/events'); const response = await this.requestStreaming('GET', '/events');
return plugins.rxjs.Observable.create(observer => { return plugins.rxjs.Observable.create(observer => {
response.on('data', data => { 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 () => { return () => {
response.emit('end'); response.emit('end');
@ -70,7 +76,8 @@ export class DockerHost {
async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) { async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) {
const requestUrl = `${this.sockPath}${routeArg}`; const requestUrl = `${this.sockPath}${routeArg}`;
const response = await plugins.smartrequest.request( const response = await plugins.smartrequest.request(
requestUrl, { requestUrl,
{
method: methodArg, method: methodArg,
headers: { headers: {
// 'Content-Type': 'application/json', // 'Content-Type': 'application/json',

View File

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

View File

@ -0,0 +1,8 @@
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,8 @@
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 smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
export { export { lik, smartlog, smartpromise, smartrequest };
lik,
smartlog,
smartpromise,
smartrequest
};
// third party // third party
import * as rxjs from 'rxjs'; import * as rxjs from 'rxjs';
export { export { rxjs };
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 './label';
export * from './port'; export * from './port';