Skip to content

Commit

Permalink
Fix Docker and Podman show images without containers
Browse files Browse the repository at this point in the history
  • Loading branch information
rovellipaolo committed Oct 31, 2023
1 parent 09228d6 commit 06ee577
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"43",
"44"
],
"version": 26
"version": 27
}
7 changes: 6 additions & 1 deletion src/data/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ var getImages = async (engine) => {
const result = await CommandLine.execute(
COMMAND_TEMPLATE_IMAGES.replace(PARAM_ENGINE, engine),
);
return parseImages(result);
const images = parseImages(result);
if (images.length === 0) {
Log.w(LOGTAG, `No ${engine} image detected!`);
throw new Error("No image detected!");
}
return images;
};

/**
Expand Down
10 changes: 9 additions & 1 deletion src/data/dockerRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ var isInstalled = () => Container.isInstalled(ENGINE);
*/
/* exported getContainers */
var getContainers = async () => {
var containers = await Container.getContainers(ENGINE);
var containers = [];
try {
containers = await Container.getContainers(ENGINE);
} catch (error) {
Log.w(LOGTAG, `Cannot retrieve ${ENGINE} containers: ${error.message}`);
}
if (Settings.shouldShowDockerImages()) {
try {
const images = await Container.getImages(ENGINE);
Expand All @@ -33,6 +38,9 @@ var getContainers = async () => {
Log.w(LOGTAG, `Cannot retrieve ${ENGINE} images: ${error.message}`);
}
}
if (containers.length === 0) {
throw new Error("No container detected!");
}
return containers;
};

Expand Down
10 changes: 9 additions & 1 deletion src/data/podmanRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ var isInstalled = () => Container.isInstalled(ENGINE);
*/
/* exported getContainers */
var getContainers = async () => {
var containers = await Container.getContainers(ENGINE);
var containers = [];
try {
containers = await Container.getContainers(ENGINE);
} catch (error) {
Log.w(LOGTAG, `Cannot retrieve ${ENGINE} containers: ${error.message}`);
}
if (Settings.shouldShowPodmanImages()) {
try {
const images = await Container.getImages(ENGINE);
Expand All @@ -33,6 +38,9 @@ var getContainers = async () => {
Log.w(LOGTAG, `Cannot retrieve ${ENGINE} images: ${error.message}`);
}
}
if (containers.length === 0) {
throw new Error("No container detected!");
}
return containers;
};

Expand Down

0 comments on commit 06ee577

Please sign in to comment.