redhat-developer / odo

odo - Developer-focused CLI for fast & iterative container-based application development on Podman and Kubernetes. Implementation of the open Devfile standard.
https://odo.dev
Apache License 2.0
795 stars 243 forks source link

`odo init` interactive mode does not prompt for Devfile personalization when running from empty directory #6313

Closed rm3l closed 1 year ago

rm3l commented 2 years ago

/kind bug

What versions of software are you using?

Operating System: Fedora 37

Output of odo version:

$ odo version
odo v3.2.0 (ce42ce435)

Server: https://10.10.10.105:6443
Kubernetes: v1.25.3

ce42ce435

How did you run odo exactly?

# Start from an empty directory
mkdir -p /tmp/test-odo-init-from-empty-dir
cd /tmp/test-odo-init-from-empty-dir

# Run odo init interactively till the end.
odo init

Actual behavior

Devfile is downloaded as expected, but we are not prompting users to personalize its configuration (by updating endpoints or environment variables).

$ odo init
  __
 /  \__     Initializing a new component
 \__/  \    Files: No source code detected, a starter project will be created in the current directory
 /  \__/    odo version: v3.2.0
 \__/

Interactive mode enabled, please answer the following questions:
? Select language: Java
? Select project type: Quarkus Java
 ✓  Downloading devfile "java-quarkus" from registry "DefaultDevfileRegistry" [1s]
? Which starter project do you want to use? redhat-product
? Enter component name: test-odo-init-from-empty-dir
 ✓  Downloading starter project "redhat-product" [2s]

Port configuration using flag is currently not supported  

You can automate this command by executing:
   odo init --name test-odo-init-from-empty-dir --devfile java-quarkus --devfile-registry DefaultDevfileRegistry --starter redhat-product

Your new component 'test-odo-init-from-empty-dir' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

Expected behavior

The current behavior seems inconsistent, depending on whether the directory has source code or not.

When there is source code, odo prompts for Devfile personalization, as we can confirm below:

$ git clone https://github.com/gothinkster/node-express-realworld-example-app && cd node-express-realworld-example-app

$ odo init
  __
 /  \__     Initializing a new component
 \__/  \    Files: Source code detected, a Devfile will be determined based upon source code autodetection
 /  \__/    odo version: v3.2.0
 \__/

Interactive mode enabled, please answer the following questions:
Based on the files in the current directory odo detected
Language: JavaScript
Project type: Node.js
The devfile "nodejs" from the registry "DefaultDevfileRegistry" will be downloaded.
? Is this correct? Yes
 ✓  Downloading devfile "nodejs" from registry "DefaultDevfileRegistry" [1s]

↪ Container Configuration "runtime":
  OPEN PORTS:
    - 3000
    - 5858
  ENVIRONMENT VARIABLES:
    - DEBUG_PORT = 5858

? Select container for which you want to change configuration? NONE - configuration is correct
? Enter component name: conduit-node

Port configuration using flag is currently not supported  

You can automate this command by executing:
   odo init --name conduit-node --devfile nodejs --devfile-registry DefaultDevfileRegistry

Your new component 'conduit-node' is ready in the current directory.
To start editing your component, use 'odo dev' and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.

I think we should do the same thing even if there is no source code, because users may have an idea of how their application could look like in the end (regardless of whether they select a starter project or not).

Any logs, error output, etc?

anandrkskd commented 1 year ago

@rm3l I think current behavior should be the expected behavior, According to current workflow, first we are downloading the devfile, and then we ask/download the starter project associated to it, does it make sense to update/edit the devfile if we will use the starter project?