mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
feat(az): add tenant name
This commit is contained in:
parent
415d310c69
commit
fb9d447c87
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
||||
<Config data={{
|
||||
"type": "az",
|
||||
"style": "powerline",
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"foreground": "#000000",
|
||||
"background": "#9ec3f0",
|
||||
"template": " \uebd8 {{ .EnvironmentName }}",
|
||||
"properties": {
|
||||
"source": "pwsh"
|
||||
}
|
||||
}}/>
|
||||
<Config
|
||||
data={{
|
||||
type: "az",
|
||||
style: "powerline",
|
||||
powerline_symbol: "\uE0B0",
|
||||
foreground: "#000000",
|
||||
background: "#9ec3f0",
|
||||
template: " \uebd8 {{ .EnvironmentName }}",
|
||||
properties: {
|
||||
source: "pwsh",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| Name | Type | Default | Description |
|
||||
| -------- | :------: | :-----------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `source` | `string` | `first_match` | <ul><li>`first_match`: try the CLI config first, then the PowerShell module. The first to resolve is displayed</li><li>`cli`: fetch the information from the CLI config</li><li>`pwsh`: fetch the information from the PowerShell Module config</li></ul> |
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue