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 22, 2024
1 parent 134e53e commit a116f67
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 68 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
15 changes: 6 additions & 9 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,14 +83,12 @@ 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
Expand Down Expand Up @@ -149,11 +146,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|-|
Expand Down Expand Up @@ -219,8 +215,9 @@ 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|
|`0`|Focus left pane (explorer)|
|`1`|Focus top right pane|
|`2`|Focus bottom right pane|
|`s`|Go to state page\*|
|`t`|Go to tasks page|
|`T`|Go to task groups page|
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.
78 changes: 44 additions & 34 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,9 +196,9 @@ 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

Expand All @@ -199,7 +209,7 @@ Type `TF_CLI_CONFIG_FILE=$PWD/mirror/mirror.tfrc go run main.go -w demo/multiple
Sleep 1s
Show

# show unintialized modules
# show explorer
Sleep 1s

# select all modules
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.

2 changes: 1 addition & 1 deletion internal/tui/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
Green = lipgloss.Color("34")
Turquoise = lipgloss.Color("86")
DarkGreen = lipgloss.Color("#325451")
DarkishGreen = lipgloss.Color("30")
LightGreen = lipgloss.Color("47")
GreenBlue = lipgloss.Color("#00A095")
DeepBlue = lipgloss.Color("39")
Expand All @@ -26,7 +27,6 @@ const (
DarkGrey = lipgloss.Color("#606362")
White = lipgloss.Color("#ffffff")
OffWhite = lipgloss.Color("#a8a7a5")
Pink = lipgloss.Color("30")
HotPink = lipgloss.Color("200")
)

Expand Down
13 changes: 2 additions & 11 deletions internal/tui/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ var (
Border = Regular.Border(lipgloss.NormalBorder())
ThickBorder = Regular.Border(lipgloss.ThickBorder()).BorderForeground(Violet)

Title = Padded.Foreground(White).Background(Purple)
TitleCommand = Padded.Foreground(White).Background(Blue)
TitlePath = Padded.Foreground(White).Background(modulePathColor)
TitleWorkspace = Padded.Foreground(White).Background(Green)
TitleID = Padded.Foreground(White).Background(Green)
TitleAddress = Padded.Foreground(White).Background(Blue)
TitleSerial = Padded.Foreground(Black).Background(Orange)
TitleTainted = Padded.Foreground(White).Background(Red)

ModuleStyle = Regular.Foreground(Purple)
WorkspaceStyle = Regular.Foreground(Pink)
ModuleStyle = Regular.Foreground(DarkishGreen)
WorkspaceStyle = Regular.Foreground(Purple)
)

0 comments on commit a116f67

Please sign in to comment.