hetznercloud / cli

A command-line interface for Hetzner Cloud
MIT License
1.06k stars 78 forks source link

Introduce delete subcommand to `hcloud all` #689

Open kranurag7 opened 6 months ago

kranurag7 commented 6 months ago

TL;DR

As a User, I have the use case of deleting all the resources in one project in one go. Given we don't have projects API available in hcloud-go or project subcommand in hcloud CLI. I think we can implement it under hcloud all

Expected behavior

hcloud all delete 
< prompt: Do you really want to delete everything [y/n]? >
kranurag7 commented 6 months ago

@apricote Do we want to implement it? If yes, I can give it an attempt.

I'm not very familiar with the code here so if you think that this will be not be possible to implement or requires some big refactoring then please let me know.

phm07 commented 5 months ago

I'm not sure if it is a good idea to add this to the CLI, as this command is very dangerous and probably not that often used. Also it's not clear what should be deleted. All resources, even the free ones (like SSH Keys, Placement Groups and Firewalls)? Or only paid resources? How are protected resources handled? What about deletion order (Volumes might be attached to servers etc.)? Maybe we can get a third opinion on this.

For now I'd suggest a solution like this:

hcloud server list -o=noheader -o=columns=name | xargs -L1 -I{} hcloud server delete {}
jooola commented 4 months ago

With 3b896fef82f50bc27351eec9e2da38032615c6e0 being released, it is now easier to delete multiple resources at once.

I propose to let this feature request open and wait until enough user have expressed their interest to reconsider the implementation of such feature.