diff --git a/src/segments/az.go b/src/segments/az.go index 45620ae37160..66c774ede150 100644 --- a/src/segments/az.go +++ b/src/segments/az.go @@ -33,15 +33,16 @@ type AzureConfig struct { } type AzureSubscription struct { - ID string `json:"id"` - Name string `json:"name"` - State string `json:"state"` - User *AzureUser `json:"user"` - IsDefault bool `json:"isDefault"` - TenantID string `json:"tenantId"` - EnvironmentName string `json:"environmentName"` - HomeTenantID string `json:"homeTenantId"` - ManagedByTenants []any `json:"managedByTenants"` + ID string `json:"id"` + Name string `json:"name"` + State string `json:"state"` + User *AzureUser `json:"user"` + IsDefault bool `json:"isDefault"` + TenantID string `json:"tenantId"` + TenantDisplayName string `json:"tenantDisplayName"` + EnvironmentName string `json:"environmentName"` + HomeTenantID string `json:"homeTenantId"` + ManagedByTenants []any `json:"managedByTenants"` } type AzureUser struct { @@ -66,7 +67,8 @@ type AzurePowerShellSubscription struct { } `json:"ExtendedProperties"` } `json:"Subscription"` Tenant struct { - ID string `json:"Id"` + ID string `json:"Id"` + Name string `json:"Name"` } `json:"Tenant"` } @@ -126,10 +128,12 @@ func (a *Az) getModuleSubscription() bool { if len(envSubscription) == 0 { return false } + var config AzurePowerShellSubscription if err := json.Unmarshal([]byte(envSubscription), &config); err != nil { return false } + a.IsDefault = true a.EnvironmentName = config.Environment.Name a.TenantID = config.Tenant.ID @@ -140,7 +144,10 @@ func (a *Az) getModuleSubscription() bool { Name: config.Subscription.ExtendedProperties.Account, Type: config.Account.Type, } + a.TenantDisplayName = config.Tenant.Name + a.Origin = "PWSH" + return true } diff --git a/website/docs/segments/cloud/az.mdx b/website/docs/segments/cloud/az.mdx index 000bd0bbd9da..3ddee8e9bb71 100644 --- a/website/docs/segments/cloud/az.mdx +++ b/website/docs/segments/cloud/az.mdx @@ -16,23 +16,25 @@ initializing Oh My Posh. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Default | Description | +| Name | Type | Default | Description | | -------- | :------: | :-----------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `source` | `string` | `first_match` | | @@ -48,18 +50,19 @@ import Config from '@site/src/components/Config.js'; ### Properties -| Name | Type | Description | -| ------------------ | --------- | -------------------------------------------------------------- | -| `.EnvironmentName` | `string` | Azure environment name | -| `.HomeTenantID` | `string` | home tenant id | -| `.ID` | `string` | subscription id | -| `.IsDefault` | `boolean` | is the default subscription or not | -| `.Name` | `string` | subscription name | -| `.State` | `string` | subscription 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` | +| Name | Type | Description | +| -------------------- | --------- | -------------------------------------------------------------- | +| `.EnvironmentName` | `string` | Azure environment name | +| `.HomeTenantID` | `string` | home tenant id | +| `.ID` | `string` | subscription id | +| `.IsDefault` | `boolean` | is the default subscription or not | +| `.Name` | `string` | subscription name | +| `.State` | `string` | subscription state | +| `.TenantID` | `string` | tenant id | +| `.TenantDisplayName` | `string` | tenant name | +| `.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/configuration/templates [az]: https://www.powershellgallery.com/packages/Az