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

Implement odo delete component --files to delete files generated by odo #6255

Conversation

rm3l
Copy link
Member

@rm3l rm3l commented Oct 25, 2022

What type of PR is this:
/area component

What does this PR do / why we need it:
See #5997 for the user story.

In a nutshell, this PR adds a new --files flag to odo delete component, the goal of which is to delete files that were created by odo.
To avoid deleting files we should not, it does so by introducing utility functions at the CLI level, so that commands can report which files they created. The list of files created is then stored in in a dedicated .odo/generated file. This way, we will be able to know which files were initially created by odo and which ones were not.
The reason for this is that files like devfile.yaml might or might not be created by odo. Also, odo dev for example creates a .gitignore file if it does not exist. So in some cases, we need to delete those files, and in other cases, we should not touch them.
See c47307b (#6255) and 350b9ac (#6255)

In all cases, we list all the files that are candidates for deletion and ask the user for confirmation (unless the --force flag is used).

Which issue(s) this PR fixes:
Fixes #5997

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/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation labels Oct 25, 2022
@netlify
Copy link

netlify bot commented Oct 25, 2022

Deploy Preview for odo-docusaurus-preview ready!

Name Link
🔨 Latest commit 74157a0
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/637b9bba205ab300093407cc
😎 Deploy Preview https://deploy-preview-6255--odo-docusaurus-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@openshift-ci openshift-ci bot requested review from dharmit and feloy October 25, 2022 17:07
@rm3l rm3l marked this pull request as draft October 25, 2022 17:08
@odo-robot
Copy link

odo-robot bot commented Oct 25, 2022

Unit Tests on commit afe1eef finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Oct 25, 2022

Validate Tests on commit afe1eef finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Oct 25, 2022

Windows Tests (OCP) on commit afe1eef finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Oct 25, 2022

Kubernetes Tests on commit afe1eef finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Oct 25, 2022

OpenShift Tests on commit afe1eef finished successfully.
View logs: TXT HTML

@rm3l rm3l force-pushed the 5997-odo-delete-component-files-delete-odo-generated-files-and-directories branch from 4feb896 to 05317f4 Compare October 26, 2022 06:45
@rm3l rm3l removed request for dharmit and feloy October 26, 2022 06:45
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Nov 2, 2022
@rm3l rm3l force-pushed the 5997-odo-delete-component-files-delete-odo-generated-files-and-directories branch from 05317f4 to f28ac06 Compare November 3, 2022 09:00
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Nov 3, 2022
@odo-robot
Copy link

odo-robot bot commented Nov 3, 2022

NoCluster Tests on commit afe1eef finished successfully.
View logs: TXT HTML

@rm3l rm3l removed the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Nov 3, 2022
@rm3l rm3l changed the title [WIP] Implement odo delete component --files Implement odo delete component --files to delete files generated by odo Nov 3, 2022
@rm3l rm3l marked this pull request as ready for review November 3, 2022 09:27
@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 3, 2022
@openshift-ci openshift-ci bot requested review from dharmit and feloy November 3, 2022 09:27
@rm3l rm3l added kind/user-story An issue of user-story kind kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation and removed kind/user-story An issue of user-story kind labels Nov 3, 2022
@rm3l rm3l closed this Nov 3, 2022
@rm3l rm3l reopened this Nov 3, 2022
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Nov 19, 2022
rm3l and others added 6 commits November 21, 2022 09:44
The end goal is for 'odo delete component --files' to gather a list of
files that were initially generated by odo, so as to delete only those.
This way, we are less likely to delete the wrong files.

This list is collected in a '.odo/generated' file.

It will then be up to odo commands to call those methods
accordingly. For example, this is called:
- by odo init, odo dev, or odo deploy, when generating a new devfile.yaml
- by odo dev, when there is no .gitignore file and odo generated one

Note that it is quite impossible to cover all scenarios; for example,
if odo generates a new devfile.yaml file, but the user deletes it
manually and recreates it, 'odo delete component --files'
will still list it as a possible candidate for deletion
(because it would be listed in .odo/generated).
Co-authored-by: Philippe Martin <[email protected]>
It is more likely to be modified by the user afterward (for another
usage).

Co-authored-by: Philippe Martin <[email protected]>
@rm3l rm3l force-pushed the 5997-odo-delete-component-files-delete-odo-generated-files-and-directories branch from 0bb8f31 to 032e83c Compare November 21, 2022 09:00
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Nov 21, 2022
@rm3l
Copy link
Member Author

rm3l commented Nov 21, 2022

Rebased and force-pushed to fix the conflicts reported.

@rm3l rm3l requested a review from feloy November 21, 2022 09:35
@feloy
Copy link
Contributor

feloy commented Nov 21, 2022

/lgtm

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

@valaparthvi valaparthvi left a comment

Choose a reason for hiding this comment

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

The code lgtm. I am not very sure about the integration tests yet, but everything else is functional.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Nov 21, 2022
@rm3l rm3l requested review from valaparthvi and removed request for dharmit November 21, 2022 14:21
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rm3l
Copy link
Member Author

rm3l commented Nov 21, 2022

/test v4.11-integration-e2e

@valaparthvi
Copy link
Contributor

/override ci/prow/v4.11-integration-e2e

/lgtm

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

openshift-ci bot commented Nov 22, 2022

@valaparthvi: Overrode contexts on behalf of valaparthvi: ci/prow/v4.11-integration-e2e

In response to this:

/override ci/prow/v4.11-integration-e2e

/lgtm

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.

@valaparthvi valaparthvi mentioned this pull request Nov 22, 2022
3 tasks
@openshift-merge-robot openshift-merge-robot merged commit d921a17 into redhat-developer:main Nov 22, 2022
@rm3l rm3l deleted the 5997-odo-delete-component-files-delete-odo-generated-files-and-directories branch November 22, 2022 09:18
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. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation 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 delete component --files delete odo generated files and directories
4 participants