Skip to content

Commit

Permalink
chore: update demo and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Dec 23, 2024
1 parent 134e53e commit ebd073e
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 134 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ install-infracost:
curl -L https://github.com/infracost/infracost/releases/download/v0.10.38/infracost-linux-amd64.tar.gz | tar -zxf -
mv infracost-linux-amd64 ~/.local/bin/infracost
chmod +x ~/.local/bin/infracost

.PHONY: demo
demo:
vhs demo/vhs.tape
109 changes: 44 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ FLAGS
--data-dir STRING Directory in which to store plan files. (default: /home/louis/.pug)
-e, --env STRING Environment variable to pass to terraform process. Can set more than once.
-a, --arg STRING CLI arg to pass to terraform process. Can set more than once.
-f, --first-page STRING The first page to open on startup. (default: modules)
-d, --debug Log bubbletea messages to messages.log
-v, --version Print version.
-c, --config STRING Path to config file. (default: /home/louis/.pug.yaml)
Expand All @@ -84,55 +83,40 @@ max-tasks: 100
Pug automatically loads variables from a .tfvars file. It looks for a file named `<workspace>.tfvars` in the module directory, where `<workspace>` is the name of the workspace. For example, if the workspace is named `dev` then it'll look for `dev.tfvars`. If the file exists then it'll pass the name to `terraform plan`, e.g. for a workspace named `dev`, it'll invoke `terraform plan -vars-file=dev.tfvars`.

## Pages
## Panes

### Modules
### Explorer

![Modules screenshot](./demo/modules.png)

Press `m` to go to the modules page.

