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

View File

@ -59,4 +59,4 @@
"npmextra.json",
"readme.md"
]
}
}

View File

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

View File

@ -47,7 +47,7 @@ export class DockerHost {
/**
* sets an auth token
* @param authToken
* @param authToken
*/
public setAuthToken(authToken: string) {
this.registryToken = authToken;
@ -70,10 +70,9 @@ export class DockerHost {
}
/**
*
*
*/
/**
* gets all containers
*/

View File

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

View File

@ -17,17 +17,20 @@ export class DockerSecret {
return secrets;
}
public static async getSecretByID (dockerHostArg: DockerHost, idArg: string) {
public static async getSecretByID(dockerHostArg: DockerHost, idArg: string) {
const secrets = await this.getSecrets(dockerHostArg);
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);
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 = {
...secretDescriptor.labels,
version: secretDescriptor.version
@ -37,10 +40,13 @@ export class DockerSecret {
Labels: labels,
Data: plugins.smartstring.base64.encode(secretDescriptor.contentArg)
});
const newSecretInstance = new DockerSecret(dockerHostArg);
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;
}
@ -51,7 +57,7 @@ export class DockerSecret {
Labels: interfaces.TLabels;
};
public Version: {
Index:string;
Index: string;
};
public dockerHost: DockerHost;
@ -62,22 +68,25 @@ export class DockerSecret {
/**
* updates a secret
*/
public async update (contentArg: string) {
public async update(contentArg: string) {
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}`, {
Name: this.Spec.Name,
Labels: this.Spec.Labels,
Data: plugins.smartstring.base64.encode(contentArg)
});
const response = await this.dockerHost.request(
'POST',
`/secrets/${this.ID}/update?version=${this.Version.Index}`,
{
Name: this.Spec.Name,
Labels: this.Spec.Labels,
Data: plugins.smartstring.base64.encode(contentArg)
}
);
}
public async remove () {
public async remove() {
await this.dockerHost.request('DELETE', `/secrets/${this.ID}`);
}
// get things
public async getVersion() {
return this.Spec.Labels.version;
}
}
}

View File

@ -41,7 +41,7 @@ export class DockerService {
'info',
`now creating service ${serviceCreationDescriptor.name}`
);
// await serviceCreationDescriptor.image.pullLatestImageFromRegistry();
const serviceVersion = await serviceCreationDescriptor.image.getVersion();

View File

@ -1,9 +1,7 @@
// node native path
import * as path from 'path';
export {
path
};
export { path };
// @pushrocks scope
import * as lik from '@pushrocks/lik';
@ -19,7 +17,18 @@ import * as smartversion from '@pushrocks/smartversion';
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
import * as rxjs from 'rxjs';

View File

@ -5,4 +5,4 @@ export interface ISecretCreationDescriptor {
version: string;
contentArg: any;
labels: interfaces.TLabels;
}
}