forked from redhat-developer/odo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make odo work if optional
metadata.name
field is missing in Devfile (…
…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.
- Loading branch information
Showing
39 changed files
with
1,764 additions
and
1,130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.