feat(az): add user type

resolves #1957
This commit is contained in:
Jan De Dobbeleer 2022-03-21 16:05:23 +01:00 committed by Jan De Dobbeleer
parent 744764a05e
commit f4fa7a4166
4 changed files with 19 additions and 8 deletions

View file

@ -42,14 +42,15 @@ Display the currently active Azure subscription information.
### Properties
- `.EnvironmentName`: `string` - the account environment name
- `.HomeTenantID`: `string` - the home tenant id
- `.ID`: `string` - the account/subscription id
- `.EnvironmentName`: `string` - account environment name
- `.HomeTenantID`: `string` - home tenant id
- `.ID`: `string` - account/subscription id
- `.IsDefault`: `boolean` - is the default account or not
- `.Name`: `string` - the account name
- `.State`: `string` - the account state
- `.TenantID`: `string` - the tenant id
- `.User.Name`: `string` - the user name
- `.Name`: `string` - account name
- `.State`: `string` - account state
- `.TenantID`: `string` - tenant id
- `.User.Name`: `string` - user name
- `.User.Type`: `string` - user type
- `.Origin`: `string` - where we received the information from, can be `CLI` or `PWSH`
[templates]: /docs/config-templates

View file

@ -43,6 +43,7 @@ type AzureSubscription struct {
type AzureUser struct {
Name string `json:"name"`
Type string `json:"type"`
}
type AzurePowerShellConfig struct {
@ -166,6 +167,7 @@ func (a *Az) getModuleSubscription() bool {
a.State = defaultContext.Subscription.State
a.User = &AzureUser{
Name: defaultContext.Subscription.ExtendedProperties.Account,
Type: defaultContext.Account.Type,
}
a.Origin = "PWSH"
return true

View file

@ -97,6 +97,14 @@ func TestAzSegment(t *testing.T) {
Template: "{{ .EnvironmentName }}",
Source: pwsh,
},
{
Case: "Az CLI account type",
ExpectedEnabled: true,
ExpectedString: "user",
Template: "{{ .User.Type }}",
HasCLI: true,
Source: cli,
},
}
for _, tc := range cases {

View file

@ -5,7 +5,7 @@
"My Azure Subscription (subscription_id) - tenant_id - user_name": {
"Account": {
"Id": "232-232-232-232",
"Type": "User",
"Type": "user",
"TenantMap": {},
"ExtendedProperties": {
"Subscriptions": "subscription_ids",