Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price url was not set, causing a null reference exception #189

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Commands/WhatIf/DevTestWhatIfCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public override async Task<int> ExecuteAsync(CommandContext context, WhatIfSetti
{
// Get the subscription ID from the settings
var subscriptionId = settings.Subscription;
_costRetriever.CostApiAddress = settings.CostApiAddress;
_priceRetriever.PriceApiAddress = settings.PriceApiAddress;

if (subscriptionId.HasValue == false && (settings.GetScope.IsSubscriptionBased))
{
Expand Down
1 change: 1 addition & 0 deletions src/Commands/WhatIf/RegionWhatIfCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public RegionWhatIfCommand(IPriceRetriever priceRetriever, ICostRetriever costRe
public override async Task<int> ExecuteAsync(CommandContext context, WhatIfSettings settings)
{
_costRetriever.CostApiAddress = settings.CostApiAddress;
_priceRetriever.PriceApiAddress = settings.PriceApiAddress;

// Get the subscription ID from the settings
var subscriptionId = settings.Subscription;
Expand Down
4 changes: 4 additions & 0 deletions src/Commands/WhatIf/WhatIfSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

[CommandOption("--filter")]
[Description("Filter the output by the specified properties. Defaults to no filtering and can be multiple values.")]
public string[] Filter { get; set; }

Check warning on line 66 in src/Commands/WhatIf/WhatIfSettings.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Non-nullable property 'Filter' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[CommandOption("-m|--metric")]
[Description("The metric to use for the costs. Defaults to ActualCost. (ActualCost, AmortizedCost)")]
Expand All @@ -74,6 +74,10 @@
[Description("The base address for the Cost API. Defaults to https://management.azure.com/")]
public string CostApiAddress { get; set; } = "https://management.azure.com/";

[CommandOption("--priceApiBaseAddress <BASE_ADDRESS>")]
[Description("The base address for the Price API. Defaults to https://prices.azure.com/")]
public string PriceApiAddress { get; set; } = "https://prices.azure.com/";

public Scope GetScope
{
get {
Expand Down
Loading