summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-07-07 17:19:59 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-07-22 14:39:41 -0400
commit0630d19b34c6cea674fc5f830fe308b8a1206259 (patch)
tree1e5eeeb038f6132e2f070ffd695d73507f0c7cc1 /libpod/options.go
parent800595a0a325e841d5888a33e3114c20c944d9b4 (diff)
downloadpodman-0630d19b34c6cea674fc5f830fe308b8a1206259.tar.gz
podman-0630d19b34c6cea674fc5f830fe308b8a1206259.tar.bz2
podman-0630d19b34c6cea674fc5f830fe308b8a1206259.zip
Fix container and pod create commands for remote create
In `podman inspect` output for containers and pods, we include the command that was used to create the container. This is also used by `podman generate systemd --new` to generate unit files. With remote podman, the generated create commands were incorrect since we sourced directly from os.Args on the server side, which was guaranteed to be `podman system service` (or some variant thereof). The solution is to pass the command along in the Specgen or PodSpecgen, where we can source it from the client's os.Args. This will still be VERY iffy for mixed local/remote use (doing a `podman --remote run ...` on a remote client then a `podman generate systemd --new` on the server on the same container will not work, because the `--remote` flag will slip in) but at the very least the output of `podman inspect` will be correct. We can look into properly handling `--remote` (parsing it out would be a little iffy) in a future PR. Signed-off-by: Matthew Heon <matthew.heon@pm.me> <MH: Fixed build after cherry-pick> Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 3120a35d7..bff3f3c18 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1371,12 +1371,12 @@ func WithHealthCheck(healthCheck *manifest.Schema2HealthConfig) CtrCreateOption
// WithCreateCommand adds the full command plus arguments of the current
// process to the container config.
-func WithCreateCommand() CtrCreateOption {
+func WithCreateCommand(cmd []string) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
return define.ErrCtrFinalized
}
- ctr.config.CreateCommand = os.Args
+ ctr.config.CreateCommand = cmd
return nil
}
}
@@ -1553,12 +1553,12 @@ func WithPodHostname(hostname string) PodCreateOption {
// WithPodCreateCommand adds the full command plus arguments of the current
// process to the pod config.
-func WithPodCreateCommand() PodCreateOption {
+func WithPodCreateCommand(createCmd []string) PodCreateOption {
return func(pod *Pod) error {
if pod.valid {
return define.ErrPodFinalized
}
- pod.config.CreateCommand = os.Args
+ pod.config.CreateCommand = createCmd
return nil
}
}