Skip to content

Commit 208794b

Browse files
authored
Expose more configuration for PromptResourceGroup (#6583)
Adds support for PromptResourceGroupOptions in the PromptResourceGroup gRPC API, enabling extensions to customize the resource group selection experience (e.g., hide/show "Create new resource group" option).
1 parent f7fa60b commit 208794b

File tree

7 files changed

+791
-57
lines changed

7 files changed

+791
-57
lines changed

cli/azd/.vscode/cspell.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ words:
88
- Canonicalize
99
- Chans
1010
- chinacloudapi
11+
- cmds
1112
- Codespace
1213
- Codespaces
1314
- cooldown

cli/azd/extensions/microsoft.azd.demo/internal/cmd/prompt.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ func newPromptCommand() *cobra.Command {
204204
Prompt().
205205
PromptResourceGroup(ctx, &azdext.PromptResourceGroupRequest{
206206
AzureContext: &azureContext,
207+
Options: &azdext.PromptResourceGroupOptions{
208+
SelectOptions: &azdext.PromptResourceSelectOptions{
209+
AllowNewResource: to.Ptr(false),
210+
},
211+
},
207212
})
208213
if err != nil {
209214
return err

cli/azd/grpc/proto/prompt.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ message PromptLocationResponse {
5656

5757
message PromptResourceGroupRequest {
5858
AzureContext azure_context = 1;
59+
PromptResourceGroupOptions options = 2;
5960
}
6061

6162
message PromptResourceGroupResponse {
@@ -182,4 +183,10 @@ message PromptResourceSelectOptions {
182183
string loading_message = 7;
183184
optional bool display_numbers = 8;
184185
int32 display_count = 9;
186+
string hint = 10;
187+
optional bool enable_filtering = 11;
188+
}
189+
190+
message PromptResourceGroupOptions {
191+
PromptResourceSelectOptions select_options = 1;
185192
}

cli/azd/internal/grpcserver/prompt_service.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ func (s *promptService) PromptResourceGroup(
289289
return nil, err
290290
}
291291

292-
selectedResourceGroup, err := s.prompter.PromptResourceGroup(ctx, azureContext, nil)
292+
options := createResourceGroupOptions(req.Options)
293+
294+
selectedResourceGroup, err := s.prompter.PromptResourceGroup(ctx, azureContext, options)
293295
if err != nil {
294296
return nil, err
295297
}
@@ -418,6 +420,8 @@ func createResourceOptions(options *azdext.PromptResourceOptions) prompt.Resourc
418420
DisplayCount: int(options.SelectOptions.DisplayCount),
419421
DisplayNumbers: options.SelectOptions.DisplayNumbers,
420422
AllowNewResource: options.SelectOptions.AllowNewResource,
423+
Hint: options.SelectOptions.Hint,
424+
EnableFiltering: options.SelectOptions.EnableFiltering,
421425
}
422426
}
423427

@@ -431,6 +435,27 @@ func createResourceOptions(options *azdext.PromptResourceOptions) prompt.Resourc
431435
return resourceOptions
432436
}
433437

438+
func createResourceGroupOptions(options *azdext.PromptResourceGroupOptions) *prompt.ResourceGroupOptions {
439+
if options == nil || options.SelectOptions == nil {
440+
return nil
441+
}
442+
443+
return &prompt.ResourceGroupOptions{
444+
SelectorOptions: &prompt.SelectOptions{
445+
ForceNewResource: options.SelectOptions.ForceNewResource,
446+
AllowNewResource: options.SelectOptions.AllowNewResource,
447+
NewResourceMessage: options.SelectOptions.NewResourceMessage,
448+
Message: options.SelectOptions.Message,
449+
HelpMessage: options.SelectOptions.HelpMessage,
450+
LoadingMessage: options.SelectOptions.LoadingMessage,
451+
DisplayCount: int(options.SelectOptions.DisplayCount),
452+
DisplayNumbers: options.SelectOptions.DisplayNumbers,
453+
Hint: options.SelectOptions.Hint,
454+
EnableFiltering: options.SelectOptions.EnableFiltering,
455+
},
456+
}
457+
}
458+
434459
func convertToInt32(input *int) *int32 {
435460
if input == nil {
436461
return nil // Handle the nil case

0 commit comments

Comments
 (0)