From 55f45b1c3af657544c96c3d16087ee4097ea0b8b Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 13 Sep 2019 16:57:21 +0200 Subject: [PATCH] fix(core): update --- test/test.ts | 8 +++++--- ts/docker.classes.image.ts | 8 +++++++- ts/docker.classes.service.ts | 12 +++++------- ts/interfaces/service.ts | 3 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/test/test.ts b/test/test.ts index 6f48ef2..605d08e 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,6 +1,5 @@ import { expect, tap } from '@pushrocks/tapbundle'; import * as docker from '../ts/index'; -import { DockerService } from '../ts/index'; let testDockerHost: docker.DockerHost; @@ -94,8 +93,11 @@ tap.test('should create a service', async () => { labels: {}, contentArg: '{"hi": "wow"}' }); - const testService = await DockerService.createService(testDockerHost, { - image: 'nginx:latest', + const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, { + imageUrl: 'nginx:latest' + }); + const testService = await docker.DockerService.createService(testDockerHost, { + image: testImage, labels: { 'testlabel': 'hi' }, diff --git a/ts/docker.classes.image.ts b/ts/docker.classes.image.ts index d7f485e..f2c04b4 100644 --- a/ts/docker.classes.image.ts +++ b/ts/docker.classes.image.ts @@ -119,7 +119,13 @@ export class DockerImage { }); } - public tagImage(newTag) {} + /** + * tag an image + * @param newTag + */ + public async tagImage(newTag) { + throw new Error('.tagImage is not yet implemented'); + } /** * pulls the latest version from the registry diff --git a/ts/docker.classes.service.ts b/ts/docker.classes.service.ts index cb91778..5849736 100644 --- a/ts/docker.classes.service.ts +++ b/ts/docker.classes.service.ts @@ -39,13 +39,11 @@ export class DockerService { // lets get the image plugins.smartlog.defaultLogger.log( 'info', - `downloading image for service ${serviceCreationDescriptor.name}` + `now creating service ${serviceCreationDescriptor.name}` ); - const serviceImage = await DockerImage.createFromRegistry(dockerHost, { - imageUrl: serviceCreationDescriptor.image - }); - - const serviceVersion = serviceImage.Labels.version; + + // await serviceCreationDescriptor.image.pullLatestImageFromRegistry(); + const serviceVersion = await serviceCreationDescriptor.image.getVersion(); const labels: interfaces.TLabels = { ...serviceCreationDescriptor.labels, @@ -78,7 +76,7 @@ export class DockerService { Name: serviceCreationDescriptor.name, TaskTemplate: { ContainerSpec: { - Image: serviceCreationDescriptor.image, + Image: serviceCreationDescriptor.image.RepoTags[0], Labels: labels, Secrets: secretArray }, diff --git a/ts/interfaces/service.ts b/ts/interfaces/service.ts index 66d488d..0c16226 100644 --- a/ts/interfaces/service.ts +++ b/ts/interfaces/service.ts @@ -1,10 +1,11 @@ import * as interfaces from './'; import { DockerNetwork } from '../docker.classes.network'; import { DockerSecret } from '../docker.classes.secret'; +import { DockerImage } from '../docker.classes.image'; export interface IServiceCreationDescriptor { name: string; - image: string; + image: DockerImage; labels: interfaces.TLabels; networks: DockerNetwork[]; networkAlias: string;