Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
55acb39071 | |||
f7b17a4684 | |||
d95f6c8e7f | |||
001cdadb6b | |||
82655623d1 | |||
ea117bc391 |
135
.gitlab-ci.yml
135
.gitlab-ci.yml
@ -1,62 +1,139 @@
|
|||||||
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:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
- trigger
|
- release
|
||||||
- pages
|
- 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
|
||||||
|
|
||||||
|
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
|
||||||
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
|
||||||
- priv
|
- 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
|
||||||
|
|
||||||
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
|
||||||
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
package-lock.json
generated
50
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/docker",
|
"name": "@mojoio/docker",
|
||||||
"version": "1.0.26",
|
"version": "1.0.29",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -40,6 +40,22 @@
|
|||||||
"typescript": "^3.0.1"
|
"typescript": "^3.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@gitzone/tstest": {
|
||||||
|
"version": "1.0.18",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.18.tgz",
|
||||||
|
"integrity": "sha512-/owFKFsiFWh6miL+G/DYxBr+B6mgy9WzthLTqNyC7xriYoymvBgnmm5Wo3bo1NQN+1GY83zKeSpY7JB4r2LuEQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@gitzone/tsrun": "^1.1.17",
|
||||||
|
"@pushrocks/consolecolor": "^2.0.1",
|
||||||
|
"@pushrocks/smartfile": "^6.0.11",
|
||||||
|
"@pushrocks/smartlog": "^2.0.9",
|
||||||
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
|
"@pushrocks/smartshell": "^2.0.11",
|
||||||
|
"@types/figures": "^2.0.0",
|
||||||
|
"figures": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pushrocks/consolecolor": {
|
"@pushrocks/consolecolor": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fconsolecolor/-/consolecolor-2.0.1.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fconsolecolor/-/consolecolor-2.0.1.tgz",
|
||||||
@ -188,6 +204,17 @@
|
|||||||
"rxjs": "^6.3.3"
|
"rxjs": "^6.3.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@pushrocks/smartshell": {
|
||||||
|
"version": "2.0.13",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartshell/-/smartshell-2.0.13.tgz",
|
||||||
|
"integrity": "sha512-jLfAhLxMVKAScKdln1QrQqBI7A7INhMNHIq28fJEBi0BNDUS0eerw4yMAnR4CRmcrh4xFp1z+ju1kaPO3I/4MA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
|
"@types/which": "^1.3.1",
|
||||||
|
"which": "^1.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pushrocks/smarttime": {
|
"@pushrocks/smarttime": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.5.tgz",
|
||||||
@ -235,6 +262,12 @@
|
|||||||
"@types/chai": "*"
|
"@types/chai": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/figures": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@types%2ffigures/-/figures-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-mcRgJ+ncKuNI+Dwac7omO18B8C8u+YBS+AU/oyLhEyjAnT3cUUThhHgZpbiIvu5ZqSvdD30BXtrqg9nxc3OKMg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/form-data": {
|
"@types/form-data": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.2.1.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.2.1.tgz",
|
||||||
@ -276,6 +309,12 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/which": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/yargs": {
|
"@types/yargs": {
|
||||||
"version": "12.0.5",
|
"version": "12.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fyargs/-/yargs-12.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fyargs/-/yargs-12.0.5.tgz",
|
||||||
@ -644,6 +683,15 @@
|
|||||||
"strip-eof": "^1.0.0"
|
"strip-eof": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"figures": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/figures/-/figures-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"escape-string-regexp": "^1.0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"find-up": {
|
"find-up": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/find-up/-/find-up-3.0.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/find-up/-/find-up-3.0.0.tgz",
|
||||||
|
12
package.json
12
package.json
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/docker",
|
"name": "@mojoio/docker",
|
||||||
"version": "1.0.26",
|
"version": "1.0.29",
|
||||||
"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",
|
||||||
@ -33,11 +34,12 @@
|
|||||||
"rxjs": "^6.3.3"
|
"rxjs": "^6.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@gitzone/tsbuild": "^2.1.4",
|
||||||
"@gitzone/tsrun": "^1.1.17",
|
"@gitzone/tsrun": "^1.1.17",
|
||||||
|
"@gitzone/tstest": "^1.0.18",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^10.12.18",
|
"@types/node": "^10.12.18",
|
||||||
"tslint": "^5.12.0",
|
"tslint": "^5.12.0",
|
||||||
"tslint-config-prettier": "^1.17.0"
|
"tslint-config-prettier": "^1.17.0"
|
||||||
},
|
}
|
||||||
"private": false
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -21,12 +21,10 @@ export class DockerContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param containerId
|
* @param containerId
|
||||||
*/
|
*/
|
||||||
static async getContainerById(containerId: string) {
|
static async getContainerById(containerId: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
static async create() {}
|
static async create() {}
|
||||||
|
|
||||||
// ========
|
// ========
|
||||||
@ -36,7 +34,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;
|
||||||
|
@ -37,7 +37,7 @@ 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');
|
||||||
@ -70,15 +70,16 @@ 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,
|
{
|
||||||
headers: {
|
method: methodArg,
|
||||||
// 'Content-Type': 'application/json',
|
headers: {
|
||||||
Host: 'docker.sock'
|
// 'Content-Type': 'application/json',
|
||||||
|
Host: 'docker.sock'
|
||||||
|
},
|
||||||
|
requestBody: null
|
||||||
},
|
},
|
||||||
requestBody: null
|
true
|
||||||
},
|
|
||||||
true
|
|
||||||
);
|
);
|
||||||
console.log(response.statusCode);
|
console.log(response.statusCode);
|
||||||
console.log(response.body);
|
console.log(response.body);
|
||||||
|
@ -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
|
|
||||||
};
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
// tslint:disable-next-line: interface-over-type-literal
|
// tslint:disable-next-line: interface-over-type-literal
|
||||||
export type TLabels = {[key: string]: string };
|
export type TLabels = { [key: string]: string };
|
||||||
|
@ -3,4 +3,4 @@ export interface IPort {
|
|||||||
Type: 'tcp';
|
Type: 'tcp';
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TPorts = IPort[];
|
export type TPorts = IPort[];
|
||||||
|
Reference in New Issue
Block a user