From ea117bc391f66b6c52149e053a3627b6dca2bffe Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 10 Jan 2019 00:28:12 +0100 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 135 ++++++++++++++++++++++++++------- package.json | 2 +- test/test.ts | 3 +- ts/docker.classes.container.ts | 8 +- ts/docker.classes.host.ts | 19 ++--- ts/dockersock.plugins.ts | 11 +-- ts/interfaces/label.ts | 2 +- ts/interfaces/port.ts | 2 +- 8 files changed, 125 insertions(+), 57 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b150c5b..42439a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,62 +1,139 @@ -image: hosttoday/ht-docker-dbase:npmci -services: - - docker:dind +# gitzone standard +image: 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 + +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 script: - - npmci test stable + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci npm test + coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - - priv + - docker + - priv release: - image: hosttoday/ht-docker-node:npmci stage: release script: - - npmci publish npm + - npmci node install stable + - npmci npm publish only: - - tags + - tags tags: - - lossless - - priv + - 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 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 + stage: metadata script: - - npmci command yarn global add npmpage - - npmci command npmpage --publish gitlab + - npmci command npm install -g typedoc typescript + - npmci npm prepare + - npmci npm install + - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ tags: - docker + - notpriv only: - tags artifacts: expire_in: 1 week paths: - - public \ No newline at end of file + - public + allow_failure: true diff --git a/package.json b/package.json index a90d5de..bf028a9 100644 --- a/package.json +++ b/package.json @@ -40,4 +40,4 @@ "tslint-config-prettier": "^1.17.0" }, "private": false -} +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 3c30aa6..4a277f2 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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); diff --git a/ts/docker.classes.container.ts b/ts/docker.classes.container.ts index de1126f..a2ef497 100644 --- a/ts/docker.classes.container.ts +++ b/ts/docker.classes.container.ts @@ -21,12 +21,10 @@ export class DockerContainer { } /** - * + * * @param containerId */ - static async getContainerById(containerId: string) { - - } + static async getContainerById(containerId: string) {} static async create() {} // ======== @@ -36,7 +34,7 @@ export class DockerContainer { constructor(dockerContainerObjectArg: any) { Object.keys(dockerContainerObjectArg).forEach(keyArg => { this[keyArg] = dockerContainerObjectArg[keyArg]; - }) + }); } Id: string; diff --git a/ts/docker.classes.host.ts b/ts/docker.classes.host.ts index 1f39acf..6ba8059 100644 --- a/ts/docker.classes.host.ts +++ b/ts/docker.classes.host.ts @@ -37,7 +37,7 @@ export class DockerHost { async getContainers() { const containerArray = await DockerContainer.getContainers(this); return containerArray; - }; + } async getEventObservable(): Promise> { const response = await this.requestStreaming('GET', '/events'); @@ -70,15 +70,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); diff --git a/ts/dockersock.plugins.ts b/ts/dockersock.plugins.ts index c2cebea..f826a0b 100644 --- a/ts/dockersock.plugins.ts +++ b/ts/dockersock.plugins.ts @@ -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 }; diff --git a/ts/interfaces/label.ts b/ts/interfaces/label.ts index 46c6828..de3e34a 100644 --- a/ts/interfaces/label.ts +++ b/ts/interfaces/label.ts @@ -1,2 +1,2 @@ // tslint:disable-next-line: interface-over-type-literal -export type TLabels = {[key: string]: string }; \ No newline at end of file +export type TLabels = { [key: string]: string }; diff --git a/ts/interfaces/port.ts b/ts/interfaces/port.ts index 3eb97bb..80b90fd 100644 --- a/ts/interfaces/port.ts +++ b/ts/interfaces/port.ts @@ -3,4 +3,4 @@ export interface IPort { Type: 'tcp'; } -export type TPorts = IPort[]; \ No newline at end of file +export type TPorts = IPort[];