odo: unable to push devfile, if there is no .odo
I have a project that contains devfile.yaml but no .odo
.
The .odo
directory should not be required!
▶ odo push
✗ The current directory does not represent an odo component. Use 'odo create' to create component here or switch to directory with a component
- User story covering required changes in
odo push
command - https://github.com/openshift/odo/issues/3144
/area devfile /priority high /area component
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (17 by maintainers)
I’d suggest we go ahead with what we’re discussing about
odo push
creating anenv.yaml
if it doesn’t find one. But adding similar capabilities toodo config set project
andodo config set name
can be kept for later time if we receive request from users. I’m saying this because it’s about adding functionality to sub commands unlikeodo push
. Also, someone usingodo config
commands first thing after cloning a repo containingdevfile.yaml
doesn’t sound like a frequent scenario to me.Don’t get me wrong, I understand the intention. It’s just that I don’t think it’s required right now.
As for the below approach,
I agree it makes sense. But it must be clearly laid out in docs so that there’s no room for confusion among users and/or developers.
So the final approach I would like to propose here would be -
odo create
in a directory with or without a devfile.yaml (with experimental mode= on) will always populates .odo/env/env.yaml with current namespace and other values. if there is no namespace that can be detected thendefault
odo push
will useenv.yaml
file if its available else it will use defaults . assuming if theenv.yaml
is not present the user didn’t go through the standardodo create
process and actually cloned someone’s odo component and due to that the component would be freshly created which means its ok to have a fresh component name and project name.odo push
in case if it doesn’t find theenv.yaml
, should create theenv.yaml
before it starts doing any cluster operations.odo project create <project>
can create a project and set it in KUBECONFIG as well as env.yaml only if there is no project present because that’s the most conventional this command could become without being unpredictable i.e.odo project create <project-name>
sets env.yaml when there is not project/default project present in env.yamlodo project create <project-name>
will not set env.yaml if the project is already set.Can we make
odo push
smart enough to check if.odo/env/env.yaml
is present in the directory? If it’s not present butdevfile.yaml
is present, canodo push
automagically create.odo/env/env.yaml
with some well-informed defaults?By well-informed defaults I mean:
KUBECONFIG
.pwd
(but I have a reservation against this and would suggest some random string getting appended to component name otherwise a user might have two differentnodejs
components for two different directories at/home/dshah/project1/nodejs
and/home/dshah/project2/nodejs
. We can do something similar to whatmetadata.generateName
does for other use cases. This will create one component namednodejs-random-string-1
andnodejs-random-string-2
. So user won’t accidentally push/modify something for one component from the directory for other component. This is not related to this discussion so I can open a new issue if there’s not one already.)What
odo push
would then do is, just call the same code thatodo create
calls if it detects that.odo/env/env.yaml
is not present in thepwd
.TBH, this sounds quite confusing to me. Whatever we decide to go with, we must make sure to explicitly mention this in the documentation along with a scenario. 😉