mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-21 20:08:09 +00:00
Clear up images.ts module code for simiplicity
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
6f9d9e5de6
commit
24ce72a2c3
@ -244,10 +244,6 @@ export class Images extends (EventEmitter as {
|
||||
),
|
||||
);
|
||||
|
||||
// if (localMode) {
|
||||
// // Get all images present on the local daemon which are tagged as local images
|
||||
// return images.concat(await this.getLocalModeImages());
|
||||
// }
|
||||
return images;
|
||||
}
|
||||
|
||||
@ -285,9 +281,8 @@ export class Images extends (EventEmitter as {
|
||||
}
|
||||
}
|
||||
}
|
||||
return _.filter(
|
||||
supervisedImages,
|
||||
image => !this.isAvailableInDocker(image, dockerImages),
|
||||
return _.reject(supervisedImages, image =>
|
||||
this.isAvailableInDocker(image, dockerImages),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -384,7 +379,8 @@ export class Images extends (EventEmitter as {
|
||||
}
|
||||
}
|
||||
}
|
||||
const toCleanup = _(images)
|
||||
|
||||
return _(images)
|
||||
.uniq()
|
||||
.filter(
|
||||
image =>
|
||||
@ -393,7 +389,6 @@ export class Images extends (EventEmitter as {
|
||||
constants.imageCleanupErrorIgnoreTimeout,
|
||||
)
|
||||
.value();
|
||||
return toCleanup;
|
||||
}
|
||||
|
||||
public async inspectByName(
|
||||
@ -455,19 +450,6 @@ export class Images extends (EventEmitter as {
|
||||
);
|
||||
}
|
||||
|
||||
// private async getLocalModeImages() {
|
||||
// const [legacy, current] = await Promise.all([
|
||||
// this.docker.listImages({
|
||||
// filters: { label: ['io.resin.local.image=1'] },
|
||||
// }),
|
||||
// this.docker.listImages({
|
||||
// filters: { label: ['io.balena.local.image=1'] },
|
||||
// }),
|
||||
// ]);
|
||||
|
||||
// const dockerImages = _.unionBy(legacy, current, 'Id');
|
||||
// }
|
||||
|
||||
private normalise(imageName: string): Bluebird<string> {
|
||||
return this.docker.normaliseImageName(imageName);
|
||||
}
|
||||
@ -623,17 +605,18 @@ export class Images extends (EventEmitter as {
|
||||
|
||||
// TODO: find out if imageId can actually be null
|
||||
private reportChange(imageId: Nullable<number>, status?: Partial<Image>) {
|
||||
if (imageId != null) {
|
||||
if (status != null) {
|
||||
if (this.volatileState[imageId] == null) {
|
||||
this.volatileState[imageId] = { imageId } as Image;
|
||||
}
|
||||
_.merge(this.volatileState[imageId], status);
|
||||
return this.emit('change');
|
||||
} else if (this.volatileState[imageId] != null) {
|
||||
delete this.volatileState[imageId];
|
||||
return this.emit('change');
|
||||
if (imageId == null) {
|
||||
return;
|
||||
}
|
||||
if (status != null) {
|
||||
if (this.volatileState[imageId] == null) {
|
||||
this.volatileState[imageId] = { imageId } as Image;
|
||||
}
|
||||
_.merge(this.volatileState[imageId], status);
|
||||
return this.emit('change');
|
||||
} else if (this.volatileState[imageId] != null) {
|
||||
delete this.volatileState[imageId];
|
||||
return this.emit('change');
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,10 +625,7 @@ export class Images extends (EventEmitter as {
|
||||
return false;
|
||||
}
|
||||
const parts = name.split('@');
|
||||
if (parts[1] == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return parts[1] != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user