Skip to content

Commit 56f32ed

Browse files
authored
Let PurgeCommand inspect the results (#1226)
1 parent e50af9b commit 56f32ed

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

quarkus/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.polaris.admintool;
2020

2121
import java.util.List;
22+
import java.util.Map;
2223
import picocli.CommandLine;
2324

2425
@CommandLine.Command(
@@ -37,9 +38,26 @@ public class PurgeCommand extends BaseCommand {
3738
@Override
3839
public Integer call() {
3940
try {
40-
metaStoreManagerFactory.purgeRealms(realms);
41-
spec.commandLine().getOut().println("Purge completed successfully.");
42-
return 0;
41+
var result = metaStoreManagerFactory.purgeRealms(realms);
42+
var failed =
43+
result.entrySet().stream()
44+
.filter(e -> !e.getValue().isSuccess())
45+
.map(Map.Entry::getKey)
46+
.toList();
47+
if (failed.isEmpty()) {
48+
spec.commandLine().getOut().println("Purge completed successfully.");
49+
return 0;
50+
}
51+
52+
var out = spec.commandLine().getOut();
53+
failed.forEach(
54+
r ->
55+
out.printf(
56+
"Realm %s is not bootstrapped, could not load root principal. Please run Bootstrap command.%n",
57+
r));
58+
59+
spec.commandLine().getErr().printf("Purge encountered errors during operation.");
60+
return EXIT_CODE_PURGE_ERROR;
4361
} catch (Exception e) {
4462
spec.commandLine().getErr().println("Purge encountered errors during operation.");
4563
return EXIT_CODE_PURGE_ERROR;

0 commit comments

Comments
 (0)