Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.polaris.admintool;

import java.util.List;
import java.util.Map;
import picocli.CommandLine;

@CommandLine.Command(
Expand All @@ -37,9 +38,26 @@ public class PurgeCommand extends BaseCommand {
@Override
public Integer call() {
try {
metaStoreManagerFactory.purgeRealms(realms);
spec.commandLine().getOut().println("Purge completed successfully.");
return 0;
var result = metaStoreManagerFactory.purgeRealms(realms);
var failed =
result.entrySet().stream()
.filter(e -> !e.getValue().isSuccess())
.map(Map.Entry::getKey)
.toList();
if (failed.isEmpty()) {
spec.commandLine().getOut().println("Purge completed successfully.");
return 0;
}

var out = spec.commandLine().getOut();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inlined or pulled above line 47

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather a nit, right?

failed.forEach(
r ->
out.printf(
"Realm %s is not bootstrapped, could not load root principal. Please run Bootstrap command.%n",
r));

spec.commandLine().getErr().printf("Purge encountered errors during operation.");
return EXIT_CODE_PURGE_ERROR;
} catch (Exception e) {
spec.commandLine().getErr().println("Purge encountered errors during operation.");
return EXIT_CODE_PURGE_ERROR;
Expand Down