feat(az): display info origin

resolves #1562
This commit is contained in:
Jan De Dobbeleer 2022-01-13 20:29:03 +01:00 committed by Jan De Dobbeleer
parent b1c427abaa
commit d45c51cccc
2 changed files with 17 additions and 0 deletions

View file

@ -11,6 +11,7 @@ type az struct {
env Environment
AzureSubscription
Origin string
}
type AzureConfig struct {
@ -123,6 +124,7 @@ func (a *az) getAzureProfile() bool {
for _, subscription := range config.Subscriptions {
if subscription.IsDefault {
a.AzureSubscription = *subscription
a.Origin = "CLI"
return true
}
}
@ -151,5 +153,6 @@ func (a *az) getAzureRmContext() bool {
a.User = &AzureUser{
Name: defaultContext.Subscription.ExtendedProperties.Account,
}
a.Origin = "PWSH"
return true
}

View file

@ -42,6 +42,20 @@ func TestAzSegment(t *testing.T) {
Template: "{{ .Burp }}",
HasPowerShell: true,
},
{
Case: "PWSH",
ExpectedEnabled: true,
ExpectedString: "PWSH",
Template: "{{ .Origin }}",
HasPowerShell: true,
},
{
Case: "CLI",
ExpectedEnabled: true,
ExpectedString: "CLI",
Template: "{{ .Origin }}",
HasCLI: true,
},
}
for _, tc := range cases {