odo: Specifying a name does not matter when using odo delete

/kind bug

What versions of software are you using?

Operating System: Linux

Output of odo version: master 👍

How did you run odo exactly?

~/openshift/foobar                                                                                                                                                                                                                                                                                                                                                         ⍉
▶ odo list
Experimental mode is enabled, use at your own risk
Devfile Components: 
APP     NAME                PROJECT     TYPE                STATE
app     java-springboot     foo         java-springboot     Pushed
app     nodejs              foo         nodejs              Pushed
~/openshift/foobar                                                                                                                                                                                                                                                                                                                                                          
▶ odo delete kalsdjalksdjlakdjlasljkd -f
Gathering information for component nodejs
 ✓  Checking status for component [47ms]
Deleting component nodejs
 ✓  Deleting Kubernetes resources for component [46ms]
 ✓  Successfully deleted component
~/openshift/foobar   

Actual behavior

It does not matter what you specify to odo delete it will delete whatever is in your current folder…

Expected behavior

To fail when passing in something random such as odo delete alksjdalksjdklasd -f

Any logs, error output, etc?

See above

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry, for #1 let me clarify - I meant scenarios where we may have multiple components on your machine (and even more if there’s multiple components in multiple apps), and each component has its own folder. So being able to delete the component without having to find the component folder would save time / avoid a nuisance for the user.

But I agree, the better use case is actually #2 where the folder is lost or not accessible. I’m surprised actually that --app is required, since I believe the past functionality with odo was to use the default app if one isn’t specified, so yup, --app should be optional.

  1. Yes and no. But if you’ve got multiple components deployed on a cluster, across multiple apps (once https://github.com/openshift/odo/issues/3402 is in), having to find the context folder for the app you want to delete can be a real nuisance.

  2. odo delete’s help text does allow you to specify a name for a component:

Johns-MacBook-Pro-3:odo johncollier$ ./odo delete --help
Delete component.

Usage:
  odo delete <component_name> [flags]

Examples:
  # Delete component named 'frontend'.
  odo delete frontend
  odo delete frontend --all
  1. So, I just tried on master, and had no issues deleting a s2i component from a non-component directory. I just had to specify --app on odo delete if not inside a component directory:
Johns-MacBook-Pro-3:nodejs-ex johncollier$ odo create nodejs --s2i
Validation
 ✓  Validating component [250ms]

Please use `odo push` command to create the component with source deployed
Johns-MacBook-Pro-3:nodejs-ex johncollier$ odo push
Validation
 ✓  Checking component [388ms]

Configuration changes
 ✓  Initializing component
 ✓  Creating component [2s]

Applying URL changes
 ✓  URLs are synced with the cluster, no changes are required.

Pushing to component nodejs-nodejs-ex-ibmz of type local
 ✓  Checking files for pushing [1ms]
 ✓  Waiting for component to start [49s]
 ✓  Syncing files to the component [3s]
 ✓  Building component [22s]
 ✓  Changes successfully pushed to component
Johns-MacBook-Pro-3:nodejs-ex johncollier$ cd ~/
Johns-MacBook-Pro-3:~ johncollier$ mkdir testdir
Johns-MacBook-Pro-3:~ johncollier$ cd testdir
Johns-MacBook-Pro-3:testdir johncollier$ odo list --app app
Openshift Components: 
APP     NAME                      PROJECT     TYPE       SOURCETYPE     STATE
app     nodejs-nodejs-ex-ibmz     default     nodejs     local          Pushed
Johns-MacBook-Pro-3:testdir johncollier$ odo delete nodejs-nodejs-ex-ibmz --app app
? Are you sure you want to delete nodejs-nodejs-ex-ibmz from app? Yes
 ✓  Deleting component nodejs-nodejs-ex-ibmz [404ms]
 ✓  Component nodejs-nodejs-ex-ibmz from application app has been deleted

It may not make much sense without support for odo app with devfiles in, but being able to do odo delete <comp> --app <app> is a whole lot nicer than having to find the context folder for each component.