Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Commit

Permalink
Print deleted secret info
Browse files Browse the repository at this point in the history
  • Loading branch information
Chloe Barker committed Feb 3, 2023
1 parent f58f8bc commit 156eab8
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion cli/src/main/java/keywhiz/cli/Printing.java
Expand Up @@ -161,10 +161,43 @@ public void printDeletedSecretsWithDetails(@Nullable List<SecretSeries> deletedS
int deletedCount = deletedSecrets == null ? 0 : deletedSecrets.size();
System.out.println(String.format("Deleted Secrets: found %d", deletedCount));
if (deletedSecrets != null) {
deletedSecrets.forEach(series -> this.printSecretWithDetails(series.id()));
deletedSecrets.forEach(series -> this.printDeletedSecretWithDetails(series));
}
}

private void printDeletedSecretWithDetails(SecretSeries secret) {
System.out.println(secret.name());

System.out.println(INDENT + "Internal ID:");
System.out.println(DOUBLE_INDENT + secret.id());

System.out.println(INDENT + "Owner:");
if (secret.owner() != null && !secret.owner().isEmpty()) {
System.out.println(DOUBLE_INDENT + secret.owner());
}

if (!secret.description().isEmpty()) {
System.out.println(INDENT + "Description:");
System.out.println(DOUBLE_INDENT + secret.description());
}

if (!secret.createdBy().isEmpty()) {
System.out.println(INDENT + "Created by:");
System.out.println(DOUBLE_INDENT + secret.createdBy());
}

System.out.println(INDENT + "Created at:");
System.out.println(DOUBLE_INDENT + apiDateToString(secret.createdAt()));

if (!secret.updatedBy().isEmpty()) {
System.out.println(INDENT + "Updated by:");
System.out.println(DOUBLE_INDENT + secret.updatedBy());
}

System.out.println(INDENT + "Updated at:");
System.out.println(DOUBLE_INDENT + apiDateToString(secret.updatedAt()));
}

public void printNonDeletedSecretWithDetails(@Nullable SanitizedSecret secret) {
if (secret == null) {
System.out.println("No non-deleted secret found.");
Expand Down

0 comments on commit 156eab8

Please sign in to comment.