mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 12:29:40 -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 {
|
type AzureSubscription struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
User *AzureUser `json:"user"`
|
User *AzureUser `json:"user"`
|
||||||
IsDefault bool `json:"isDefault"`
|
IsDefault bool `json:"isDefault"`
|
||||||
TenantID string `json:"tenantId"`
|
TenantID string `json:"tenantId"`
|
||||||
EnvironmentName string `json:"environmentName"`
|
TenantDisplayName string `json:"tenantDisplayName"`
|
||||||
HomeTenantID string `json:"homeTenantId"`
|
EnvironmentName string `json:"environmentName"`
|
||||||
ManagedByTenants []any `json:"managedByTenants"`
|
HomeTenantID string `json:"homeTenantId"`
|
||||||
|
ManagedByTenants []any `json:"managedByTenants"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AzureUser struct {
|
type AzureUser struct {
|
||||||
|
@ -66,7 +67,8 @@ type AzurePowerShellSubscription struct {
|
||||||
} `json:"ExtendedProperties"`
|
} `json:"ExtendedProperties"`
|
||||||
} `json:"Subscription"`
|
} `json:"Subscription"`
|
||||||
Tenant struct {
|
Tenant struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
|
Name string `json:"Name"`
|
||||||
} `json:"Tenant"`
|
} `json:"Tenant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +128,12 @@ func (a *Az) getModuleSubscription() bool {
|
||||||
if len(envSubscription) == 0 {
|
if len(envSubscription) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var config AzurePowerShellSubscription
|
var config AzurePowerShellSubscription
|
||||||
if err := json.Unmarshal([]byte(envSubscription), &config); err != nil {
|
if err := json.Unmarshal([]byte(envSubscription), &config); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
a.IsDefault = true
|
a.IsDefault = true
|
||||||
a.EnvironmentName = config.Environment.Name
|
a.EnvironmentName = config.Environment.Name
|
||||||
a.TenantID = config.Tenant.ID
|
a.TenantID = config.Tenant.ID
|
||||||
|
@ -140,7 +144,10 @@ func (a *Az) getModuleSubscription() bool {
|
||||||
Name: config.Subscription.ExtendedProperties.Account,
|
Name: config.Subscription.ExtendedProperties.Account,
|
||||||
Type: config.Account.Type,
|
Type: config.Account.Type,
|
||||||
}
|
}
|
||||||
|
a.TenantDisplayName = config.Tenant.Name
|
||||||
|
|
||||||
a.Origin = "PWSH"
|
a.Origin = "PWSH"
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,23 +16,25 @@ initializing Oh My Posh.
|
||||||
|
|
||||||
## Sample Configuration
|
## Sample Configuration
|
||||||
|
|
||||||
import Config from '@site/src/components/Config.js';
|
import Config from "@site/src/components/Config.js";
|
||||||
|
|
||||||
<Config data={{
|
<Config
|
||||||
"type": "az",
|
data={{
|
||||||
"style": "powerline",
|
type: "az",
|
||||||
"powerline_symbol": "\uE0B0",
|
style: "powerline",
|
||||||
"foreground": "#000000",
|
powerline_symbol: "\uE0B0",
|
||||||
"background": "#9ec3f0",
|
foreground: "#000000",
|
||||||
"template": " \uebd8 {{ .EnvironmentName }}",
|
background: "#9ec3f0",
|
||||||
"properties": {
|
template: " \uebd8 {{ .EnvironmentName }}",
|
||||||
"source": "pwsh"
|
properties: {
|
||||||
}
|
source: "pwsh",
|
||||||
}}/>
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
## Properties
|
## 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> |
|
| `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
|
### Properties
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------------ | --------- | -------------------------------------------------------------- |
|
| -------------------- | --------- | -------------------------------------------------------------- |
|
||||||
| `.EnvironmentName` | `string` | Azure environment name |
|
| `.EnvironmentName` | `string` | Azure environment name |
|
||||||
| `.HomeTenantID` | `string` | home tenant id |
|
| `.HomeTenantID` | `string` | home tenant id |
|
||||||
| `.ID` | `string` | subscription id |
|
| `.ID` | `string` | subscription id |
|
||||||
| `.IsDefault` | `boolean` | is the default subscription or not |
|
| `.IsDefault` | `boolean` | is the default subscription or not |
|
||||||
| `.Name` | `string` | subscription name |
|
| `.Name` | `string` | subscription name |
|
||||||
| `.State` | `string` | subscription state |
|
| `.State` | `string` | subscription state |
|
||||||
| `.TenantID` | `string` | tenant id |
|
| `.TenantID` | `string` | tenant id |
|
||||||
| `.User.Name` | `string` | user name |
|
| `.TenantDisplayName` | `string` | tenant name |
|
||||||
| `.User.Type` | `string` | user type |
|
| `.User.Name` | `string` | user name |
|
||||||
| `.Origin` | `string` | where we received the information from, can be `CLI` or `PWSH` |
|
| `.User.Type` | `string` | user type |
|
||||||
|
| `.Origin` | `string` | where we received the information from, can be `CLI` or `PWSH` |
|
||||||
|
|
||||||
[templates]: /docs/configuration/templates
|
[templates]: /docs/configuration/templates
|
||||||
[az]: https://www.powershellgallery.com/packages/Az
|
[az]: https://www.powershellgallery.com/packages/Az
|
||||||
|
|
Loading…
Reference in a new issue