diff --git a/package-lock.json b/package-lock.json index 6a927fd..15f8840 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,34 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@apiglobal/typedrequest": { + "version": "1.0.17", + "resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest/-/typedrequest-1.0.17.tgz", + "integrity": "sha512-p19ZOROh7+dsA00N3QFHCuyeUWarxpSVZxVJBI59LPnh6JlGE3ixQYpAEi+HJbsGfIEhuOBIJ6upN+0lnjH+fg==", + "requires": { + "@apiglobal/typedrequest-interfaces": "^1.0.7", + "@pushrocks/lik": "^3.0.11", + "@pushrocks/smartjson": "^3.0.8", + "@pushrocks/smartrequest": "^1.1.23" + }, + "dependencies": { + "@pushrocks/smartjson": { + "version": "3.0.8", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.8.tgz", + "integrity": "sha512-EjC3611RSZaZmK+nXxXrYDBxdxYWtrxjOrZtQzbYn0yM33KSCH0sLIAG8B2wYZVAOj4A2pC8mVxFSJ1w3iRFHg==", + "requires": { + "@types/fast-json-stable-stringify": "^2.0.0", + "fast-json-stable-stringify": "^2.0.0", + "lodash.clonedeep": "^4.5.0" + } + } + } + }, + "@apiglobal/typedrequest-interfaces": { + "version": "1.0.7", + "resolved": "https://verdaccio.lossless.one/@apiglobal%2ftypedrequest-interfaces/-/typedrequest-interfaces-1.0.7.tgz", + "integrity": "sha512-yPl0UcLFMwSQL7bK52wVjkgvadC+x2YS3+7T15V1A1dXNxa96yd4WX1fqcKqwnBrvYexq/8FaxWGi98tZ0oNwg==" + }, "@babel/code-frame": { "version": "7.5.5", "resolved": "https://verdaccio.lossless.one/@babel%2fcode-frame/-/code-frame-7.5.5.tgz", diff --git a/package.json b/package.json index 27ff534..5c89416 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "tslint-config-prettier": "^1.18.0" }, "dependencies": { + "@apiglobal/typedrequest": "^1.0.17", "@pushrocks/lik": "^3.0.11", "@pushrocks/npmextra": "^3.0.5", "@pushrocks/projectinfo": "^4.0.2", diff --git a/ts/connector.cloudly/cloudlyconnector.ts b/ts/connector.cloudly/cloudlyconnector.ts index df75063..5926010 100644 --- a/ts/connector.cloudly/cloudlyconnector.ts +++ b/ts/connector.cloudly/cloudlyconnector.ts @@ -1,8 +1,30 @@ import * as plugins from '../npmci.plugins'; +import {Npmci} from '../npmci.classes.npmci'; +import { logger } from '../npmci.logging'; + /** - * + * connects to cloudly */ export class CloudlyConnector { - public announceDockerContainer(options: plugins.servezoneInterfaces.IVersionData) {} + public npmciRef: Npmci; + + constructor(npmciRefArg: Npmci) { + this.npmciRef = npmciRefArg; + } + + + public async announceDockerContainer(optionsArg: plugins.servezoneInterfaces.IVersionData) { + const cloudlyUrl = this.npmciRef.npmciConfig.getConfig().urlCloudly; + if (!cloudlyUrl) { + logger.log('warn', 'no cloudly url provided. Thus we cannot announce the newly built Dockerimage!'); + return; + } + + const typedrequest = new plugins.typedrequest.TypedRequest< + plugins.servezoneInterfaces.IRequest_Any_Cloudly_VersionManager_Update + >(`https://${cloudlyUrl}/versionmanager`, 'update'); + + const response = (await typedrequest.fire(optionsArg)); + } } diff --git a/ts/manager.docker/index.ts b/ts/manager.docker/index.ts index 5fb668c..14edc7f 100644 --- a/ts/manager.docker/index.ts +++ b/ts/manager.docker/index.ts @@ -50,7 +50,7 @@ export class NpmciDockerManager { `>>npmci docker ...<< cli arguments invalid... Please read the documentation.` ); } - }; + } /** * builds a cwd of Dockerfiles by triggering a promisechain @@ -62,7 +62,7 @@ export class NpmciDockerManager { .then(Dockerfile.sortDockerfiles) .then(Dockerfile.mapDockerfiles) .then(Dockerfile.buildDockerfiles); - }; + } /** * login to the DockerRegistries @@ -70,7 +70,7 @@ export class NpmciDockerManager { public login = async () => { await this.prepare(); await this.npmciRegistryStorage.loginAll(); - }; + } /** * logs in docker @@ -98,7 +98,7 @@ export class NpmciDockerManager { } ); return; - }; + } /** * pushes an image towards a registry @@ -146,7 +146,7 @@ export class NpmciDockerManager { await dockerfile.push(dockerRegistryToPushTo, suffix); } } - }; + } /** * pulls an image @@ -165,7 +165,7 @@ export class NpmciDockerManager { for (const dockerfile of dockerfileArray) { await dockerfile.pull(localDockerRegistry, suffix); } - }; + } /** * tests docker files @@ -173,5 +173,5 @@ export class NpmciDockerManager { public test = async () => { await this.prepare(); return await Dockerfile.readDockerfiles(this).then(Dockerfile.testDockerfiles); - }; + } } diff --git a/ts/manager.docker/mod.classes.dockerfile.ts b/ts/manager.docker/mod.classes.dockerfile.ts index d9db08c..1802425 100644 --- a/ts/manager.docker/mod.classes.dockerfile.ts +++ b/ts/manager.docker/mod.classes.dockerfile.ts @@ -266,6 +266,13 @@ export class Dockerfile { ); await bash(`docker tag ${this.buildTag} ${pushTag}`); await bash(`docker push ${pushTag}`); + const imageDigest = (await bash( + `docker inspect --format='{{index .RepoDigests 0}}' ${pushTag}` + )).split('@')[1]; + await this.npmciDockerManagerRef.npmciRef.cloudlyConnector.announceDockerContainer({ + dockerImageUrl: pushTag, + dockerImageVersion: imageDigest + }); } /** diff --git a/ts/npmci.classes.npmci.ts b/ts/npmci.classes.npmci.ts index 883212b..86a95d6 100644 --- a/ts/npmci.classes.npmci.ts +++ b/ts/npmci.classes.npmci.ts @@ -34,7 +34,7 @@ export class Npmci { projectId: 'gitzone', appName: 'npmci' }); - this.cloudlyConnector = new CloudlyConnector(); + this.cloudlyConnector = new CloudlyConnector(this); this.npmciEnv = new NpmciEnv(this); this.npmciInfo = new NpmciInfo(this); this.npmciCli = new NpmciCli(this); diff --git a/ts/npmci.plugins.ts b/ts/npmci.plugins.ts index 36bb59d..2dba147 100644 --- a/ts/npmci.plugins.ts +++ b/ts/npmci.plugins.ts @@ -3,6 +3,13 @@ import * as path from 'path'; export { path }; +// @apiglobal +import * as typedrequest from '@apiglobal/typedrequest'; + +export { + typedrequest +}; + // @servezone import * as servezoneInterfaces from '@servezone/servezone-interfaces';