fix(deps): upgrade core tooling dependencies and adapt Docker client internals for compatibility
This commit is contained in:
@@ -37,6 +37,9 @@ export class DockerService extends DockerResource {
|
||||
const wantedService = allServices.find((service) => {
|
||||
return service.Spec.Name === networkName;
|
||||
});
|
||||
if (!wantedService) {
|
||||
throw new Error(`Service not found: ${networkName}`);
|
||||
}
|
||||
return wantedService;
|
||||
}
|
||||
|
||||
@@ -56,10 +59,11 @@ export class DockerService extends DockerResource {
|
||||
// Resolve image (support both string and DockerImage instance)
|
||||
let imageInstance: DockerImage;
|
||||
if (typeof serviceCreationDescriptor.image === 'string') {
|
||||
imageInstance = await DockerImage._fromName(dockerHost, serviceCreationDescriptor.image);
|
||||
if (!imageInstance) {
|
||||
const foundImage = await DockerImage._fromName(dockerHost, serviceCreationDescriptor.image);
|
||||
if (!foundImage) {
|
||||
throw new Error(`Image not found: ${serviceCreationDescriptor.image}`);
|
||||
}
|
||||
imageInstance = foundImage;
|
||||
} else {
|
||||
imageInstance = serviceCreationDescriptor.image;
|
||||
}
|
||||
@@ -131,7 +135,7 @@ export class DockerService extends DockerResource {
|
||||
});
|
||||
}
|
||||
|
||||
const ports = [];
|
||||
const ports: Array<{ Protocol: string; PublishedPort: number; TargetPort: number }> = [];
|
||||
for (const port of serviceCreationDescriptor.ports) {
|
||||
const portArray = port.split(':');
|
||||
const hostPort = portArray[0];
|
||||
@@ -149,10 +153,11 @@ export class DockerService extends DockerResource {
|
||||
// Resolve secret instance
|
||||
let secretInstance: DockerSecret;
|
||||
if (typeof secret === 'string') {
|
||||
secretInstance = await DockerSecret._fromName(dockerHost, secret);
|
||||
if (!secretInstance) {
|
||||
const foundSecret = await DockerSecret._fromName(dockerHost, secret);
|
||||
if (!foundSecret) {
|
||||
throw new Error(`Secret not found: ${secret}`);
|
||||
}
|
||||
secretInstance = foundSecret;
|
||||
} else {
|
||||
secretInstance = secret;
|
||||
}
|
||||
@@ -171,21 +176,12 @@ export class DockerService extends DockerResource {
|
||||
|
||||
// lets configure limits
|
||||
|
||||
const memoryLimitMB =
|
||||
serviceCreationDescriptor.resources &&
|
||||
serviceCreationDescriptor.resources.memorySizeMB
|
||||
? serviceCreationDescriptor.resources.memorySizeMB
|
||||
: 1000;
|
||||
const memoryLimitMB = serviceCreationDescriptor.resources?.memorySizeMB ?? 1000;
|
||||
|
||||
const limits = {
|
||||
MemoryBytes: memoryLimitMB * 1000000,
|
||||
};
|
||||
|
||||
if (serviceCreationDescriptor.resources) {
|
||||
limits.MemoryBytes =
|
||||
serviceCreationDescriptor.resources.memorySizeMB * 1000000;
|
||||
}
|
||||
|
||||
const response = await dockerHost.request('POST', '/services/create', {
|
||||
Name: serviceCreationDescriptor.name,
|
||||
TaskTemplate: {
|
||||
@@ -234,11 +230,11 @@ export class DockerService extends DockerResource {
|
||||
// INSTANCE PROPERTIES
|
||||
// Note: dockerHost (not dockerHostRef) for consistency with base class
|
||||
|
||||
public ID: string;
|
||||
public Version: { Index: number };
|
||||
public CreatedAt: string;
|
||||
public UpdatedAt: string;
|
||||
public Spec: {
|
||||
public ID!: string;
|
||||
public Version!: { Index: number };
|
||||
public CreatedAt!: string;
|
||||
public UpdatedAt!: string;
|
||||
public Spec!: {
|
||||
Name: string;
|
||||
Labels: interfaces.TLabels;
|
||||
TaskTemplate: {
|
||||
@@ -261,7 +257,7 @@ export class DockerService extends DockerResource {
|
||||
Mode: {};
|
||||
Networks: [any[]];
|
||||
};
|
||||
public Endpoint: { Spec: {}; VirtualIPs: [any[]] };
|
||||
public Endpoint!: { Spec: {}; VirtualIPs: [any[]] };
|
||||
|
||||
constructor(dockerHostArg: DockerHost) {
|
||||
super(dockerHostArg);
|
||||
@@ -325,6 +321,7 @@ export class DockerService extends DockerResource {
|
||||
return true;
|
||||
} else {
|
||||
console.log(`service ${this.Spec.Name} is up to date.`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user