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

Run plugin on Windows #738

Merged
merged 1 commit into from
Mar 20, 2020
Merged

Run plugin on Windows #738

merged 1 commit into from
Mar 20, 2020

Conversation

MIBc
Copy link
Contributor

@MIBc MIBc commented Mar 12, 2020

Fixes #737

  • Use exec.Command instend of syscall.Exec for windows.
  • Fix a bug in plugin handler test when running it on windows.
  • Fix typo.

Release Note:

  • 🐛 Bug fix
    Using exec.Command instend of syscall.Exec for windows.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 12, 2020
@knative-prow-robot
Copy link
Contributor

Hi @MIBc. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@knative-prow-robot knative-prow-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 12, 2020
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

pkg/kn/commands/plugin/handler.go Show resolved Hide resolved
pkg/kn/commands/plugin/handler.go Show resolved Hide resolved
pkg/kn/commands/plugin/handler.go Outdated Show resolved Hide resolved
pkg/kn/commands/plugin/handler_test.go Outdated Show resolved Hide resolved
@navidshaikh
Copy link
Collaborator

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 13, 2020
@rhuss
Copy link
Contributor

rhuss commented Mar 13, 2020

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@mattmoor Could we please switch off this check ? A mentioned elsewhere we are using goimports as part of our regular build. Goimports has a slightly different opinion of how imports are organized (no idea why), but having this suggestions are too noisy imo causing unnecessary friction. Also, the next build will rearrange it again.

Just out of curiosity: Why did you stop using a dedicated bot account and use your real account for both activities (manual and automated PR/reviews) ? Asking, because quite some stats (like in TOC meetings or also when it comes for the TOC election process) are based on contributions, not sure whether automated commits (like these) are diluting these stats.

@rhuss
Copy link
Contributor

rhuss commented Mar 13, 2020

@MIBc please don't apply the reformatting suggestions, you will see if you rerun build.sh the imports will get rearranged again.

Copy link
Contributor

@maximilien maximilien 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 this contribution. Since I don't have a Windows system to try this I have to assume your changes are correct and needed :)

Otherwise LGTM. See my one comment left. Hopefully we can merge this soon. Thanks again.

pkg/kn/commands/plugin/handler.go Show resolved Hide resolved
@dsimansk
Copy link
Contributor

dsimansk commented Mar 17, 2020

@MIBc @maximilien
I have access to Windows on my home PC. So I've tried to check the current PR, but I'm still seeing a weird error message. Even though that plugin is executed, there's also and unknown command displayed afterwards.

Have you seen such behavior during your tests? Otherwise the PR looks good.

C:\Users\StyX\Desktop>kn-windows-amd64.exe hello.bat --plugins-dir=C:\Users\StyX\AppData\Roaming\kn\plugins
"Hello!"
unknown command "hello.bat" for "kn"

kn-hello.bat

@ECHO OFF
ECHO "Hello!"  

@MIBc
Copy link
Contributor Author

MIBc commented Mar 17, 2020

@MIBc @maximilien
I have access to Windows on my home PC. So I've tried to check the current PR, but I'm still seeing a weird error message. Even though that plugin is executed, there's also and unknown command displayed afterwards.

Have you seen such behavior during your tests? Otherwise the PR looks good.

C:\Users\StyX\Desktop>kn-windows-amd64.exe hello.bat --plugins-dir=C:\Users\StyX\AppData\Roaming\kn\plugins
"Hello!"
unknown command "hello.bat" for "kn"

kn-hello.bat

@ECHO OFF
ECHO "Hello!"  

Plugin's name should begin with kn. Like kn-hello.bat

@dsimansk
Copy link
Contributor

@MIBc I had to add the following lines that're also part of kubectl implementation.

Per conversation with @navidshaikh. He found out that this behaviour is reproducible on Linux as well, if exec.Command is used instead of syscall.Exec.

➜  client git:(pr-738) ✗ git --no-pager diff
diff --git a/pkg/kn/commands/plugin/handler.go b/pkg/kn/commands/plugin/handler.go
index 1d05169..7ee7c4e 100644
--- a/pkg/kn/commands/plugin/handler.go
+++ b/pkg/kn/commands/plugin/handler.go
@@ -100,7 +100,11 @@ func (h *DefaultPluginHandler) Execute(executablePath string, cmdArgs, environme
 		cmd.Stderr = os.Stderr
 		cmd.Stdin = os.Stdin
 		cmd.Env = environment
-		return cmd.Run()
+		err := cmd.Run()
+		if err == nil {
+			os.Exit(0)
+		}
+		return err
 	}
 	return syscall.Exec(executablePath, cmdArgs, environment)
 }

@MIBc
Copy link
Contributor Author

MIBc commented Mar 18, 2020

