-
Notifications
You must be signed in to change notification settings - Fork 35
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
Make the parser able to parse any file (including files with .yml
extension)
#186
Conversation
Signed-off-by: Armel Soro <asoro@redhat.com>
The parser should act generically, and be able to parse any file it is provided, regardless of name and file extension. Signed-off-by: Armel Soro <asoro@redhat.com>
It actually is able to write to the path in the Devfile object context, not just a `devfile.yaml` file Signed-off-by: Armel Soro <asoro@redhat.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
==========================================
+ Coverage 60.84% 61.05% +0.20%
==========================================
Files 41 42 +1
Lines 5006 5017 +11
==========================================
+ Hits 3046 3063 +17
+ Misses 1767 1761 -6
Partials 193 193
☔ View full report in Codecov by Sentry. |
.yml
).yml
)
.yml
).yml
extension)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea behind this solution makes sense.
One question I have is what about Che and HAS? Have we checked how they are first filtering the files passed to ParseDevfileAndValidate
?
44e7c7d
to
1b58177
Compare
Whoops, I just noticed this comment..
I checked Che, and in my understanding, Che (the DevWorkspace Operator) has its own library for parsing Devfiles: https://github.com/devfile/devworkspace-operator/tree/main/pkg/library This PR is more about making sure the parser is able to parse filesystem paths other than As for HAS, I saw this has been covered too in DEVHAS-493 (redhat-appstudio/application-service#400), where support for detecting |
I've gone ahead and tried to check the changes here on HAS.
(As I expected, the test passes with the changes in this PR) @yangcao77 Am I missing anything about DEVHAS-493 and redhat-appstudio/application-service#400? I guess HAS will need to update its version of the Devfile library once the changes here are merged.. |
the failure you saw is due to this: library/pkg/devfile/parser/context/context.go Lines 99 to 101 in 36607c5
in library, if the extension is not .yaml , it will append devfile.yaml at the end of the path. so HAS passed
I saw in your PR, you removed the block which appends devfile.yaml , it will fix the current issue, but I’m not suggesting to do it. it will cause regression to existing users who only pass the context path to library and also to test with your changes in library with HAS and ODC(please do), need to replace the library version in go.mod
|
Yes, HAS need the change in library to be able to parse the content. |
Yes, that's how I am testing this with |
Signed-off-by: Armel Soro <asoro@redhat.com>
This reverts commit fd5fccb. Signed-off-by: Armel Soro <asoro@redhat.com>
…ext path is passed Signed-off-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Armel Soro <asoro@redhat.com>
…fault devfiles Signed-off-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Armel Soro <asoro@redhat.com>
32d5250
to
728befe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change looks good to me. assumes verified it works with consumers
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rm3l, yangcao77 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks for the review! |
What does this PR do?:
This makes sure the Devfile parser does not make any assumptions on the path it is provided. It should now be able to parse any file path it is provided by clients, including files with a
.yml
extension.After digging, I found no special place in the code where the library is discovering a Devfile.
Which issue(s) this PR fixes:
Fixes devfile/api#1265
PR acceptance criteria:
Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened and linked to this PR, if they are not in the PR scope due to various constraints.
I checked the following clients:
odo
: there is an ongoing PR (Recognizedevfile.yml
and.devfile.yml
as Devfiles redhat-developer/odo#7130).odo
has a specified list of acceptable filenames for a Devfile, and this list has been extended to includedevfile.yml
and.devfile.yml
ODC
: they call the parser using theData
field, which should not be affected by the changes here (which handles parsing from a specified devfile path): https://github.com/openshift/console/blob/master/pkg/devfile/handler.go#L55. I tested based on the instructions here.Che: they have their own logic for parsing: devfile/devworkspace-operator@main/pkg/library
So they should not be impacted by the changes here. Furthermore, they currently look by default for a devfile with the file name .devfile.yaml or devfile.yaml. For other cases, they allow users to specify a custom path, which also covers {,.}devfile.yml or any other files. I tested on Dev Sandbox using a devfile.yml file and it works without any problem.
See eclipse.dev/che/docs/stable/end-user-guide/url-parameter-for-the-devfile-file-name and che-incubator/che-code@main/code/extensions/che-remote/src/extension.ts#L100-L112
HAS: [DEVHAS-493]support devfile.yml redhat-appstudio/application-service#400 made it possible to allow
devfile.yml
and.devfile.yml
as potential input devfiles. But parsing of those files currently fails. I checked with the changes here and parsing works as expected.Gosec scans
How to test changes / Special notes to the reviewer: