Skip to content

Commit

Permalink
Adjustment in calculation algorithm to use secret with furthest out e…
Browse files Browse the repository at this point in the history
…xpiration date (#509)

* typo fix

* code gardening

* Fix to the calculation

* Bumping the minor version, as the Azure Service Principle watcher is basically done
  • Loading branch information
samsmithnz committed Aug 9, 2023
1 parent 41ab8df commit 3ccf7ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 36 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
next-version: 0.16.0
next-version: 0.17.0
9 changes: 5 additions & 4 deletions src/RepoGovernance.Core/Models/AzureAppRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ public string ExpirationDateString
{
get
{
DateTimeOffset? minDate = null;
DateTimeOffset? maxDate = null;
foreach (DateTimeOffset? item in ExpirationDates)
{
if (item != null && (minDate == null || item < minDate))
//Get the date furthest in the future
if (item != null && (maxDate == null || item > maxDate))
{
minDate = item;
maxDate = item;
}
}
return minDate;
return maxDate;
}
}

Expand Down
41 changes: 10 additions & 31 deletions src/RepoGovernance.Core/SummaryItemsDA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public static List<UserOwnerRepo> GetRepos(string user)
//Initialize the summary item
SummaryItem? summaryItem = new(user, owner, repo);

if (azureDeployment == null && connectionString != null)
{
//check to make sure there isn't data in the table already for Azure deployments, and pull it out to save it
SummaryItem? existingItem = await GetSummaryItem(connectionString, owner, repo);
if (existingItem != null && existingItem.AzureDeployment != null)
{
azureDeployment = existingItem.AzureDeployment;
}
}

try
{
//Get repo settings
Expand Down Expand Up @@ -329,37 +339,6 @@ public static List<UserOwnerRepo> GetRepos(string user)
}
}

//Get the Azure Deployment information
//AzureDeployment? azureDeployment = null;
//if (repo == "RepoGovernance")
//{
// azureDeployment = new()
// {
// DeployedURL = "https://repogovernance-prod-eu-web.azurewebsites.net/",
// AppRegistrations = new()
// {
// new AzureAppRegistration() { Name = "RepoGovernancePrincipal2023" },
// new AzureAppRegistration() { Name = "RepoGovernanceGraphAPIAccess" }
// }
// };
//}
//else if (repo == "DevOpsMetrics")
//{
// azureDeployment = new()
// {
// DeployedURL = "https://devops-prod-eu-web.azurewebsites.net//",
// AppRegistrations = new()
// {
// new AzureAppRegistration() { Name = "DeveloperMetricsOrgSP2023" },
// new AzureAppRegistration() { Name = "DevOpsMetrics" },
// new AzureAppRegistration() { Name = "DevOpsMetricsServicePrincipal2022" }
// }
// };
// if (summaryItem != null && azureDeployment != null)
// {
// summaryItem.AzureDeployment = azureDeployment;
// }
//}
//If there are azure deployment records, then process the summary item and save the detail
if (azureDeployment != null &&
azureTenantId != null &&
Expand Down

0 comments on commit 3ccf7ed

Please sign in to comment.