Skip to content
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

Fix odo overwrites devfile with flattened/resolved devfile and refactor component creation #5199

Merged
merged 14 commits into from
Nov 9, 2021

Conversation

valaparthvi
Copy link
Contributor

@valaparthvi valaparthvi commented Oct 30, 2021

What type of PR is this?
/kind cleanup

What does this PR do / why we need it:
Refactors the component/create.go

Which issue(s) this PR fixes:

Fixes #5112

PR acceptance criteria:

How to test changes / Special notes to the reviewer:

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/cleanup labels Oct 30, 2021
@valaparthvi valaparthvi force-pushed the crefactor branch 2 times, most recently from 7a3b4cc to 8b71ea6 Compare November 1, 2021 11:37
@valaparthvi
Copy link
Contributor Author

/retest

@valaparthvi valaparthvi requested review from feloy and dharmit and removed request for rnapoles-rh November 1, 2021 13:59
@netlify
Copy link

netlify bot commented Nov 1, 2021

✔️ Deploy Preview for odo-docusaurus-preview ready!

🔨 Explore the source changes: ade774c

🔍 Inspect the deploy log: https://app.netlify.com/sites/odo-docusaurus-preview/deploys/6182c4d6ab7ad60008ad6a81

😎 Browse the preview: https://deploy-preview-5199--odo-docusaurus-preview.netlify.app

@valaparthvi
Copy link
Contributor Author

/retest

@valaparthvi
Copy link
Contributor Author

/test psi-kubernetes-integration-e2e

@valaparthvi
Copy link
Contributor Author

/test psi-kubernetes-integration-e2e

@valaparthvi valaparthvi changed the title WIP: Refactor component/create.go Refactor component/create.go Nov 8, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Nov 8, 2021
@valaparthvi valaparthvi changed the title Refactor component/create.go Fix odo overwrites devfile with flattened/resolved devfile and refactor component creation Nov 8, 2021
@valaparthvi
Copy link
Contributor Author

/test psi-kubernetes-integration-e2e

pkg/odo/cli/component/create_methods.go Show resolved Hide resolved
pkg/odo/cli/component/create_methods.go Outdated Show resolved Hide resolved
pkg/odo/cli/component/create_methods.go Outdated Show resolved Hide resolved
pkg/odo/cli/component/create_methods.go Outdated Show resolved Hide resolved
pkg/odo/cli/component/create.go Show resolved Hide resolved
@valaparthvi valaparthvi requested a review from feloy November 8, 2021 14:34
@valaparthvi
Copy link
Contributor Author

/test psi-kubernetes-integration-e2e
/test psi-unit-test-windows

@valaparthvi
Copy link
Contributor Author

/test psi-unit-test-windows

if err != nil {
co.createMethod.Rollback(co.componentContext)
return err
}

// From this point forward, rollback should be triggered if an error is encountered; rollback should delete all the files that were created by odo
defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

}

func (icm InteractiveCreateMethod) Rollback(componentContext string) {
os.RemoveAll(componentContext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we want to remove all the files of the devfile context? The user could have source files in this place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Philippe, what was the library you mentioned which could check diff in the directory. I am thinking to use it to decide what files should be deleted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked about this lib recently, but I'm not sure it is relevant: https://github.com/monochromegane/go-gitignore

But don't you think we just need to delete the devfile.yaml file here? The interface is about fetching this devfile.yaml only, I think it should only revert the creation of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought, I am not sure if deleting the starter project files is a good idea, we don't do it now. We can just delete the devfile and env files for now.


// validateAndFetchRegistry validates if the provided registryName exists and returns the devfile listed in the registy;
// if the registryName is "", then it returns devfiles of all the available registries
func validateAndFetchRegistry(registryName string) (catalog.DevfileComponentTypeList, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow creating a component if no devfile registry is present for direct(odo create <comp_name> <comp_type>) and interactive mode?

@feloy @dharmit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think you could detect early that there is no registry configured and stop at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this check has already been implemented.

@valaparthvi
Copy link
Contributor Author

@feloy Did you push afaf7a3 by mistake on this branch instead of #5198 ?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 9, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
3.2% 3.2% Duplication

@valaparthvi
Copy link
Contributor Author

/test psi-kubernetes-integration-e2e

@valaparthvi valaparthvi requested a review from feloy November 9, 2021 09:14
@feloy
Copy link
Contributor

feloy commented Nov 9, 2021

/lgtm
/approve

Thanks for this refactoring, this will help for the maintenance of the create command

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Nov 9, 2021
@openshift-ci
Copy link

openshift-ci bot commented Nov 9, 2021

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Nov 9, 2021
@openshift-merge-robot openshift-merge-robot merged commit 6b99ec4 into redhat-developer:main Nov 9, 2021
@rm3l rm3l added the area/refactoring Issues or PRs related to code refactoring label Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. area/refactoring Issues or PRs related to code refactoring lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

odo overwrites devfile with parent reference with flattened/resolved devfile
4 participants