mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #50384 from thaJeztah/daemon_inspect_unify
daemon: consolidate platform-specific inspectExecProcessConfig
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
@@ -204,24 +205,37 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err
|
||||
|
||||
e.Lock()
|
||||
defer e.Unlock()
|
||||
pc := inspectExecProcessConfig(e)
|
||||
var pid int
|
||||
if e.Process != nil {
|
||||
pid = int(e.Process.Pid())
|
||||
}
|
||||
var privileged *bool
|
||||
if runtime.GOOS != "windows" || e.Privileged {
|
||||
// Privileged is not used on Windows, so should always be false
|
||||
// (and omitted in the response), but set it if it happened to
|
||||
// be true. On non-Windows, we always set it, and the field should
|
||||
// not be omitted.
|
||||
privileged = &e.Privileged
|
||||
}
|
||||
|
||||
return &backend.ExecInspect{
|
||||
ID: e.ID,
|
||||
Running: e.Running,
|
||||
ExitCode: e.ExitCode,
|
||||
ProcessConfig: pc,
|
||||
OpenStdin: e.OpenStdin,
|
||||
OpenStdout: e.OpenStdout,
|
||||
OpenStderr: e.OpenStderr,
|
||||
CanRemove: e.CanRemove,
|
||||
ContainerID: e.Container.ID,
|
||||
DetachKeys: e.DetachKeys,
|
||||
Pid: pid,
|
||||
ID: e.ID,
|
||||
Running: e.Running,
|
||||
ExitCode: e.ExitCode,
|
||||
ProcessConfig: &backend.ExecProcessConfig{
|
||||
Tty: e.Tty,
|
||||
Entrypoint: e.Entrypoint,
|
||||
Arguments: e.Args,
|
||||
Privileged: privileged, // Privileged is not used on Windows
|
||||
User: e.User, // User is not used on Windows
|
||||
},
|
||||
OpenStdin: e.OpenStdin,
|
||||
OpenStdout: e.OpenStdout,
|
||||
OpenStderr: e.OpenStderr,
|
||||
CanRemove: e.CanRemove,
|
||||
ContainerID: e.Container.ID,
|
||||
DetachKeys: e.DetachKeys,
|
||||
Pid: pid,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package daemon
|
||||
import (
|
||||
"github.com/moby/moby/api/types/container"
|
||||
containerpkg "github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
)
|
||||
|
||||
// This sets platform-specific fields
|
||||
@@ -15,13 +14,3 @@ func setPlatformSpecificContainerFields(container *containerpkg.Container, contJ
|
||||
|
||||
return contJSONBase
|
||||
}
|
||||
|
||||
func inspectExecProcessConfig(e *containerpkg.ExecConfig) *backend.ExecProcessConfig {
|
||||
return &backend.ExecProcessConfig{
|
||||
Tty: e.Tty,
|
||||
Entrypoint: e.Entrypoint,
|
||||
Arguments: e.Args,
|
||||
Privileged: &e.Privileged,
|
||||
User: e.User,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,9 @@ package daemon
|
||||
import (
|
||||
"github.com/moby/moby/api/types/container"
|
||||
containerpkg "github.com/moby/moby/v2/daemon/container"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
)
|
||||
|
||||
// This sets platform-specific fields
|
||||
func setPlatformSpecificContainerFields(container *containerpkg.Container, contJSONBase *container.ContainerJSONBase) *container.ContainerJSONBase {
|
||||
return contJSONBase
|
||||
}
|
||||
|
||||
func inspectExecProcessConfig(e *containerpkg.ExecConfig) *backend.ExecProcessConfig {
|
||||
return &backend.ExecProcessConfig{
|
||||
Tty: e.Tty,
|
||||
Entrypoint: e.Entrypoint,
|
||||
Arguments: e.Args,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user