radius-project / radius

Radius is a cloud-native, portable application platform that makes app development easier for teams building cloud-native apps.
https://radapp.io
Apache License 2.0
1.48k stars 94 forks source link

`rad env delete` defaults to deleting the default environment #6561

Open ytimocin opened 12 months ago

ytimocin commented 12 months ago

Bug information

Steps to reproduce (required)

First Scenario: rad install kubernetes is not run and this is a fresh Radius installation.

  1. Run rad env list and see that there is no environment.
  2. Run rad env delete and see that the CLI tries to delete the default environment.

Second Scenario: When we have a default environment, rad env delete tries to delete the default environment.

  1. Run rad init and initialize a default environment.
  2. Run rad env delete and see that the CLI tries to delete the default environment.

Third Scenario: When we have multiple environments, rad env delete tries to delete the default environment.

  1. Have multiple environments (you can create them via rad env create env-name).
  2. Run rad env delete and see that the CLI tries to delete the default environment.

Fourth Scenario: When we delete default environment and run rad env delete, it still tries to delete the default environment.

  1. Delete the default environment by running rad env delete -e default.
  2. Run rad env delete and see that the CLI tries to delete the default environment.

Observed behavior (required)

rad env delete defaults to deleting the default environment.

Desired behavior (required)

rad env delete should ask for an environment name.

Workaround (optional)

System information

rad Version (required)

RELEASE VERSION BICEP COMMIT 0.26.7 v0.26.7 0.11.90 fa562cea0b123ec2b1531112e67f758526bbba19

Operating system (required)

MacOS Sonoma 14.0 Apple Chip

Additional context

Screenshot 2023-10-24 at 3 53 33 PM

After we run rad init, which means we have a default environment, rad env delete defaults to the default environment.

Screenshot 2023-10-24 at 3 52 15 PM

No Radius installation so no default environment, rad env delete defaults to the default environment.

Screenshot 2023-10-24 at 3 51 57 PM

No Radius installation so no default environment, rad env delete defaults to the default environment.

AB#9903

AaronCrawfis commented 12 months ago

Thanks for the find!

To address numbers 1 and 4, we can do two things:

  1. Add a validation step in rad env delete to first check if the environment exists before prompting the user. If it does not exist provide the existing error of "specify -e/--environment or set a default environment via 'rad env switch'"
  2. Add logic to update the workspace file if the default environment is deleted. If it is remove the default from the workspace file. I don't think we should try and set a new default, that could lead to unexpected results.
willvelida commented 1 week ago

@AaronCrawfis @ytimocin - If this is still relevant, I'd like to address this issue. I'll assign myself now, and let you know how I get on.

willvelida commented 1 week ago

/assign