-
Notifications
You must be signed in to change notification settings - Fork 243
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 odo work if optional metadata.name
field is missing in Devfile
#6015
Make odo work if optional metadata.name
field is missing in Devfile
#6015
Conversation
Skipping CI for Draft Pull Request. |
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
3d40ab8
to
71cad0c
Compare
71cad0c
to
1d64567
Compare
1d64567
to
3b99e67
Compare
2dc0119
to
b2478e6
Compare
b2478e6
to
16a2835
Compare
bf58a7c
to
b8f9079
Compare
metadata.name
field is missing in Devfilemetadata.name
field is missing in Devfile
/hold cancel |
/test unit-and-validate-test |
/test unit-and-validate-test |
…file metadata name Compute and store the component name in the CLI context, and pass it as needed As commented out in [1], the context should ideally be built and passed down to the business clients structs. [1] redhat-developer#6015 (comment)
…as needed As commented out in [1], the context should ideally be built and passed down to the business clients structs. [1] redhat-developer#6015 (comment)
3f7ef4d
to
cf27963
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feloy 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 |
Functions in this file are only called from the 'registry' package, so it makes sense for this file to belong to this package. Furthermore, this paves the way to calling 'alizer.DetectName' from 'component.go', thus avoiding a cyclic dependency between packages.
…nent/component.go' This rewrites the 'component#GatherName' function that was already there, but not used, to meet the expectations, i.e.: - use 'metadata.name' field (after sanitizing it) if it is defined in the Devfile - otherwise, use Alizer to detect the name. Under the hood, this leverages the 'alizer#DetectName' introduced in 83ad3ee, which means that: -- use Alizer to detect the name automatically -- otherwise, use the name of the Devfile base directory after sanitizing it
…as needed As commented out in [1], the context should ideally be built and passed down to the business clients structs. [1] redhat-developer#6015 (comment)
For the sake of both performance and readability, only the tests that break in the absence of a 'metadata.name' field in their Devfiles have been updated (to test this specific case).
…d with no 'metadata.name' in the Devfile The rationale behind this is to purposely make the Alizer library unable to detect the project. Per the requirements, this would force us to use the project directory name as component name. This highlights an interesting behavior if the project directory name is all-numeric (as is the case in our tests); our sanitization logic automatically prepends an "x" prefix to the directory name, so it can be used as a valid name for the component.
cf27963
to
3aa7bc0
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
/override ci/prow/unit-and-validate-test |
@feloy: Overrode contexts on behalf of feloy: ci/prow/unit-and-validate-test, ci/prow/v4.10-integration-e2e In response to this:
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. |
…redhat-developer#6015) * Move 'starter_project.go' from 'pkg/component' to 'pkg/registry' Functions in this file are only called from the 'registry' package, so it makes sense for this file to belong to this package. Furthermore, this paves the way to calling 'alizer.DetectName' from 'component.go', thus avoiding a cyclic dependency between packages. * Introduce central logic for determining component names in 'pkg/component/component.go' This rewrites the 'component#GatherName' function that was already there, but not used, to meet the expectations, i.e.: - use 'metadata.name' field (after sanitizing it) if it is defined in the Devfile - otherwise, use Alizer to detect the name. Under the hood, this leverages the 'alizer#DetectName' introduced in 83ad3ee, which means that: -- use Alizer to detect the name automatically -- otherwise, use the name of the Devfile base directory after sanitizing it * Compute and store the component name in the CLI context, and pass it as needed As commented out in [1], the context should ideally be built and passed down to the business clients structs. [1] redhat-developer#6015 (comment) * Enrich relevant integration test cases For the sake of both performance and readability, only the tests that break in the absence of a 'metadata.name' field in their Devfiles have been updated (to test this specific case). * Add test case for 'odo dev' when a project with no source code is used with no 'metadata.name' in the Devfile The rationale behind this is to purposely make the Alizer library unable to detect the project. Per the requirements, this would force us to use the project directory name as component name. This highlights an interesting behavior if the project directory name is all-numeric (as is the case in our tests); our sanitization logic automatically prepends an "x" prefix to the directory name, so it can be used as a valid name for the component.
What type of PR is this:
/kind feature
What does this PR do / why we need it:
Which issue(s) this PR fixes:
Fixes #5821
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer: