Merge pull request #1518 from anderbubble/container-exec-args
Simplify passing of arguments through wwctl container exec
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'`,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user