Add Pulumi item (#335)

* Add Pulumi support

* Fix indentation issues

* Update to command rm in pulumi test

* Replace python script with sha1sum command; Update to use fish builtins

* Some changes to pulumi item

* Update pulumi item for search-up behavior

* Actually update pulumi item for search-up behavior

* Merge main

Co-authored-by: Ilan Cosman <ilancosman@gmail.com>
This commit is contained in:
Devansh Sharma 2022-09-20 06:49:59 +05:30 committed by GitHub
parent 81ffcfea58
commit 0a83ef6af8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 4 deletions

View File

@ -0,0 +1,19 @@
function _tide_item_pulumi
if path filter $_tide_parent_dirs/Pulumi.yaml | read -l yaml_path
if command -q sha1sum
echo -n "$yaml_path" | sha1sum | string sub -e40 | read -f path_hash
else if command -q shasum
echo -n "$yaml_path" | shasum | string sub -e40 | read -f path_hash
end
if test -n "$path_hash"
string match -rg 'name: *(.*)' <$yaml_path | read -l project_name
set -l workspace_file "$HOME/.pulumi/workspaces/$project_name-$path_hash-workspace.json"
if test -e $workspace_file
string match -rg '"stack": *"(.*)"' <$workspace_file | read -l stack
_tide_print_item pulumi $tide_pulumi_icon' ' $stack
end
end
end
end

View File

@ -1,7 +1,7 @@
function _tide_remove_unusable_items
# Remove tool-specific items for tools the machine doesn't have installed
set -l removed_items
for item in aws chruby crystal distrobox docker git go java kubectl nix_shell node php rustc terraform toolbox virtual_env
for item in aws chruby crystal distrobox docker git go java kubectl nix_shell node php pulumi rustc terraform toolbox virtual_env
set -l cli_names $item
switch $item
case virtual_env

View File

@ -83,6 +83,9 @@ tide_prompt_color_separator_same_color 949494
tide_prompt_icon_connection ' '
tide_prompt_min_cols 34
tide_prompt_pad_items true
tide_pulumi_bg_color 444444
tide_pulumi_color F7BF2A
tide_pulumi_icon ''
tide_pwd_bg_color 444444
tide_pwd_color_anchors $_tide_color_light_blue
tide_pwd_color_dirs $_tide_color_dark_blue
@ -92,7 +95,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php pulumi chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_prefix
tide_right_prompt_separator_diff_color
tide_right_prompt_separator_same_color

View File

@ -47,6 +47,8 @@ tide_private_mode_bg_color black
tide_private_mode_color brwhite
tide_prompt_color_frame_and_connection brblack
tide_prompt_color_separator_same_color brblack
tide_pulumi_bg_color black
tide_pulumi_color yellow
tide_pwd_bg_color black
tide_pwd_color_anchors brcyan
tide_pwd_color_dirs cyan

View File

@ -83,6 +83,9 @@ tide_prompt_color_separator_same_color 949494
tide_prompt_icon_connection ' '
tide_prompt_min_cols 34
tide_prompt_pad_items false
tide_pulumi_bg_color normal
tide_pulumi_color F7BF2A
tide_pulumi_icon ''
tide_pwd_bg_color normal
tide_pwd_color_anchors $_tide_color_light_blue
tide_pwd_color_dirs $_tide_color_dark_blue
@ -92,7 +95,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled false
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php pulumi chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_prefix ' '
tide_right_prompt_separator_diff_color ' '
tide_right_prompt_separator_same_color ' '

View File

@ -47,6 +47,8 @@ tide_private_mode_bg_color normal
tide_private_mode_color brwhite
tide_prompt_color_frame_and_connection brblack
tide_prompt_color_separator_same_color brblack
tide_pulumi_bg_color normal
tide_pulumi_color yellow
tide_pwd_bg_color normal
tide_pwd_color_anchors brcyan
tide_pwd_color_dirs cyan

View File

@ -83,6 +83,9 @@ tide_prompt_color_separator_same_color 949494
tide_prompt_icon_connection ' '
tide_prompt_min_cols 34
tide_prompt_pad_items true
tide_pulumi_bg_color F7BF2A
tide_pulumi_color 000000
tide_pulumi_icon ''
tide_pwd_bg_color 3465A4
tide_pwd_color_anchors E4E4E4
tide_pwd_color_dirs E4E4E4
@ -92,7 +95,7 @@ tide_pwd_icon_home
tide_pwd_icon_unwritable
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_right_prompt_frame_enabled true
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_items status cmd_duration context jobs node virtual_env rustc java php pulumi chruby go kubectl toolbox terraform aws nix_shell crystal
tide_right_prompt_prefix
tide_right_prompt_separator_diff_color
tide_right_prompt_separator_same_color

View File

@ -47,6 +47,8 @@ tide_private_mode_bg_color brwhite
tide_private_mode_color black
tide_prompt_color_frame_and_connection brblack
tide_prompt_color_separator_same_color brblack
tide_pulumi_bg_color yellow
tide_pulumi_color black
tide_pwd_bg_color blue
tide_pwd_color_anchors brwhite
tide_pwd_color_dirs brwhite

View File

@ -0,0 +1,40 @@
# RUN: %fish %s
_tide_parent_dirs
function _pulumi
_tide_decolor (_tide_item_pulumi)
end
set -l tmpdir (mktemp -d)
cd $tmpdir
# Test #1: No Pulumi.yaml file
_pulumi # CHECK:
# Test #2: No workspace file
# Setting up sample Pulumi.yaml file
touch Pulumi.yaml
echo "name: pulumi-test" >Pulumi.yaml
# Setting up sample workspaces folder
mkdir -p .pulumi/workspaces/
# Calculating path hash for sample Pulumi file in $tmpdir
set -l mock_path_hash ''
if command -q sha1sum
set mock_path_hash (echo -n "$tmpdir/Pulumi.yaml" | sha1sum | string sub -e 40)
else if command -q shasum
set mock_path_hash (echo -n "$tmpdir/Pulumi.yaml" | shasum | string sub -e 40)
end
# Overriding $HOME to force use sample workspace file
HOME=$tmpdir _pulumi # CHECK:
# Test #3: Ideal path
# Setting up sample workspace file with 'dev' as current stack
echo "{\"stack\": \"dev\"}" >.pulumi/workspaces/pulumi-test-$mock_path_hash-workspace.json
# Overriding $HOME to force use sample workspace file
HOME=$tmpdir _pulumi # CHECK:  dev
command rm -r $tmpdir