Skip to content

Comments

fix: restore os.Args after plugin completion and fix error return#6817

Open
luojiyin1987 wants to merge 1 commit intodocker:masterfrom
luojiyin1987:fix-plugin-cobra
Open

fix: restore os.Args after plugin completion and fix error return#6817
luojiyin1987 wants to merge 1 commit intodocker:masterfrom
luojiyin1987:fix-plugin-cobra

Conversation

@luojiyin1987
Copy link

- What I did

Fix two issues in the plugin manager:

  1. Fix error return value: The plugin stub was returning the wrong error variable when flag parsing failed
  2. Restore os.Args after plugin completion: The global os.Args was being modified during plugin completion but not restored, which could cause side effects in subsequent code

- How I did it

  1. Changed the error return from err to perr when flag parsing fails
  2. Added code to save the original os.Args before modification and use defer to restore it
  3. Added comprehensive tests to verify both fixes

- Files changed:

File Change
cli-plugins/manager/cobra.go Fix error return + restore os.Args
cli-plugins/manager/cobra_test.go Add regression tests

- How to verify it

The new tests verify both scenarios.

- Description for the changelog

bug fix: restore os.Args after plugin completion and fix error return

Fixes #6816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: restore os.Args after plugin completion and fix error return

1 participant