Yes. It needs an exit code when using exec.Command on windows .

@MIBc
Copy link
Contributor Author

MIBc commented Mar 18, 2020

/retest

@dsimansk
Copy link
Contributor

Thanks!
/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 18, 2020
@maximilien
Copy link
Contributor

/lgtm

CHANGELOG.adoc Outdated Show resolved Hide resolved
@rhuss
Copy link
Contributor

rhuss commented Mar 20, 2020

When this PR is merged, can we cherry pick the commit also to release-0.13 branch so that it gets part of 0.13.1 ?

@navidshaikh
Copy link
Collaborator

+1 for getting this for 0.13.1

@MIBc : could you quickly fix the typo in CHANGELOG ?
or we can merge the PR and fix in cherry pick PR too.

Fixes knative#737

* Use exec.Command instend of syscall.Exec for windows.
* Fix a bug in plugin handler test when running it on windows.
* Fix typo.
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2020
@rhuss
Copy link
Contributor

rhuss commented Mar 20, 2020

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 20, 2020
@navidshaikh
Copy link
Collaborator

/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MIBc, navidshaikh

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 20, 2020
@knative-prow-robot knative-prow-robot merged commit 5e73d8d into knative:master Mar 20, 2020
dsimansk pushed a commit to dsimansk/client that referenced this pull request Mar 20, 2020
Fixes knative#737

* Use exec.Command instend of syscall.Exec for windows.
* Fix a bug in plugin handler test when running it on windows.
* Fix typo.
@MIBc MIBc deleted the plugin branch March 23, 2020 02:27
knative-prow-robot pushed a commit that referenced this pull request Mar 24, 2020
* fix(trigger): Make --filter flag truly optional (#745)

* fix(trigger): Make --filter flag truly optional

* fix(trigger): Update trigger docs

* chore: Update changelog

* fix(trigger): Fix filter delete for trigger update (#746)

* chore: Update changelog

* Fix plugin execution for Windows (#738)

Fixes #737

* Use exec.Command instend of syscall.Exec for windows.
* Fix a bug in plugin handler test when running it on windows.
* Fix typo.

* fix: Fix default config path on Windows (#752)

Co-authored-by: Lv Jiawei <[email protected]>
@navidshaikh navidshaikh added the backport/pr A backport PR which is target to a release branch. label Apr 20, 2020
@rhuss rhuss added backported-to/0.13 and removed backport/pr A backport PR which is target to a release branch. labels Apr 20, 2020
coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
rhuss added a commit to rhuss/knative-client that referenced this pull request Mar 9, 2021
David meets all criteria for an approver:

- [x] Reviewer for at least 3 months
- [x] Primary reviewer for at least 10 substantial PRs to the codebase, e.g.
  * knative#1246
  * knative#1194
  * knative#738
  * knative#832
  * knative#1016
  * knative#877
  * knative#667
  * knative#697
  * knative#1212
  * knative#835
- [x] Reviewed at least 30 PRs to the codebase ([38 assigned PRs](https://github.com/knative/client/pulls?q=type%3Apr+assignee%3Adsimansk+))
- [x] Nominated by a WG lead (rhuss)

Congrats David ! Thanks a lot for your awesome work & contributions.
@rhuss rhuss mentioned this pull request Mar 9, 2021
4 tasks
rhuss added a commit to rhuss/knative-client that referenced this pull request Mar 9, 2021
David meets all criteria for an approver:

- [x] Reviewer for at least 3 months
- [x] Primary reviewer for at least 10 substantial PRs to the codebase, e.g.
  * knative#1246
  * knative#1194
  * knative#738
  * knative#832
  * knative#1016
  * knative#877
  * knative#667
  * knative#697
  * knative#1212
  * knative#835
- [x] Reviewed at least 30 PRs to the codebase ([38 assigned PRs](https://github.com/knative/client/pulls?q=type%3Apr+assignee%3Adsimansk+))
- [x] Nominated by a WG lead (rhuss)

Congrats David ! Thanks a lot for your awesome work & contributions.
knative-prow-robot pushed a commit that referenced this pull request Mar 9, 2021
David meets all criteria for an approver:

- [x] Reviewer for at least 3 months
- [x] Primary reviewer for at least 10 substantial PRs to the codebase, e.g.
  * #1246
  * #1194
  * #738
  * #832
  * #1016
  * #877
  * #667
  * #697
  * #1212
  * #835
- [x] Reviewed at least 30 PRs to the codebase ([38 assigned PRs](https://github.com/knative/client/pulls?q=type%3Apr+assignee%3Adsimansk+))
- [x] Nominated by a WG lead (rhuss)

Congrats David ! Thanks a lot for your awesome work & contributions.
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugins can't be executed on Windows
8 participants