-
Notifications
You must be signed in to change notification settings - Fork 244
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
Improves odo delete for devfiles #2842
Merged
openshift-merge-robot
merged 2 commits into
redhat-developer:master
from
mik-dass:dev_del_improve
Apr 18, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,36 +101,7 @@ func (do *DeleteOptions) Run() (err error) { | |
glog.V(4).Infof("args: %#v", do) | ||
|
||
if experimental.IsExperimentalModeEnabled() && util.CheckPathExists(do.devfilePath) { | ||
// devfile delete | ||
if do.componentForceDeleteFlag || ui.Proceed(fmt.Sprintf("Are you sure you want to delete the devfile component?")) { | ||
err = do.DevfileComponentDelete() | ||
if err != nil { | ||
log.Errorf("error occurred while deleting component, cause: %v", err) | ||
} | ||
} else { | ||
log.Error("Aborting deletion of component") | ||
} | ||
|
||
if do.componentDeleteAllFlag { | ||
if do.componentForceDeleteFlag || ui.Proceed(fmt.Sprintf("Are you sure you want to delete env folder?")) { | ||
if !do.EnvSpecificInfo.EnvInfoFileExists() { | ||
return fmt.Errorf("env folder doesn't exist for the component") | ||
} | ||
err = do.EnvSpecificInfo.DeleteEnvInfoFile() | ||
if err != nil { | ||
return err | ||
} | ||
err = do.EnvSpecificInfo.DeleteEnvDirIfEmpty() | ||
if err != nil { | ||
return err | ||
} | ||
log.Successf("Successfully deleted env file") | ||
} else { | ||
log.Error("Aborting deletion of env folder") | ||
} | ||
} | ||
|
||
return nil | ||
return do.DevFileRun() | ||
} | ||
|
||
if do.isCmpExists { | ||
|
@@ -212,6 +183,53 @@ func (do *DeleteOptions) Run() (err error) { | |
return | ||
} | ||
|
||
// Run has the logic to perform the required actions as part of command for devfiles | ||
func (do *DeleteOptions) DevFileRun() (err error) { | ||
// devfile delete | ||
if do.componentForceDeleteFlag || ui.Proceed(fmt.Sprintf("Are you sure you want to delete the devfile component: %s?", do.EnvSpecificInfo.GetName())) { | ||
err = do.DevfileComponentDelete() | ||
if err != nil { | ||
log.Errorf("error occurred while deleting component, cause: %v", err) | ||
} | ||
} else { | ||
log.Error("Aborting deletion of component") | ||
} | ||
|
||
if do.componentDeleteAllFlag { | ||
if do.componentForceDeleteFlag || ui.Proceed(fmt.Sprintf("Are you sure you want to delete env folder?")) { | ||
if !do.EnvSpecificInfo.EnvInfoFileExists() { | ||
return fmt.Errorf("env folder doesn't exist for the component") | ||
} | ||
if err = util.DeleteIndexFile(filepath.Dir(do.devfilePath)); err != nil { | ||
return err | ||
} | ||
|
||
err = do.EnvSpecificInfo.DeleteEnvInfoFile() | ||
if err != nil { | ||
return err | ||
} | ||
err = do.EnvSpecificInfo.DeleteEnvDirIfEmpty() | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, we should remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
return err | ||
} | ||
|
||
cfg, err := config.NewLocalConfigInfo(do.componentContext) | ||
if err != nil { | ||
return err | ||
} | ||
if err = cfg.DeleteConfigDirIfEmpty(); err != nil { | ||
return err | ||
} | ||
|
||
log.Successf("Successfully deleted env file") | ||
} else { | ||
log.Error("Aborting deletion of env folder") | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// NewCmdDelete implements the delete odo command | ||
func NewCmdDelete(name, fullName string) *cobra.Command { | ||
|
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@mik-dass Any plan for writing UTs ?
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.
It's the CLI package. We are testing CLI by using integration tests I guess.
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.
Really i am in 50-50 state whether to write UTs for cli packages or not. Recently i saw UTs for few devfile cli packages, so thought why not then covering UTs for regular cli packages. More importantly our UTs coverage are being run on all regular cli packages having no test file.
Ping @girishramnani @kadel
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.
TBH I couldn't any. Please share some links. Also is the effort even worth it?
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.
This is a generic topic for cabal discussion i guess. I will create a separate issue #2867 to tack the discussion of whether to add UTs for cli packages are sensible or not.
So atm i am applying lgtm label for your current changes
/lgtm
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.
Cool thanks for creating the issue 👍
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 refer #2867, there i have added the references.