This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 8e932e618d7 camel-aws - Add dev console for AWS secrets
8e932e618d7 is described below

commit 8e932e618d7801416d2c7856db2381a52fe7129a
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Sep 7 20:41:15 2022 +0200

    camel-aws - Add dev console for AWS secrets
---
 .../aws/secretsmanager/SecretsDevConsole.java      | 25 +++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsDevConsole.java
 
b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsDevConsole.java
index ba5171db120..47f6181122c 100644
--- 
a/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsDevConsole.java
+++ 
b/components/camel-aws/camel-aws-secrets-manager/src/main/java/org/apache/camel/component/aws/secretsmanager/SecretsDevConsole.java
@@ -17,6 +17,9 @@
 package org.apache.camel.component.aws.secretsmanager;
 
 import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.ExtendedCamelContext;
@@ -34,7 +37,7 @@ import org.apache.camel.vault.AwsVaultConfiguration;
 public class SecretsDevConsole extends AbstractDevConsole {
 
     private SecretsManagerPropertiesFunction propertiesFunction;
-    private CloudTrailReloadTriggerTask secretsRefreshTask; // TODO:
+    private CloudTrailReloadTriggerTask secretsRefreshTask;
 
     public SecretsDevConsole() {
         super("camel", "aws-secrets", "AWS Secrets", "AWS Secrets Manager");
@@ -78,7 +81,11 @@ public class SecretsDevConsole extends AbstractDevConsole {
                 sb.append(String.format("\n    Last Check: %s", s));
             }
             sb.append("\n\nSecrets in use:");
-            for (String sec : propertiesFunction.getSecrets()) {
+
+            List<String> sorted = new 
ArrayList<>(propertiesFunction.getSecrets());
+            Collections.sort(sorted);
+
+            for (String sec : sorted) {
                 Instant last = secretsRefreshTask != null ? 
secretsRefreshTask.getUpdates().get(sec) : null;
                 String age = last != null ? 
TimeUtils.printSince(last.toEpochMilli()) : null;
                 if (age != null) {
@@ -107,9 +114,21 @@ public class SecretsDevConsole extends AbstractDevConsole {
                 root.put("refreshEnabled", aws.isRefreshEnabled());
                 root.put("refreshPeriod", aws.getRefreshPeriod());
             }
+            if (secretsRefreshTask != null) {
+                Instant last = secretsRefreshTask.getLastCheckTime();
+                if (last != null) {
+                    long timestamp = last.toEpochMilli();
+                    root.put("lastCheckTimestamp", timestamp);
+                    root.put("lastCheckAge", TimeUtils.printSince(timestamp));
+                }
+            }
             JsonArray arr = new JsonArray();
             root.put("secrets", arr);
-            for (String sec : propertiesFunction.getSecrets()) {
+
+            List<String> sorted = new 
ArrayList<>(propertiesFunction.getSecrets());
+            Collections.sort(sorted);
+
+            for (String sec : sorted) {
                 JsonObject jo = new JsonObject();
                 jo.put("name", sec);
                 Instant last = secretsRefreshTask != null ? 
secretsRefreshTask.getUpdates().get(sec) : null;

Reply via email to