Skip to content

Commit fcbb58a

Browse files
Merge pull request #18113 from juanvallejo/jvallejo/fix-oadm-cmd
Automatic merge from submit-queue (batch tested with PRs 18075, 17725, 16766, 18070, 18113). fix args passed to exec syscall Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534315 The `oadm` top-level cmd made exec calls to `oc`, relaying its arguments to it. It failed to pass a "base" command argument, which meant that the first argument that it passed to `oc` was ignored/treated as the binary name in `oc`. This meant that every command relayed from `oadm` to `oc adm` would be executed without the `adm` arg, causing every command except `oadm version` to fail. What this also means is that this fix would break `oadm version` as there is no `oc adm version` sub-command: ``` $ oadm version DEPRECATED: The 'oadm' command is deprecated, please use 'oc adm' instead. error: unknown command "version" See 'oc adm -h' for help and examples. ``` cc @deads2k @soltysh
2 parents f28be5d + c817087 commit fcbb58a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/oadm/main.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ func main() {
2424

2525
fmt.Fprintf(os.Stderr, "DEPRECATED: The 'oadm' command is deprecated, please use '%s adm' instead.\n", baseCommand)
2626

27-
if err := syscall.Exec(path, append([]string{"adm"}, os.Args[1:]...), os.Environ()); err != nil {
27+
admCmd := ""
28+
29+
// there is no `oc adm version` command.
30+
// special-case it here.
31+
if os.Args[1] != "version" {
32+
admCmd = "adm"
33+
}
34+
35+
if err := syscall.Exec(path, append([]string{baseCommand, admCmd}, os.Args[1:]...), os.Environ()); err != nil {
2836
fmt.Fprintf(os.Stderr, "%v\n", err)
2937
os.Exit(1)
3038
}

0 commit comments

Comments
 (0)