Skip to content

Commit

Permalink
feat(pulumi): Add pulumi (#834)
Browse files Browse the repository at this point in the history
* added pulumi support to show the stack name

* update symbol with a minor p

* changed color to 133 to make Pulumis color

* use pulumi commnad to fetch the active stack

* refactor(pulumi): Update to v4

* docs(pulumi): Add docs for pulumi

Co-authored-by: Chin <chin.tong@slalom.com>
Co-authored-by: Denys Dovhan <denysdovhan@gmail.com>
  • Loading branch information
3 people committed Nov 8, 2022
1 parent f4d85de commit 1ab9162
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/config/prompt.md
Expand Up @@ -75,6 +75,7 @@ SPACESHIP_PROMPT_ORDER=(
ocaml # OCaml section
kubectl # Kubectl context section
terraform # Terraform workspace section
pulumi # Pulumi stack section
ibmcloud # IBM Cloud section
exec_time # Execution time
async # Async jobs indicator
Expand Down
6 changes: 6 additions & 0 deletions docs/registry/internal.json
Expand Up @@ -318,6 +318,12 @@
"url": "https://spaceship-prompt.sh/sections/docker_compose",
"description": "Docker Compose services statuses.",
"internal": true
},
{
"name": "pulumi",
"url": "https://spaceship-prompt.sh/sections/pulumi",
"description": "The current Pulumi stack.",
"internal": true
}
]
}
24 changes: 24 additions & 0 deletions docs/sections/pulumi.md
@@ -0,0 +1,24 @@
# Pulumi (`pulumi`)

!!! important "This section is rendered asynchronously by default"

!!! info
[**Terraform**](https://www.pulumi.com/) is an infrastructure-as-code platform for full-stack developers.

The `pulumi` section shows Pulumi stack.

This section is only displayed when you have a `pulumi` command available and:

* Upsearch finds a `Pulumi.yaml` or `Pulumi.yml` file
* Upsearch finds a `.pulumi/stacks` file

## Options

| Variable | Default | Meaning |
| :------------------------ | :--------------------------------: | ----------------------------------- |
| `SPACESHIP_PULUMI_SHOW` | `true` | Show section |
| `SPACESHIP_PULUMI_ASYNC` | `true` | Render section asynchronously |
| `SPACESHIP_PULUMI_PREFIX` | `$SPACESHIP_PROMPT_DEFAULT_PREFIX` | Section's prefix |
| `SPACESHIP_PULUMI_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Section's suffix |
| `SPACESHIP_PULUMI_SYMBOL` | `🛠️·` | Symbol displayed before the section |
| `SPACESHIP_PULUMI_COLOR` | `133` | Section's color |
1 change: 1 addition & 0 deletions mkdocs.yml
Expand Up @@ -92,6 +92,7 @@ nav:
- OCaml (ocaml): sections/ocaml.md
- Kubernetes (kubectl): sections/kubectl.md
- Terraform (terraform): sections/terraform.md
- Pulumi (pulumi): sections/pulumi.md
- IBM Cloud (ibmcloud): sections/ibmcloud.md
- Nix Shell (nix-shell): sections/nix_shell.md
- Advanced:
Expand Down
43 changes: 43 additions & 0 deletions sections/pulumi.zsh
@@ -0,0 +1,43 @@
#
# Pulumi
#
# Pulumi automates the repetitive tasks of setting up cloud resources
# Link: https://www.pulumi.com/
#
# This section shows you the current stack and number of resources
# Link: https://www.pulumi.com/docs/intro/concepts/stack/

# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------

SPACESHIP_PULUMI_SHOW="${SPACESHIP_PULUMI_SHOW=true}"
SPACESHIP_PULUMI_ASYNC="${SPACESHIP_PULUMI_ASYNC=true}"
SPACESHIP_PULUMI_PREFIX="${SPACESHIP_PULUMI_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_PULUMI_SUFFIX="${SPACESHIP_PULUMI_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_PULUMI_SYMBOL="${SPACESHIP_PULUMI_SYMBOL=""}"
SPACESHIP_PULUMI_COLOR="${SPACESHIP_PULUMI_COLOR="133"}"

# ------------------------------------------------------------------------------
# Section
# ----------------------------------------------- -------------------------------

spaceship_pulumi() {
[[ $SPACESHIP_PULUMI_SHOW == false ]] && return

spaceship::exists pulumi || return

# Show PULUMI Stack when exists
local pulumi_project=$(spaceship::upsearch Pulumi.y*ml)
[[ -n "$pulumi_project" || -d .pulumi/stacks ]] || return

local pulumi_stack=$(pulumi stack ls 2>/dev/null | sed -n -e '2p' | cut -f1 -d" " | sed s/\*//)
[[ -z $pulumi_stack ]] && return

spaceship::section \
--color "$SPACESHIP_PULUMI_COLOR" \
--prefix "$SPACESHIP_PULUMI_PREFIX" \
--suffix "$SPACESHIP_PULUMI_SUFFIX" \
--symbol "$SPACESHIP_PULUMI_SYMBOL" \
"$pulumi_stack"
}
1 change: 1 addition & 0 deletions spaceship.zsh
Expand Up @@ -77,6 +77,7 @@ if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then
ocaml # OCaml section
kubectl # Kubectl context section
terraform # Terraform workspace section
pulumi # Pulumi stack section
ibmcloud # IBM Cloud section
nix_shell # Nix shell
exec_time # Execution time
Expand Down

0 comments on commit 1ab9162

Please sign in to comment.