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

[Eng]: Does Get-AzContext need to use dynamic parameters? #18041

Closed
isra-fel opened this issue May 5, 2022 · 1 comment · Fixed by #19655
Closed

[Eng]: Does Get-AzContext need to use dynamic parameters? #18041

isra-fel opened this issue May 5, 2022 · 1 comment · Fixed by #19655
Assignees
Labels
Accounts Issues in Az.Accounts except authentication related feature-request This issue requires a new behavior in the product in order be resolved.

Comments

@isra-fel
Copy link
Member

isra-fel commented May 5, 2022

Description

Problem

The -Name parameter of Get-AzContext is a dynamic parameter. It exists only when there are contexts available (code).

Get-AzContext [-DefaultProfile <IAzureContextContainer>] [[-Name] <String>] [<CommonParameters>]

It leads to instability in release process. The version bump up tool may have different results on different environments depending on whether there are contexts.

Action

We need to re-evaluate the necessity of defining -Name as a dynamic parameter, and if it's not worth it, change it to a normal one.

@isra-fel
Copy link
Member Author

isra-fel commented May 5, 2022

As of why the code is like this, my guess is we want to put a ValidateSet attribute on the Name parameter, but we also want the set to be dynamic, which is impossible unless Name is a dynamic parameter.
In fact, it can be rewritten as an ArgumentCompleter + dedicated validation logic. This way Name can be a normal parameter.

@dingmeng-xue dingmeng-xue added Accounts Issues in Az.Accounts except authentication related feature-request This issue requires a new behavior in the product in order be resolved. and removed Engineering labels May 12, 2022
@LucasYao93 LucasYao93 self-assigned this Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accounts Issues in Az.Accounts except authentication related feature-request This issue requires a new behavior in the product in order be resolved.
Projects
None yet
3 participants