summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2023-03-15 14:27:04 +0100
committerSebastiaan van Stijn <github@gone.nl>2023-03-15 18:49:15 +0100
commit58504620c52704e0f069a7b8aeba4c3911e18235 (patch)
tree8f256dc54525fdb4d8e0c5237cc15782ecbc18b5 /api
parent6f0e28d024ba71c3a134fae1fd4294a651cff2fb (diff)
downloaddocker-58504620c52704e0f069a7b8aeba4c3911e18235.tar.gz
api/types/container: IpcMode: use common function for container-mode
Use the utility introduced in 1bd486666b858c11451495c9eb803eda3184e58c to share the same implementation as similar options. The IPCModeContainer const is left for now, but we need to consider what to do with these. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'api')
-rw-r--r--api/types/container/hostconfig.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/api/types/container/hostconfig.go b/api/types/container/hostconfig.go
index 7459b8cc6a..d4e6f55375 100644
--- a/api/types/container/hostconfig.go
+++ b/api/types/container/hostconfig.go
@@ -101,7 +101,8 @@ func (n IpcMode) IsShareable() bool {
// IsContainer indicates whether the container uses another container's ipc namespace.
func (n IpcMode) IsContainer() bool {
- return strings.HasPrefix(string(n), string(IPCModeContainer)+":")
+ _, ok := containerID(string(n))
+ return ok
}
// IsNone indicates whether container IpcMode is set to "none".
@@ -121,11 +122,9 @@ func (n IpcMode) Valid() bool {
}
// Container returns the name of the container ipc stack is going to be used.
-func (n IpcMode) Container() string {
- if n.IsContainer() {
- return strings.TrimPrefix(string(n), string(IPCModeContainer)+":")
- }
- return ""
+func (n IpcMode) Container() (idOrName string) {
+ idOrName, _ = containerID(string(n))
+ return idOrName
}
// NetworkMode represents the container network stack.