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

Add a new function to run cwp without exiting a process #640

Merged
merged 7 commits into from
Sep 30, 2021

Conversation

jxr98
Copy link
Contributor

@jxr98 jxr98 commented Sep 27, 2021

Make sure that you've checked the boxes below before you submit PR:

Always

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Written well with PR title, we generate the release notes base on that

For the bug fixes or features only

  • Quality Gate Passed. Change this URL to your PR.
  • The coverage is xxx on the new lines
  • I've tested it by manual in the following platform
    • MacOS
    • Linux
    • Windows
  • Unit Test covered
  • e2e Test covered

@codecov
Copy link

codecov bot commented Sep 27, 2021

Codecov Report

Merging #640 (586f42c) into master (a99158f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #640   +/-   ##
=======================================
  Coverage   37.98%   37.98%           
=======================================
  Files          13       13           
  Lines         416      416           
=======================================
  Hits          158      158           
  Misses        246      246           
  Partials       12       12           
Flag Coverage Δ
unittests 37.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a99158f...586f42c. Read the comment docs.

@jxr98
Copy link
Contributor Author

jxr98 commented Sep 27, 2021

I want to use the cwpOptions.Run() method in other go files, but this function uses syscall.Exec() which ends a process and the following code are not executing. So I creates a new function called RunWithoutProcessExits() and the logic is the same basically, while using exec.Command() which doesn't exiting a process instead of syscall.Exec().

Copy link
Member

@LinuxSuRen LinuxSuRen left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. There are a few small problems you might need to take a look at them.

app/cmd/cwp.go Show resolved Hide resolved
app/cmd/cwp.go Outdated Show resolved Hide resolved
@jxr98
Copy link
Contributor Author

jxr98 commented Sep 28, 2021

The e2e Test/ Build ubuntu failed, but I don't know why. Could someone give me a hint on it. That would be appreciated.
Is it because the function I wrote doesn't ending a process?

@jxr98
Copy link
Contributor Author

jxr98 commented Sep 30, 2021

Hello Rick! This pr is needed to be merged first. Thanks for your reviewing.
An example to use this new added function is as follows:

var rootCmd = &cobra.Command{
 Use:   "sth",
 Short: "sth",
 RunE: func(cmd *cobra.Command, args []string)(err error) {
   var cwpOptions CWPOptions
   cwpOptions.ConfigPath = pathToYamlFile
   err =cwpOptions.RunWithoutProcessExits(cmd, args)
  return err
 },
}

But this is not a complete file and more information about cobra is available here.

@LinuxSuRen LinuxSuRen merged commit a8a75cc into jenkins-zh:master Sep 30, 2021
@LinuxSuRen LinuxSuRen added the enhancement New feature or request label Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants