Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AzureRm) Adds a basic Azure Powershell module. #5910

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
43 changes: 43 additions & 0 deletions .github/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
}
]
},
"azurerm": {
"default": {
"disabled": false,
"format": "on [$symbol($subscription)]($style) ",
"style": "blue bold",
"subscription_aliases": {},
"symbol": "󰠅 "
},
"allOf": [
{
"$ref": "#/definitions/AzureRMConfig"
}
]
},
"battery": {
"default": {
"charging_symbol": "󰂄 ",
Expand Down Expand Up @@ -1979,6 +1993,35 @@
},
"additionalProperties": false
},
"AzureRMConfig": {
"type": "object",
"properties": {
"format": {
"default": "on [$symbol($subscription)]($style) ",
"type": "string"
},
"symbol": {
"default": "󰠅 ",
"type": "string"
},
"style": {
"default": "blue bold",
"type": "string"
},
"disabled": {
"default": false,
"type": "boolean"
},
"subscription_aliases": {
"default": {},
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"additionalProperties": false
},
"BatteryConfig": {
"type": "object",
"properties": {
Expand Down
49 changes: 49 additions & 0 deletions docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,55 @@ style = "blue bold"
very-long-subscription-name = 'vlsn'
```

## AzureRM

The `azurerm` module shows the current Azure Subscription for the AzureRM and Az PowerShell module(s). This is based on showing the name of the default subscription or the username, as defined in the `~/.azurerm/AzureRm_Context.json` file.

### Options

| Variable | Default | Description |
| ---------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------- |
| `format` | `'on [$symbol($subscription)]($style) '` | The format for the Azure module to render. |
| `symbol` | `'󰠅 '` | The symbol used in the format. |
| `style` | `'blue bold'` | The style used in the format. |
| `disabled` | `true` | Disables the `azurerm` module. |
| `subscription_aliases` | `{}` | Table of subscription name aliases to display in addition to Azure subscription name. |

### Examples

#### Display Subscription Name

```toml
# ~/.config/starship.toml

[azurerm]
disabled = false
format = 'on [$symbol($subscription)]($style) '
symbol = '󰠅 '
style = 'blue bold'
```

#### Display Username

```toml
# ~/.config/starship.toml

[azurerm]
disabled = false
format = "on [$symbol($username)]($style) "
symbol = "󰠅 "
style = "blue bold"
```

#### Display Subscription Name Alias

```toml
# ~/.config/starship.toml

[azurerm.subscription_aliases]
very-long-subscription-name = 'vlsn'
```

## Battery

The `battery` module shows how charged the device's battery is and its current charging status.
Expand Down
29 changes: 29 additions & 0 deletions src/configs/azurerm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct AzureRMConfig<'a> {
pub format: &'a str,
pub symbol: &'a str,
pub style: &'a str,
pub disabled: bool,
pub subscription_aliases: HashMap<String, &'a str>,
}

impl<'a> Default for AzureRMConfig<'a> {
fn default() -> Self {
AzureRMConfig {
format: "on [$symbol($subscription)]($style) ",
symbol: "󰠅 ",
style: "blue bold",
disabled: false,
subscription_aliases: HashMap::new(),
}
}
}
3 changes: 3 additions & 0 deletions src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{self, Deserialize, Serialize};

pub mod aws;
pub mod azure;
pub mod azurerm;
pub mod battery;
pub mod buf;
pub mod bun;
Expand Down Expand Up @@ -115,6 +116,8 @@ pub struct FullConfig<'a> {
#[serde(borrow)]
azure: azure::AzureConfig<'a>,
#[serde(borrow)]
azurerm: azurerm::AzureRMConfig<'a>,
#[serde(borrow)]
battery: battery::BatteryConfig<'a>,
#[serde(borrow)]
buf: buf::BufConfig<'a>,
Expand Down
1 change: 1 addition & 0 deletions src/configs/starship_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub const PROMPT_ORDER: &[&str] = &[
"gcloud",
"openstack",
"azure",
"azurerm",
"direnv",
"env_var",
"crystal",
Expand Down
1 change: 1 addition & 0 deletions src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::time::Duration;
pub const ALL_MODULES: &[&str] = &[
"aws",
"azure",
"azurerm",
#[cfg(feature = "battery")]
"battery",
"buf",
Expand Down