Files
ubicloud/.rubocop.yml
Jeremy Evans 94dbf5114a Require confirmation for cli vm/pg destroy commands
This requires changes to the cli at all levels, since the cli was
not originally designed to be interactive.

Have the /cli API endpoint ask for confirmation via an ubi-confirm
header.  Make bin/ubi recognize the ubi-confirm header and prompt
the user for confirmation.  The confirmation value is sent in the
top level --confirm option.

Change UbiCli.destroy, used for both vm and pg destory to support
an -f/--force option to destroy without asking for confirmation.
Unless the -f option is given, it asks for confirmation.  If
confirmation is already provided, and it is correct, it runs the
destroy command.  If the confirmation is already provided and it
is incorrect, an error is returned.

To ease implementation of this in bin/ubi, a 1.times do block is
used. If confirmation is required, argv is prepended with the
--confirm option and confirmation value, and then redo is used
to send another request.  Rubocop doesn't understand this and
tries to remove the 1.times do, breaking the code, so disable
that cop.
2025-02-13 14:41:19 -08:00

1.4 KiB