-
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
Draft: Ask for Devfile Personalization #5458
Conversation
✔️ Deploy Preview for odo-docusaurus-preview canceled. 🔨 Explore the source changes: 331dc19 🔍 Inspect the deploy log: https://app.netlify.com/sites/odo-docusaurus-preview/deploys/620b972b0bfa8500075bad0f |
pkg/init/init.go
Outdated
@@ -184,3 +189,176 @@ func (o *InitClient) PersonalizeName(devfile parser.DevfileObj, flags map[string | |||
err := backend.PersonalizeName(devfile, flags) | |||
return err | |||
} | |||
|
|||
func (o *InitClient) PersonalizeDevfileConfig(devfileobj parser.DevfileObj) error { | |||
var envs = map[string]string{} |
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.
In this pkg/init
package, there should not be specialized code, only calls to backends. You will need to place this code into the interactive
package, and call it from here (at this point, the only choice is to personalize the devfile config interactively, but it could change)
pkg/init/init.go
Outdated
for configChangeAnswer != "NOTHING - configuration is correct" { | ||
printConfiguration(portsMap, envs) | ||
|
||
configChangeQuestion := &survey.Select{ |
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.
Please create functions on the asker package to handle the survey specific operations. You can imagine a struct to make the interface between this function and the function into Asker, with something similar to:
- an operation (end, add, delete)
- a kind (port, envvar)
- a key
- a value
This way:
- it will be possible to mock the asker method and test the logic of this function.
- you will be able to test on some code (the operation of your struct) instead of literal values ("Delete port", etc)
pkg/init/init.go
Outdated
} | ||
|
||
if strings.HasPrefix(configChangeAnswer, "Delete port") { | ||
re := regexp.MustCompile("\"(.*?)\"") |
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.
Please don't rely on literal values (as UX people would like to change these without breaking the code).
Instead, Survey is able to reply with the index of the selected value, you can rely on this index to know the initial values without analysing the literal value (you can have two arrays in the same order, one with the containerName / port, the other with the literal value Delete port (container: "runtime")
)
Signed-off-by: Parthvi Vala <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
/close |
@valaparthvi: Closed this PR. 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. |
What type of PR is this:
/kind feature
What does this PR do / why we need it:
This PR allows user to personalize their devfile by adding/removing port, and environment variable.
Which issue(s) this PR fixes:
Fixes #5423
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer:
The devfile/library vendor files have been modified until devfile/library#131 is merged.