Skip to content

Commit

Permalink
Fix for outputting empty resource group names
Browse files Browse the repository at this point in the history
  • Loading branch information
mivano committed May 21, 2023
1 parent c53bec0 commit 28cb1eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Commands/CostSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public class CostSettings : LogCommandSettings
public int OthersCutoff { get; set; } = 10;

[CommandOption("--query")]
[Description("JMESPath query string. See http://jmespath.org/ for more information and examples.")]
[Description("JMESPath query string, applicable for the Json output only. See http://jmespath.org/ for more information and examples.")]
public string Query { get; set; } = string.Empty;
}
9 changes: 6 additions & 3 deletions src/OutputFormatters/MarkdownOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public override Task WriteAccumulatedCost(AccumulatedCostSettings settings,Accum
Console.WriteLine(" title Cost by service");
foreach (var cost in accumulatedCostDetails.ByServiceNameCosts.TrimList(threshold: settings.OthersCutoff))
{
Console.WriteLine($" \"{cost.ItemName}\" : {cost.Cost.ToString("F2", culture)}");
var name = string.IsNullOrWhiteSpace(cost.ItemName) ? "(Unknown)" : cost.ItemName;
Console.WriteLine($" \"{name}\" : {cost.Cost.ToString("F2", culture)}");
}
Console.WriteLine("```");

Expand All @@ -110,7 +111,8 @@ public override Task WriteAccumulatedCost(AccumulatedCostSettings settings,Accum
Console.WriteLine(" title Cost by location");
foreach (var cost in accumulatedCostDetails.ByLocationCosts.TrimList(threshold: settings.OthersCutoff))
{
Console.WriteLine($" \"{cost.ItemName}\" : {cost.Cost.ToString("F2", culture)}");
var name = string.IsNullOrWhiteSpace(cost.ItemName) ? "(Unknown)" : cost.ItemName;
Console.WriteLine($" \"{name}\" : {cost.Cost.ToString("F2", culture)}");
}
Console.WriteLine("```");

Expand All @@ -131,7 +133,8 @@ public override Task WriteAccumulatedCost(AccumulatedCostSettings settings,Accum
Console.WriteLine(" title Cost by resource group");
foreach (var cost in accumulatedCostDetails.ByResourceGroupCosts.TrimList(threshold: settings.OthersCutoff))
{
Console.WriteLine($" \"{cost.ItemName}\" : {cost.Cost.ToString("F2", culture)}");
var name = string.IsNullOrWhiteSpace(cost.ItemName) ? "(Unknown)" : cost.ItemName;
Console.WriteLine($" \"{name}\" : {cost.Cost.ToString("F2", culture)}");
}
Console.WriteLine("```");

Expand Down

0 comments on commit 28cb1eb

Please sign in to comment.