-
Notifications
You must be signed in to change notification settings - Fork 538
[AzureBackup] Fix telemetry misclassification, improve error UX, add command-boundary validation #2880
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
base: main
Are you sure you want to change the base?
[AzureBackup] Fix telemetry misclassification, improve error UX, add command-boundary validation #2880
Changes from all commits
76b4af7
1b0b729
03804b0
8112a66
06b6221
eea4a5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.CommandLine.Parsing; | ||
| using System.Net; | ||
| using Azure.Mcp.Tools.AzureBackup.Models; | ||
| using Azure.Mcp.Tools.AzureBackup.Options; | ||
|
|
@@ -51,6 +52,31 @@ protected override void RegisterOptions(Command command) | |
| command.Options.Add(AzureBackupOptionDefinitions.AksExcludedNamespaces); | ||
| command.Options.Add(AzureBackupOptionDefinitions.AksLabelSelectors); | ||
| command.Options.Add(AzureBackupOptionDefinitions.AksIncludeClusterScopeResources); | ||
| command.Validators.Add(commandResult => | ||
| { | ||
| OptionResult? optionResult = commandResult.GetResult(AzureBackupOptionDefinitions.DatasourceType); | ||
| if (optionResult is null || optionResult.Implicit) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var value = optionResult.Tokens.LastOrDefault()?.Value ?? string.Empty; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the type is |
||
| var normalizedValue = value.Trim(); | ||
|
|
||
| if (string.IsNullOrEmpty(normalizedValue) || | ||
| RsvDatasourceRegistry.Resolve(normalizedValue) is null && | ||
| DppDatasourceRegistry.TryAutoDetect(normalizedValue) is null && | ||
| !DppDatasourceRegistry.AllProfiles.Any(p => | ||
| p.FriendlyName.Equals(normalizedValue, StringComparison.OrdinalIgnoreCase) || | ||
| p.ArmResourceType.Equals(normalizedValue, StringComparison.OrdinalIgnoreCase) || | ||
| p.Aliases.Any(a => a.Equals(normalizedValue, StringComparison.OrdinalIgnoreCase)))) | ||
|
Comment on lines
+68
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why doesn't
Comment on lines
+66
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should take into account |
||
| { | ||
| commandResult.AddError( | ||
| $"Unknown datasource type '{value}'. " + | ||
| $"RSV types: {string.Join(", ", RsvDatasourceRegistry.KnownTypeNames)}. " + | ||
| $"DPP types: {string.Join(", ", DppDatasourceRegistry.KnownTypeNames)}."); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected override ProtectedItemProtectOptions BindOptions(ParseResult parseResult) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Implicitdoesn't really do much here as the option was optional without a default value. So nullness checking is already handling implicit checking.