Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odo init - add ability to create component with existing codebase #5408

Closed
16 tasks done
Tracked by #5312
kadel opened this issue Feb 1, 2022 · 4 comments · Fixed by #5464
Closed
16 tasks done
Tracked by #5312

odo init - add ability to create component with existing codebase #5408

kadel opened this issue Feb 1, 2022 · 4 comments · Fixed by #5464
Labels
kind/user-story An issue of user-story kind
Milestone

Comments

@kadel
Copy link
Member

kadel commented Feb 1, 2022

/kind user-story

User Story

  • As an odo user
  • I want to easily add devfile.yml to my existing project
  • So that can quickly start benefiting from Devfile ecosystem and other odo features depending on devfile (odo deploy odo dev)

Acceptance Criteria

  • The command should always work with the current directory
  • If the command is executed in the directory with the existing devfile.yaml file it should error out.
  • The command should have an interactive mode that is by default executed when the user runs the command without any flags.
    • The first line of the output should explain to odo user if odo detected the source code and will try to autodetect the project type, or if it works in a mode where it will try to bootstrap new project in an empty directory (details in examples)
    • If the command is executed in the directory with existing source code it should use Alizer to automatically detect correct devfile.yaml from all devfile registries configured in odo. As implemented in Select and pull a devfile using Alizer #5422
      • After the successful detection it will show Language and Project Type information to users and ask for confirmation. If user answers that the information is not correct, odo should ask "Select language" and "Select project type" questions.
      • Users should be able to interactively add or remove ports and environment variables that are configured in devfile. This is only in the case the command is executed in the directory with existing code. as implemented in Ask for devfile personalization #5423
    • The last question should ask for the component name. The default value should match the current directory name (be aware that component name has a character limit and it can be only alphanumer characters and -, more info in devfile spec.) user entered value should be saved as metadata.name in the devile.yaml.
  • The command should also have non-interactive mode that is active when flags are used with the following flags.
    • --devfile string Name of the Devfile from the Devfile registry (required if --devfile-path is not defined)
    • --devfile-path string Path to a devfile. It can be local filesystem path or http(s). This is alternative to using devfile from Devfile registry.
    • --name string Name of the new component. If not specified, the name will be the name of the current directory.
    • --registry string name of the devfile registry (as configured in odo preference registry). It can be used in combination with --devfile, but not with --devfile-path
    • --starter string Name of the devfile starter project to populate the current directory with.
  • The command should inform the user about how it is progressing (downloading etc...) (see example for details)
  • The last message should help the user with next steps and (see example for details)

example

when executed in directory with existing source code

$ odo init

Current directory already contains source code.
Odo will try to autodetect language and project type to select best suited Devfile for your project.
Detected java using spring
? Is this correct? Yes
Current component configuration:
Container "container2":
  Opened ports:
  Environment variables:
   - FOO = bar
Container "container1":
  Opened ports:
   - 8080
   - 8084
  Environment variables:
   - FOO = bar
   - FOO1 = bar1
? Select container for which you want to change configuration? NONE - configuration is correct

? Enter component name: myjava
⠸ Downloading "java-springboot". 
⠏ Downloading "java-springboot". DONE
Your new component "myjava" is ready in the current directory.
To start editing your project, use “odo dev” and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your application to your cluster use “odo deploy”.

when executed in empty directory

$ odo init

Current directory is empty. You can create a new component using a starter project to easily start new project.

? Select language: java
? Select project type: Maven Java
? Which starter project do you wan to use? starter1
? Enter component name: myjava
⠏ Downloading "java-maven". DONE
⠏ Downloading starter project "starter1" ... DONE
Your new component "myjava" is ready in the current directory.
To start editing your project, use “odo dev” and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your application to your cluster use “odo deploy”.

non-interactive

$ odo init --name myjava --devfile java-maven

⠏ Downloading "java-maven". DONE

Your new component "myjava" is ready in the current directory.
To start editing your project, use “odo dev” and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your application to your cluster use “odo deploy”.

$ odo init --name myjava --devfile java-maven --registry my-company-registry --starter starter1

⠏ Downloading "java-maven". DONE
⠏ Downloading starter project "starter1" ... DONE

Your new component "myjava" is ready in the current directory.
To start editing your project, use “odo dev” and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your application to your cluster use “odo deploy”.



$ odo init --name myjava --devfile-path https://example.com/devfile.yml

⠏ Downloading "https://example.com/devfile.yml". DONE

Your new component "myjava" is ready in the current directory.
To start editing your project, use “odo dev” and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your application to your cluster use “odo deploy”.


$ odo init --name myjava --devfile /path/to/devfile.yml

⠏ Copying "/path/to/devfile.yml" to current directory. DONE

Your new component "myjava" is ready in the current directory.
To start editing your project, use “odo dev” and open this folder in your favorite IDE.
Changes will be directly reflected on the cluster.
To deploy your application to your cluster use “odo deploy”.

Links

@kadel kadel added this to the 3.0 (planning) milestone Feb 1, 2022
@kadel kadel added the v3 label Feb 1, 2022
@valaparthvi
Copy link
Contributor

valaparthvi commented Feb 11, 2022

➜   ls   
devfile.yaml  mvnw  mvnw.cmd  pom.xml  README.md  src
➜   odo init
 ✗  The current directory is not empty. You can bootstrap new component only in empty directory.
If you have existing code that you want to deploy use `odo deploy` or use `odo dev` command to quickly iterate on your component.

For note keeping sake, when a devfile is present, odo init should take that into account.

@kadel kadel added the kind/epic An issue categorized as a high-level Epic. Needs to be scoped and broken down in 1+ stories/tasks label Feb 16, 2022
@kadel kadel mentioned this issue Feb 21, 2022
13 tasks
@kadel kadel removed the kind/epic An issue categorized as a high-level Epic. Needs to be scoped and broken down in 1+ stories/tasks label Feb 21, 2022
@kadel kadel added the kind/user-story An issue of user-story kind label Feb 21, 2022
@kadel kadel mentioned this issue Feb 21, 2022
6 tasks
@kadel
Copy link
Member Author

kadel commented Feb 23, 2022

/reopen

not every item is done

@openshift-ci openshift-ci bot reopened this Feb 23, 2022
@openshift-ci
Copy link

openshift-ci bot commented Feb 23, 2022

@kadel: Reopened this issue.

In response to this:

/reopen

not every item is done

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kadel kadel moved this from Done to In Progress in odo v3-alpha1 Feb 23, 2022
@kadel kadel removed the status in odo v3-alpha1 Feb 23, 2022
@rm3l
Copy link
Member

rm3l commented Mar 9, 2022

  • The first line of the output should explain to odo user if odo detected the source code and will try to autodetect the project type, or if it works in a mode where it will try to bootstrap new project in an empty directory (details in examples)

This has been implemented with #5494

@kadel kadel closed this as completed Mar 9, 2022
@kadel kadel moved this to Done in odo v3-alpha1 Mar 9, 2022
@rm3l rm3l added the v3 label Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/user-story An issue of user-story kind
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants