`odo init`: add `port` flag
I would love to see support for manually providing a port value via `odo init --port PORTNUMBER`.
If more than one port is detected, we may need the user to specify which port to use anyway.
Originally posted by @ryanj in https://github.com/redhat-developer/odo/issues/5863#issuecomment-1270768376
+1 Thanks for calling this out in a separate issue
There is one complication with manually providing port as a CLI flag in odo init commands.
The devfile can have multiple containers and user at the time of running odo init have no way to know how many containers there are unless they inspect devfile using https://registry.devfile.io/viewer or something similar.
If we want to do this, we will have to limit it in some way. If the devfile stack has only one container component that there are no problems.
Odo should ignore all ports defined in devfile container and use just those defined by the user in odo init command.
The problem is when there are multiple containers, like in the case of jave-wildfly-bootable-jar I see two possible solutions.
a) if the user runs something like odo init --name mywildfly --devfile java-wildfly-bootable-jar --port 8888 odo downloads devfile, detects that there are multiple containers and errors out with: "ERROR: java-wildfly-bootable-jar uses multiple containers you can't use --port flag. Run command again without --port and manually edit devfile.yaml
b) we try to come up with cli definition that will allow specifying the container name for which the port should be used. Maybe --port CONTAINERNAME:PORTNUMBERT. But then there is a problem in that the user currently has way to know to query devfile to know what containers are defined in the devfile. A possible solution would be to extend odo registry --filter java-wildfly-bootable-jar --details output to show containers and ports.
/status blocked
#5863
Thanks for the response.
All of my nodejs demos run on port 8080. The nodejs devfile is set for port 3000. I'm not aware of any way to initialize my apps with a functioning devfile using odo v3. I know I can manually edit the resulting devfile, but it makes my odo demos seem really complicated.
I'll try updating my demo app sources to bind to 3000 instead of 8080.
I like the idea of supporting --port CONTAINERNAME:PORTNUMBER
/close in favor of https://github.com/redhat-developer/odo/issues/4448
@kadel: Closing this issue.
In response to this:
/close in favor of https://github.com/redhat-developer/odo/issues/4448
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.