-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add login
command
#74
base: main
Are you sure you want to change the base?
Conversation
f0202e9
to
c259af5
Compare
1. Check for the existence of `~/.azure`, which signals we're already logged in using some means. 2. Check the environment for a service principal as defined by the environment variables `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET`. 3. Check the `AZURE_CLIENT_ID` environment variable for the client ID of a user-assigned managed identity. 4. Use the system-assigned managed identity for the Azure resource if it's enabled. Signed-off-by: Leo Bergnéhr <[email protected]>
It think it would be beneficial to add some examples to the documentation showing the different ways to login |
func (c *LoginCommand) GetFlags() builder.Flags { | ||
flags := builder.Flags{} | ||
|
||
if _, err := os.Stat(filepath.Join(os.Getenv("HOME"), ".azure")); err == nil { |
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.
It would be great to document what files is needed, as a lot of file exist in the directory locally
if _, err := os.Stat(filepath.Join(os.Getenv("HOME"), ".azure")); err == nil { | ||
return flags | ||
} |
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.
Indentation doesn't match the rest of the file
} | ||
|
||
if os.Getenv("AZURE_CLIENT_ID") != "" && os.Getenv("AZURE_CLIENT_SECRET") != "" && os.Getenv("AZURE_TENANT_ID") != "" { | ||
// Add flags for service principal authentication |
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 version of the AZ CLI, v2.67.0, I have installed also requires the --service-principal
flag when logging in as a service principal, so it might depend on the AZ CLI version what is needed here.
As it is possible to choose the AZ CLI version to install, we should think about what to do with different versions (if they behave differently)
Closes #33.
~/.azure
, which signals we're alreadylogged in using some means.
environment variables
AZURE_CLIENT_ID
,AZURE_TENANT_ID
, andAZURE_CLIENT_SECRET
.AZURE_CLIENT_ID
environment variable for the client ID ofa user-assigned managed identity.
it's enabled.
.azure
directory.