From a0c58e418385a4d5ebd212e49872a750b9d63e6d Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 1 Nov 2024 19:55:54 -0600 Subject: [PATCH] Simplify passing of arguments through wwctl container exec Signed-off-by: Jonathon Anderson --- CHANGELOG.md | 1 + internal/app/wwctl/container/exec/main.go | 1 + internal/app/wwctl/container/exec/main_test.go | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0875851..dfa40b03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix issue that NetworkManager marks managed interfaces "unmanaged" if they do not have a device specified. #1154 - Return non-zero exit code on overlay sub-commands #1423 +- Simplify passing of arguments to commands through `wwctl container exec`. #253 ## v4.5.8, 2024-10-01 diff --git a/internal/app/wwctl/container/exec/main.go b/internal/app/wwctl/container/exec/main.go index 508c3d69..195775e4 100644 --- a/internal/app/wwctl/container/exec/main.go +++ b/internal/app/wwctl/container/exec/main.go @@ -61,6 +61,7 @@ func runContainedCmd(cmd *cobra.Command, containerName string, args []string) (e if nodeName != "" { childArgs = append(childArgs, "--node", nodeName) } + childArgs = append(childArgs, "--") childArgs = append(childArgs, args...) // copy the files into the container at this stage, es in __child the // command syscall.Exec which replaces the __child process with the diff --git a/internal/app/wwctl/container/exec/main_test.go b/internal/app/wwctl/container/exec/main_test.go index d17c4651..bf3af8c2 100644 --- a/internal/app/wwctl/container/exec/main_test.go +++ b/internal/app/wwctl/container/exec/main_test.go @@ -40,27 +40,27 @@ func Test_Exec(t *testing.T) { { name: "plain test", args: []string{"test", "/bin/true"}, - stdout: `--loglevel 20 container exec __child test /bin/true`, + stdout: `--loglevel 20 container exec __child test -- /bin/true`, }, { name: "test with --bind", args: []string{"test", "--bind", "/tmp", "/bin/true"}, - stdout: `--loglevel 20 container exec __child test --bind /tmp /bin/true`, + stdout: `--loglevel 20 container exec __child test --bind /tmp -- /bin/true`, }, { name: "test with --node", args: []string{"test", "--node", "node1", "/bin/true"}, - stdout: `--loglevel 20 container exec __child test --node node1 /bin/true`, + stdout: `--loglevel 20 container exec __child test --node node1 -- /bin/true`, }, { name: "test with --node and --bind", args: []string{"test", "--bind", "/tmp", "--node", "node1", "/bin/true"}, - stdout: `--loglevel 20 container exec __child test --bind /tmp --node node1 /bin/true`, + stdout: `--loglevel 20 container exec __child test --bind /tmp --node node1 -- /bin/true`, }, { name: "test with complex command", args: []string{"test", "/bin/bash", "echo 'hello'"}, - stdout: `--loglevel 20 container exec __child test /bin/bash echo 'hello'`, + stdout: `--loglevel 20 container exec __child test -- /bin/bash echo 'hello'`, }, }