fix(core): update
This commit is contained in:
parent
a28b10ac51
commit
73f8ded3fe
@ -64,12 +64,16 @@ tap.test('should list all services', async tools => {
|
||||
});
|
||||
|
||||
tap.test('should create a service', async () => {
|
||||
const testNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
|
||||
Name: 'testNetwork'
|
||||
});
|
||||
await DockerService.createService(testDockerHost, {
|
||||
Image: 'nginx',
|
||||
Image: 'nginx:latest',
|
||||
Labels: {
|
||||
'testlabel': 'hi'
|
||||
},
|
||||
Name: 'testService'
|
||||
Name: 'testService',
|
||||
networks: [testNetwork]
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -47,6 +47,8 @@ export class DockerImage {
|
||||
} else {
|
||||
imageUrlObject.imageTag = imageTag;
|
||||
}
|
||||
} else if (!imageUrlObject.imageTag) {
|
||||
imageUrlObject.imageTag = 'latest';
|
||||
}
|
||||
imageUrlObject.imageOriginTag = `${imageUrlObject.imageUrl}:${imageUrlObject.imageTag}`;
|
||||
|
||||
|
@ -23,10 +23,19 @@ export class DockerService {
|
||||
serviceCreationDescriptor: interfaces.IServiceCreationDescriptor
|
||||
) {
|
||||
// lets get the image
|
||||
DockerImage.createFromRegistry(dockerHost, {
|
||||
plugins.smartlog.defaultLogger.log('info', `downloading image for service ${serviceCreationDescriptor.Name}`);
|
||||
const serviceImage = await DockerImage.createFromRegistry(dockerHost, {
|
||||
imageUrl: serviceCreationDescriptor.Image
|
||||
});
|
||||
|
||||
const networkArray: any[] = [];
|
||||
for (const network of serviceCreationDescriptor.networks) {
|
||||
networkArray.push({
|
||||
Target: network.Name,
|
||||
Aliases: []
|
||||
});
|
||||
}
|
||||
|
||||
dockerHost.request('POST', '/services/create', {
|
||||
Name: serviceCreationDescriptor.Name,
|
||||
TaskTemplate: {
|
||||
@ -35,7 +44,8 @@ export class DockerService {
|
||||
Labels: serviceCreationDescriptor.Labels
|
||||
}
|
||||
},
|
||||
Labels: serviceCreationDescriptor.Labels
|
||||
Labels: serviceCreationDescriptor.Labels,
|
||||
Networks: networkArray
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import * as interfaces from './';
|
||||
import { DockerNetwork } from '../docker.classes.network';
|
||||
|
||||
export interface IServiceCreationDescriptor {
|
||||
Name: string;
|
||||
Image: string;
|
||||
Labels: interfaces.TLabels;
|
||||
networks: DockerNetwork[];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user