Compare commits

...

4 Commits

Author SHA1 Message Date
546e139b46 1.0.57 2019-09-13 13:20:01 +02:00
28d70bb49f fix(core): update 2019-09-13 13:20:01 +02:00
b71f134abd 1.0.56 2019-09-12 14:52:56 +02:00
968b3c7449 fix(core): update 2019-09-12 14:52:55 +02:00
3 changed files with 14 additions and 6 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/docker",
"version": "1.0.55",
"version": "1.0.57",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/docker",
"version": "1.0.55",
"version": "1.0.57",
"description": "easy communication with docker remote api from node, TypeScript ready",
"private": false,
"main": "dist/index.js",

View File

@ -107,7 +107,7 @@ export class DockerService {
public UpdatedAt: string;
public Spec: {
Name: string;
Labels: interfaces.TLabels; // ZBD
Labels: interfaces.TLabels;
TaskTemplate: {
ContainerSpec: {
Image: string;
@ -142,7 +142,7 @@ export class DockerService {
const dockerData = await this.dockerHostRef.request(
'POST',
`/services/${this.ID}/update?version=${this.Version.Index + 1}`,
`/services/${this.ID}/update?version=${this.Version.Index}`,
{
Name: this.Spec.Name,
TaskTemplate: this.Spec.TaskTemplate,
@ -162,7 +162,7 @@ export class DockerService {
Object.assign(this, dockerData);
}
public async updateFromRegistry() {
public async needsUpdate(): Promise<boolean> {
// TODO: implement digest based update recognition
await this.reReadFromDockerEngine();
@ -173,7 +173,15 @@ export class DockerService {
const imageVersion = new plugins.smartversion.SmartVersion(dockerImage.Labels.version);
const serviceVersion = new plugins.smartversion.SmartVersion(this.Spec.Labels.version);
if (imageVersion.greaterThan(serviceVersion)) {
console.log('service needs to be updated');
console.log(`service ${this.Spec.Name} needs to be updated`);
return true;
} else {
console.log(`service ${this.Spec.Name} is up to date.`);
}
}
public async updateFromRegistry() {
if (await this.needsUpdate()) {
this.update();
}
}