canonical / jhack

Chock-full of Juju hackery.
Apache License 2.0
50 stars 24 forks source link

Typo in no-YOLO mode configuration `|>` #165

Closed taurus-forever closed 5 months ago

taurus-forever commented 5 months ago

Hi,

The console experience:

ubuntu@juju29:~$ jhack fire postgresql/0 update-status
firing update-status on:
    postgresql/0
WARNING:jhack./snap/jhack/357/lib/python3.8/site-packages/jhack/conf/conf.py:in order to run this command without confirmation prompt, you must enable destructive mode. This mode is intended for development environments and should be disabled in production! This is *for your own good*. If you know better, you can run `jhack conf default |> ~/.config/jhack/config.toml` and edit that file and set `[general]enable_destructive_commands_NO_PRODUCTION_zero_guarantees` to `true`. Or, if you want to allow destructive mode just this once, run `JHACK_PROFILE=devmode /snap/jhack/357/bin/jhack fire postgresql/0 update-status`
'fire' would run: 
     juju ssh postgresql/0 sudo /usr/bin/juju-run -u postgresql/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=posgresql2947 JUJU_UNIT_NAME=postgresql/0 ./dispatch
confirm [y/N]: y

ubuntu@juju29:~$ jhack conf default |> ~/.config/jhack/config.toml
-bash: /home/ubuntu/.config/jhack/config.toml: No such file or directory
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

ubuntu@juju29:~$ jhack conf default > ~/.config/jhack/config.toml
-bash: /home/ubuntu/.config/jhack/config.toml: No such file or directory

ubuntu@juju29:~$ mkdir -p ~/.config/jhack/

ubuntu@juju29:~$ jhack conf default > ~/.config/jhack/config.toml

ubuntu@juju29:~$ vim ~/.config/jhack/config.toml

Proposals:

P.S. consider to improve the warning layout:

ubuntu@juju29:~$ jhack fire postgresql/0 update-status
firing update-status on:
    postgresql/0

Note: jhack is now safe! The dangerous commands will request confirmation.

Tune jhack defaults for your needs:
> cp /snap/jhack/current/safe.toml ~/.config/jhack.toml

to run destructive commands without confirmation prompt:
>  ln -s /snap/jhack/current/destructive.toml ~/.config/jhack.toml

If you want to allow YOLO mode (WARNING: no safety belts here at all!):
>  ln -s /snap/jhack/current/yolo.toml ~/.config/jhack.toml

More options: https://github.com/jhack/somewhere

Confirm the command execution [y/N]:
PietroPasotti commented 5 months ago

Agreed, that was ugly. Cleaning it up.

PietroPasotti commented 5 months ago

Thanks for the suggestions, should be better now. Exposing easy paths for symlinking was a little too much work, instead I added destructive and yolo profiles to jhack conf.

Now you can

jhack conf yolo > .config/jhack/config.toml
jhack conf destructive > .config/jhack/config.toml
jhack conf default > .config/jhack/config.toml  # factory settings

also, by default, jhack will try to copy the default profile into your ~/.config/jhack/config.toml folder (yes, we have the appropriate connection for it to work with strict confinement). Only if that fails you'll have to do it manually.

Will be released as 0.4.1.9

taurus-forever commented 5 months ago

Not in 0.4.2?

ubuntu@juju350:~$ jhack conf yolo > ~/.config/jhack/config.toml
Usage: jhack conf [OPTIONS] COMMAND [ARGS]...
Try 'jhack conf --help' for help.
╭─ Error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ No such command 'yolo'.                                                                                                                                                                                                                                                                                                                                        │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

ubuntu@juju350:~$ jhack version
jhack 0.4.2 --DEVMODE--
PietroPasotti commented 5 months ago

Huh, not sure what happened there. It should be. Will check