mirror of https://github.com/k3s-io/k3s
Merge pull request #50672 from shiywang/fix0error
Automatic merge from submit-queue (batch tested with PRs 50890, 52484, 52542, 52567, 50672). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Fix return 0 error in DefaultSubCommandRun Fixes https://github.com/kubernetes/kubernetes/issues/50644 @mengqiy most of our command didn't return 1 when error, is because it invoke `DefaultSubCommandRun` which created in this pr https://github.com/kubernetes/kubernetes/pull/35206, I'm not sure if it's ok to directly add an `os.Exit` in that function, so also cc @juanvallejo @fabianofranz for review. also @apelisse @mengqiy I think we don't have any test for check return value now ? cmiiw, I will add some test in test-cmd since it's easy to write scripts check return value, wdyt ?pull/6/head
commit
963697564a
|
@ -4188,7 +4188,7 @@ run_plugins_tests() {
|
|||
kube::test::if_has_string "${output_message}" 'no plugins installed'
|
||||
|
||||
# single plugins path
|
||||
output_message=$(KUBECTL_PLUGINS_PATH=test/fixtures/pkg/kubectl/plugins kubectl plugin 2>&1)
|
||||
output_message=$(! KUBECTL_PLUGINS_PATH=test/fixtures/pkg/kubectl/plugins kubectl plugin 2>&1)
|
||||
kube::test::if_has_string "${output_message}" 'echo\s\+Echoes for test-cmd'
|
||||
kube::test::if_has_string "${output_message}" 'get\s\+The wonderful new plugin-based get!'
|
||||
kube::test::if_has_string "${output_message}" 'error\s\+The tremendous plugin that always fails!'
|
||||
|
@ -4225,7 +4225,7 @@ run_plugins_tests() {
|
|||
kube::test::if_has_string "${output_message}" 'error: exit status 1'
|
||||
|
||||
# plugin tree
|
||||
output_message=$(KUBECTL_PLUGINS_PATH=test/fixtures/pkg/kubectl/plugins kubectl plugin tree 2>&1)
|
||||
output_message=$(! KUBECTL_PLUGINS_PATH=test/fixtures/pkg/kubectl/plugins kubectl plugin tree 2>&1)
|
||||
kube::test::if_has_string "${output_message}" 'Plugin with a tree of commands'
|
||||
kube::test::if_has_string "${output_message}" 'child1\s\+The first child of a tree'
|
||||
kube::test::if_has_string "${output_message}" 'child2\s\+The second child of a tree'
|
||||
|
|
|
@ -778,6 +778,7 @@ func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string) {
|
|||
c.SetOutput(out)
|
||||
RequireNoArguments(c, args)
|
||||
c.Help()
|
||||
CheckErr(ErrExit)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue