dotfiles/fish/functions/_tide_item_pulumi.fish

20 lines
733 B
Fish
Raw Normal View History

2023-10-08 22:26:07 -05:00
function _tide_item_pulumi
if path filter $_tide_parent_dirs/Pulumi.yaml | read -l yaml_path
if command -q sha1sum
2023-11-20 11:20:55 -06:00
echo -n "$yaml_path" | sha1sum | string match -qr "(?<path_hash>.{40})"
2023-10-08 22:26:07 -05:00
else if command -q shasum
2023-11-20 11:20:55 -06:00
echo -n "$yaml_path" | shasum | string match -qr "(?<path_hash>.{40})"
else
return
2023-10-08 22:26:07 -05:00
end
2023-11-20 11:20:55 -06:00
string match -qr 'name: *(?<project_name>.*)' <$yaml_path
set -l workspace_file "$HOME/.pulumi/workspaces/$project_name-$path_hash-workspace.json"
2023-10-08 22:26:07 -05:00
2023-11-20 11:20:55 -06:00
if test -e $workspace_file
string match -qr '"stack": *"(?<stack>.*)"' <$workspace_file
_tide_print_item pulumi $tide_pulumi_icon' ' $stack
2023-10-08 22:26:07 -05:00
end
end
end