*Note: what Pug calls a module is equivalent to a [root module](https://developer.hashicorp.com/terraform/language/modules#the-root-module), i.e. a directory containing terraform configuration, including a state backend. It is not to be confused with a [child module](https://developer.hashicorp.com/terraform/language/modules#child-modules).*

#### Key bindings

| Key | Description | Multi-select |
|--|--|--|
|`i`|Run `terraform init`|&check;|
|`u`|Run `terraform init -upgrade`|&check;|
|`f`|Run `terraform fmt`|&check;|
|`v`|Run `terraform validate`|&check;|
|`p`|Run `terraform plan`|&check;|
|`P`|Run `terraform plan -destroy`|&check;|
|`a`|Run `terraform apply`|&check;|
|`d`|Run `terraform apply -destroy`|&check;|
|`e`|Open module in editor|&cross;|
|`x`|Run any program|&check;|
|`Ctrl+r`|Reload all modules|-|
|`Ctrl+w`|Reload module's workspaces|&check;|

### Workspaces
The explorer pane a tree of [modules](#module) and [workspaces](#workspace) discovered on your filesystem. From here, terraform commands can be carried out on both modules and workspaces.

![Workspaces screenshot](./demo/workspaces.png)
You can select multiple modules or workspaces; you cannot select a combination of the two. Any terraform commands are then carried out on the selection.

Press `w` to go to the workspaces page.

*Note: A workspace is directly equivalent to a [terraform workspace](https://developer.hashicorp.com/terraform/language/state/workspaces).*
The number of resources in the state is shown alongside the workspace.

![Modules screenshot](./demo/modules.png)

#### Key bindings

| Key | Description | Multi-select |
|--|--|--|
|`i`|Run `terraform init`|&check;|
|`u`|Run `terraform init -upgrade`|&check;|
|`f`|Run `terraform fmt`|&check;|
|`v`|Run `terraform validate`|&check;|
|`p`|Run `terraform plan`|&check;|
|`P`|Run `terraform plan -destroy`|&check;|
|`a`|Run `terraform apply`|&check;|
|`d`|Run `terraform apply -destroy`|&check;|
|`C`|Run `terraform workspace select`|&cross;|
|`$`|Run `infracost breakdown`|&check;|
| Key | Description | Multi-select | Module | Workspace |
|--|--|--|--|--|
|`i`|Run `terraform init`|&check;|&check;|&check;\*\*|
|`u`|Run `terraform init -upgrade`|&check;|&check;\*\*|
|`f`|Run `terraform fmt`|&check;|&check;|&check;\*\*|
|`v`|Run `terraform validate`|&check;|&check;|&check;\*\*|
|`p`|Run `terraform plan`|&check;|&check;\*|&check;|
|`P`|Run `terraform plan -destroy`|&check;\*|&check;|&check;|
|`a`|Run `terraform apply`|&check;|&check;\*|&check;|
|`d`|Run `terraform apply -destroy`|&check;\*|&check;|&check;|
|`C`|Run `terraform workspace select`|&cross;|&cross;|&check;|
|`$`|Run `infracost breakdown`|&check;|&check;\*|&check;|
|`E`|Open module in editor|&cross;|&check;|&check;\*\*|
|`x`|Run any program|&check;|&check;|&check;\*\*|
|`Ctrl+r`|Reload all modules|-|&check;|&check;|
|`Ctrl+w`|Reload module's workspaces|&check;|&check;|&check;\*\*|

\* Operate on module's current workspace.

\*\* Operate on workspace's parent module.

### State

Expand All @@ -149,14 +133,10 @@ Press `s` to go to the state page, listing a workspace's resources.
|`a`|Run `terraform apply -target`|&check;|
|`d`|Run `terraform apply -destroy -target`|&check;|
|`D`|Run `terraform state rm`|&check;|
|`M`|Run `terraform state mv`|&cross;|
|`m`|Run `terraform state mv`|&cross;|
|`Ctrl+t`|Run `terraform taint`|&check;|
|`U`|Run `terraform untaint`|&check;|
|`Ctrl+r`|Run `terraform state pull`|-|
|`S`|Toggle split screen|-|
|`+`|Increase split screen top pane|-|
|`-`|Decrease split screen top pane|-|
|`tab`|Switch split screen pane focus|-|

### Tasks

Expand All @@ -170,11 +150,6 @@ Press `t` to go to the tasks page.
|--|--|--|
|`c`|Cancel task|&check;|
|`r`|Retry task|&check;|
|`Enter`|Full screen task output|&cross;|
|`S`|Toggle split screen|-|
|`+`|Increase split screen top pane|-|
|`-`|Decrease split screen top pane|-|
|`tab`|Switch split screen pane focus|-|
|`I`|Toggle task info sidebar|-|

### Task Group
Expand All @@ -189,11 +164,6 @@ Creating multiple tasks, via a selection, creates a task group, and takes you to
|--|--|--|
|`c`|Cancel task|&check;|
|`r`|Retry task|&check;|
|`Enter`|Full screen task output|&cross;|
|`S`|Toggle split screen|-|
|`+`|Increase split screen top pane|-|
|`-`|Decrease split screen top pane|-|
|`tab`|Switch split screen pane focus|-|
|`I`|Toggle task info sidebar|-|

### Task Groups Listing
Expand All @@ -218,16 +188,25 @@ These keys are valid on any page.
|--|--|
|`?`|Open help pane|
|`Ctrl+c`|Quit|
|`Esc`|Go to previous page|
|`m`|Go to modules page|
|`w`|Go to workspaces page|
|`s`|Go to state page\*|
|`t`|Go to tasks page|
|`T`|Go to task groups page|
|`Esc`|Go to previous page\*\*|
|`0`|Focus left pane (explorer)|
|`1`|Focus top right pane|
|`2`|Focus bottom right pane|
|`e`|Go to explorer|
|`s`|Go to state \*|
|`t`|Go to tasks|
|`T`|Go to task groups|
|`l`|Go to logs|
|`X`|Close pane|
|`+`|Increase pane height|-|
|`-`|Decrease pane height|-|
|`<`|Increase pane width|-|
|`>`|Decrease pane width|-|
|`tab`|Switch split screen pane focus|-|
|`Ctrl+s`|Toggle auto-scrolling of terraform output|

\* Only where the workspace can be ascertained.
\*\* Only history for the top right pane is maintained.

### Selections

Expand All @@ -254,7 +233,7 @@ Items can be filtered to those containing a sub-string.

### Navigation

Common vim key bindings are supported for navigation.
Common vim key bindings are supported for navigating task output.

| Key | Description |
|--|--|
Expand Down
Binary file modified demo/asdf_install_terraform_task_group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/execute_asdf_install_terraform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/infracost_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/modules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/task_group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/task_groups.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 46 additions & 36 deletions demo/vhs.tape
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
Output demo/demo.gif

Require terraform
Require infracost
Require asdf

Set Shell "bash"
Set FontSize 14
Set Width 1200
Set Height 800
Set Framerate 24
Set Padding 5
Set FontFamily "JetBrainsMono Nerd Font"

# Clear any leftover artefacts from last demo
Hide
Type `TF_CLI_CONFIG_FILE=$PWD/mirror/mirror.tfrc go run main.go -w demo/dont_cost_money` Enter
Type@1ms "asdf uninstall terraform" Enter
Type@1ms "find demo/ -name .terraform -exec rm -rf {} \; > /dev/null 2>&1 || true" Enter
Type@1ms "find demo/ -name terraform.tfstate -exec rm {} \; > /dev/null 2>&1 || true" Enter
Type@1ms "find demo/ -name terraform.tfstate.* -exec rm {} \; > /dev/null 2>&1 || true" Enter
Type@1ms "find demo/ -name .terraform.lock.hcl -exec rm {} \; > /dev/null 2>&1 || true" Enter
Type@1ms "find demo/ -name environment -exec rm {} \; > /dev/null 2>&1 || true" Enter
Show

Hide
Type@1ms `TF_CLI_CONFIG_FILE=$PWD/mirror/mirror.tfrc go run main.go -w demo/dont_cost_money` Enter
Sleep 1s
Show

# show unintialized modules
# show explorer tree
Sleep 1s

# init all modules
Ctrl+a Sleep 0.5s Type "i"
# we're taken to the init task group page
# show init task group
Sleep 0.5s
# preview output for several tasks
Down Sleep 0.5s Down Sleep 0.5s Down Sleep 0.5s

# go back to modules
Type "m"
# go back to explorer
Type "0"
# validate all modules
Type "v"
# we're taken to the validate task group page
# show validate task group
Sleep 0.5s
# enable task info side panel
Type "I" Sleep 0.5s
Expand All @@ -37,13 +52,13 @@ Down Sleep 0.5s Down Sleep 0.5s Down Sleep 0.5s
# disable task info side panel
Type "I" Sleep 0.5s

# go back to modules
Type "m" Sleep 0.5s
# go back to explorer
Type "0" Sleep 0.5s
# show help
Type "?" Sleep 0.5s
# run plan on all modules
Type "p"
# we're taken to the plan task group page
# show plan task group page
Sleep 1s
# hide help
Type "?"
Expand All @@ -57,51 +72,48 @@ Sleep 0.5s Type "y"
# preview output for several tasks
Sleep 2s Down Sleep 1s Down Sleep 1s Down Sleep 1s

# go to workspaces
Type "w" Sleep 1s
# take screen shot of workspaces
# go back to explorer
Type "0" Sleep 1s
# take screen shot of explorer tree populated with workspaces
Screenshot demo/workspaces.png
# filter dev workspaces
Type "/" Sleep 0.5s Type "dev" Sleep 0.5s Enter
# take screen shot of filter mode
Screenshot demo/filter.png Sleep 0.5s
# move cursor down one onto dev workspace belonging to module a
Down Sleep 0.5s
# select all dev workspaces and auto-apply
Ctrl+a Sleep 0.5s Type "a"
# accept confirmation
Sleep 0.5s Type "y"
# preview output for several tasks
Sleep 2s Down Sleep 1s Down Sleep 1s

# go back to modules
Type "m" Sleep 0.5s
# go back to explorer
Type "0" Sleep 0.5s
# take screen shot of modules (sleep to ensure page doesn't switch too soon)
Screenshot demo/modules.png Sleep 0.5s

# go to state for current module
# go to state for current dev workspace
Type "s" Sleep 0.5s
# see preview for several resources
Sleep 0.5s Down Sleep 0.5s Down Sleep 0.5s Down Sleep 0.5s

# move current resource
Type "M" Sleep 0.5s Backspace 6 Sleep 0.5s Type "giraffe[99]" Sleep 0.5s Enter
# look at task output for a bit
Sleep 1s
Type "m" Sleep 0.5s Backspace 6 Sleep 0.5s Type "giraffe[99]" Sleep 0.5s Enter
# wait a bit of move to occur and message to appear in footer
Sleep 1.5s

# go back to state
Escape Sleep 0.5s
# take screen shot of state
Screenshot demo/state.png

# delete another resource
Down Sleep 0.5s
Type "D"
Delete
# confirm deletion
Sleep 0.5s Type "y" Sleep 0.5s
# look at task output for a bit
Sleep 1s

# go back to state
Escape Sleep 0.5s
Sleep 1.5s

# select all resources
Ctrl+a Sleep 0.5s
Expand All @@ -117,7 +129,7 @@ Escape Sleep 0.5s

# select all resources
Ctrl+a Sleep 0.5s
# taint all resources
# untaint all resources
Type "U"
# we're taken to the untaint task group page
Sleep 0.5s
Expand Down Expand Up @@ -167,17 +179,15 @@ Type `TF_CLI_CONFIG_FILE=$PWD/mirror/mirror.tfrc go run main.go -w demo/do_cost_
Sleep 1s
Show

# show unintialized modules
# show explorer tree
Sleep 1s

# init all modules
Ctrl+a Sleep 0.5s Type "i"
# we're taken to the init task group page, wait for a few seconds for tasks to finish
Sleep 2s

# go to workspaces
Type "w" Sleep 2s
# select all workspaces
# select all modules
Ctrl+a Sleep 0.5s
# calculate cost
Type "$"
Expand All @@ -186,27 +196,27 @@ Sleep 6s
# take screen shot of infracost output (sleep to ensure page doesn't switch too soon)
Screenshot demo/infracost_output.png Sleep 0.5s

# go back to workspaces
Type "w" Sleep 0.5s
# take screen shot of workspaces (sleep to ensure page doesn't switch too soon)
# go back to explorer
Type "0" Sleep 0.5s
# take screen shot of workspaces with costs (sleep to ensure page doesn't switch too soon)
Screenshot demo/workspaces_with_cost.png Sleep 0.5s
Sleep 3s

# quit app and restart, this time with modules with .tool-versions files, to demonstrate support for executing arbitrary programs, in this case, `asdf`
Hide
Ctrl+c Type "y"
Type `TF_CLI_CONFIG_FILE=$PWD/mirror/mirror.tfrc go run main.go -w demo/multiple_versions` Enter
Type@1ms `TF_CLI_CONFIG_FILE=$PWD/mirror/mirror.tfrc go run main.go -w demo/multiple_versions` Enter
Sleep 1s
Show

# show unintialized modules
# show explorer
Sleep 1s

# select all modules
Ctrl+a Sleep 0.5s
# install terraform for each module
Type "x" Sleep 1s
Type "asdf install terraform" Sleep 1s
Type@1ms "asdf install terraform" Sleep 1s
# take screen shot (sleep to ensure page doesn't switch too soon)
Screenshot demo/execute_asdf_install_terraform.png Sleep 0.5s
# Execute asdf
Expand Down
Binary file modified demo/workspaces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified demo/workspaces_with_cost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions hacks/make_demo.sh

This file was deleted.

8 changes: 0 additions & 8 deletions hacks/reset_demo.sh

This file was deleted.

Loading

0 comments on commit ebd073e

Please sign in to comment.