fix(core): update

This commit is contained in:
Philipp Kunz 2019-09-13 18:20:12 +02:00
parent ad67849d45
commit 83c49a6234
9 changed files with 50 additions and 40 deletions

View File

@ -38,13 +38,11 @@ snyk:
# test stage # test stage
# ==================== # ====================
testLTS: testStable:
services:
- docker:18-dind
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install lts - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
@ -56,7 +54,7 @@ testBuild:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install lts - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
@ -67,7 +65,7 @@ testBuild:
release: release:
stage: release stage: release
script: script:
- npmci node install lts - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
@ -102,7 +100,7 @@ trigger:
pages: pages:
image: hosttoday/ht-docker-dbase:npmci image: hosttoday/ht-docker-dbase:npmci
services: services:
- docker:18-dind - docker:stable-dind
stage: metadata stage: metadata
script: script:
- npmci command npm install -g @gitzone/tsdoc - npmci command npm install -g @gitzone/tsdoc

View File

@ -72,7 +72,6 @@ tap.test('should remove a secret by name', async () => {
await mySecret.remove(); await mySecret.remove();
}); });
// SERVICES // SERVICES
tap.test('should activate swarm mode', async () => { tap.test('should activate swarm mode', async () => {
await testDockerHost.activateSwarm(); await testDockerHost.activateSwarm();
@ -99,7 +98,7 @@ tap.test('should create a service', async () => {
const testService = await docker.DockerService.createService(testDockerHost, { const testService = await docker.DockerService.createService(testDockerHost, {
image: testImage, image: testImage,
labels: { labels: {
'testlabel': 'hi' testlabel: 'hi'
}, },
name: 'testService', name: 'testService',
networks: [testNetwork], networks: [testNetwork],

View File

@ -73,7 +73,6 @@ export class DockerHost {
* *
*/ */
/** /**
* gets all containers * gets all containers
*/ */

View File

@ -21,7 +21,6 @@ export class DockerImage {
} else { } else {
return false; return false;
} }
}); });
return result; return result;
} }
@ -30,7 +29,6 @@ export class DockerImage {
dockerHostArg: DockerHost, dockerHostArg: DockerHost,
creationObject: interfaces.IImageCreationDescriptor creationObject: interfaces.IImageCreationDescriptor
): Promise<DockerImage> { ): Promise<DockerImage> {
// lets create a sanatized imageUrlObject // lets create a sanatized imageUrlObject
const imageUrlObject: { const imageUrlObject: {
imageUrl: string; imageUrl: string;
@ -46,9 +44,7 @@ export class DockerImage {
const imageTag = imageUrlObject.imageUrl.split(':')[1]; const imageTag = imageUrlObject.imageUrl.split(':')[1];
if (imageUrlObject.imageTag) { if (imageUrlObject.imageTag) {
throw new Error( throw new Error(
`imageUrl ${imageUrlObject.imageUrl} can't be tagged with ${ `imageUrl ${imageUrlObject.imageUrl} can't be tagged with ${imageUrlObject.imageTag} because it is already tagged with ${imageTag}`
imageUrlObject.imageTag
} because it is already tagged with ${imageTag}`
); );
} else { } else {
imageUrlObject.imageUrl = imageUrl; imageUrlObject.imageUrl = imageUrl;

View File

@ -17,17 +17,20 @@ export class DockerSecret {
return secrets; return secrets;
} }
public static async getSecretByID (dockerHostArg: DockerHost, idArg: string) { public static async getSecretByID(dockerHostArg: DockerHost, idArg: string) {
const secrets = await this.getSecrets(dockerHostArg); const secrets = await this.getSecrets(dockerHostArg);
return secrets.find(secret => secret.ID === idArg); return secrets.find(secret => secret.ID === idArg);
} }
public static async getSecretByName (dockerHostArg: DockerHost, nameArg: string) { public static async getSecretByName(dockerHostArg: DockerHost, nameArg: string) {
const secrets = await this.getSecrets(dockerHostArg); const secrets = await this.getSecrets(dockerHostArg);
return secrets.find(secret => secret.Spec.Name === nameArg); return secrets.find(secret => secret.Spec.Name === nameArg);
} }
public static async createSecret(dockerHostArg: DockerHost, secretDescriptor: interfaces.ISecretCreationDescriptor) { public static async createSecret(
dockerHostArg: DockerHost,
secretDescriptor: interfaces.ISecretCreationDescriptor
) {
const labels: interfaces.TLabels = { const labels: interfaces.TLabels = {
...secretDescriptor.labels, ...secretDescriptor.labels,
version: secretDescriptor.version version: secretDescriptor.version
@ -40,7 +43,10 @@ export class DockerSecret {
const newSecretInstance = new DockerSecret(dockerHostArg); const newSecretInstance = new DockerSecret(dockerHostArg);
Object.assign(newSecretInstance, response.body); Object.assign(newSecretInstance, response.body);
Object.assign (newSecretInstance, await DockerSecret.getSecretByID(dockerHostArg, newSecretInstance.ID)); Object.assign(
newSecretInstance,
await DockerSecret.getSecretByID(dockerHostArg, newSecretInstance.ID)
);
return newSecretInstance; return newSecretInstance;
} }
@ -51,7 +57,7 @@ export class DockerSecret {
Labels: interfaces.TLabels; Labels: interfaces.TLabels;
}; };
public Version: { public Version: {
Index:string; Index: string;
}; };
public dockerHost: DockerHost; public dockerHost: DockerHost;
@ -62,20 +68,23 @@ export class DockerSecret {
/** /**
* updates a secret * updates a secret
*/ */
public async update (contentArg: string) { public async update(contentArg: string) {
const route = `/secrets/${this.ID}/update?=version=${this.Version.Index}`; const route = `/secrets/${this.ID}/update?=version=${this.Version.Index}`;
const response = await this.dockerHost.request('POST', `/secrets/${this.ID}/update?version=${this.Version.Index}`, { const response = await this.dockerHost.request(
'POST',
`/secrets/${this.ID}/update?version=${this.Version.Index}`,
{
Name: this.Spec.Name, Name: this.Spec.Name,
Labels: this.Spec.Labels, Labels: this.Spec.Labels,
Data: plugins.smartstring.base64.encode(contentArg) Data: plugins.smartstring.base64.encode(contentArg)
}); }
);
} }
public async remove () { public async remove() {
await this.dockerHost.request('DELETE', `/secrets/${this.ID}`); await this.dockerHost.request('DELETE', `/secrets/${this.ID}`);
} }
// get things // get things
public async getVersion() { public async getVersion() {
return this.Spec.Labels.version; return this.Spec.Labels.version;

View File

@ -1,9 +1,7 @@
// node native path // node native path
import * as path from 'path'; import * as path from 'path';
export { export { path };
path
};
// @pushrocks scope // @pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@pushrocks/lik';
@ -19,7 +17,18 @@ import * as smartversion from '@pushrocks/smartversion';
smartlog.defaultLogger.enableConsole(); smartlog.defaultLogger.enableConsole();
export { lik, smartfile, smartjson, smartlog, smartnetwork, smartpath, smartpromise, smartrequest, smartstring, smartversion }; export {
lik,
smartfile,
smartjson,
smartlog,
smartnetwork,
smartpath,
smartpromise,
smartrequest,
smartstring,
smartversion
};
// third party // third party
import * as rxjs from 'rxjs'; import * as rxjs from 'rxjs';