Clear up images.ts module code for simiplicity

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-01-23 16:40:15 +00:00
parent 6f9d9e5de6
commit 24ce72a2c3
No known key found for this signature in database
GPG Key ID: 49690ED87032539F

View File

@ -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; return images;
} }
@ -285,9 +281,8 @@ export class Images extends (EventEmitter as {
} }
} }
} }
return _.filter( return _.reject(supervisedImages, image =>
supervisedImages, this.isAvailableInDocker(image, dockerImages),
image => !this.isAvailableInDocker(image, dockerImages),
); );
}, },
); );
@ -384,7 +379,8 @@ export class Images extends (EventEmitter as {
} }
} }
} }
const toCleanup = _(images)
return _(images)
.uniq() .uniq()
.filter( .filter(
image => image =>
@ -393,7 +389,6 @@ export class Images extends (EventEmitter as {
constants.imageCleanupErrorIgnoreTimeout, constants.imageCleanupErrorIgnoreTimeout,
) )
.value(); .value();
return toCleanup;
} }
public async inspectByName( 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> { private normalise(imageName: string): Bluebird<string> {
return this.docker.normaliseImageName(imageName); return this.docker.normaliseImageName(imageName);
} }
@ -623,7 +605,9 @@ export class Images extends (EventEmitter as {
// TODO: find out if imageId can actually be null // TODO: find out if imageId can actually be null
private reportChange(imageId: Nullable<number>, status?: Partial<Image>) { private reportChange(imageId: Nullable<number>, status?: Partial<Image>) {
if (imageId != null) { if (imageId == null) {
return;
}
if (status != null) { if (status != null) {
if (this.volatileState[imageId] == null) { if (this.volatileState[imageId] == null) {
this.volatileState[imageId] = { imageId } as Image; this.volatileState[imageId] = { imageId } as Image;
@ -635,17 +619,13 @@ export class Images extends (EventEmitter as {
return this.emit('change'); return this.emit('change');
} }
} }
}
private static hasDigest(name: Nullable<string>): boolean { private static hasDigest(name: Nullable<string>): boolean {
if (name == null) { if (name == null) {
return false; return false;
} }
const parts = name.split('@'); const parts = name.split('@');
if (parts[1] == null) { return parts[1] != null;
return false;
}
return true;
} }
} }