Skip to content

Commit 2cdb650

Browse files
author
Lee Fine
committed
ab#84816
1 parent 74c579f commit 2cdb650

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

GCPSecretManager/GCPClient.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ public SecretWithLabels GetCertificateEntry(string name)
9393
rtnValue.Labels = string.Empty;
9494

9595
Secret secret = GetSecret(name.Substring(name.LastIndexOf("/")+1));
96+
rtnValue.TTLDuration = secret.Ttl;
97+
rtnValue.VersionDestroyTTLDuration = secret.VersionDestroyTtl;
98+
99+
100+
if (secret.Replication != null && secret.Replication.UserManaged != null && secret.Replication.UserManaged.Replicas != null && secret.Replication.UserManaged.Replicas.Count > 0)
101+
{
102+
foreach (Replication.Types.UserManaged.Types.Replica replica in secret.Replication.UserManaged.Replicas)
103+
{
104+
rtnValue.ReplicationRegions += $",{replica.Location}";
105+
if (replica.CustomerManagedEncryption != null && !string.IsNullOrEmpty(replica.CustomerManagedEncryption.KmsKeyName))
106+
{
107+
rtnValue.ReplicationRegions += $":{replica.CustomerManagedEncryption.KmsKeyName}";
108+
}
109+
}
110+
111+
rtnValue.ReplicationRegions = rtnValue.ReplicationRegions.Substring(1);
112+
}
113+
96114
List<string> labelsString = new List<string>();
97115
foreach(var label in secret.Labels)
98116
{

GCPSecretManager/Inventory.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public JobResult ProcessJob(InventoryJobConfiguration config, SubmitInventoryUpd
7272
Dictionary<string, object> entryParameters = new()
7373
{
7474
{ "tags", secretTags },
75-
{ "labels", certificateEntry.Labels }
75+
{ "labels", certificateEntry.Labels },
76+
{ "replicationRegions", certificateEntry.ReplicationRegions },
77+
{ "ttlDuration", certificateEntry.TTLDuration?.ToTimeSpan().Days.ToString() },
78+
{ "versionDestroyTtlDuration", certificateEntry.VersionDestroyTTLDuration?.ToTimeSpan().Days.ToString() }
7679
};
7780

7881
inventoryItems.Add(new CurrentInventoryItem()

GCPSecretManager/Models.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Google.Cloud.ResourceManager.V3;
2+
using Google.Protobuf.WellKnownTypes;
23
using System.Collections.Generic;
34

45
namespace Keyfactor.Extensions.Orchestrator.GCPSecretManager
@@ -19,5 +20,8 @@ internal class SecretWithLabels
1920
{
2021
internal string Secret { get; set; }
2122
internal string Labels { get; set; }
23+
internal Duration TTLDuration { get; set; }
24+
internal Duration VersionDestroyTTLDuration { get; set; }
25+
internal string ReplicationRegions { get; set; }
2226
}
2327
}

0 commit comments

Comments
 (0)