summaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-10-27 15:50:03 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-10-27 15:50:03 -0400
commit63efde15f14b18f5af385e89936b4ab0868cb357 (patch)
treee40c8b71e2e24cb3b375e2c2cfd15a835d946fed /libpod/in_memory_state.go
parent6af7e544636ae66ce237489ce6948123e1b3249d (diff)
downloadpodman-63efde15f14b18f5af385e89936b4ab0868cb357.tar.gz
podman-63efde15f14b18f5af385e89936b4ab0868cb357.tar.bz2
podman-63efde15f14b18f5af385e89936b4ab0868cb357.zip
Add a way to retrieve all network aliases for a ctr
The original interface only allowed retrieving aliases for a specific network, not for all networks. This will allow aliases to be retrieved for every network the container is present in, in a single DB operation. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r--libpod/in_memory_state.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index 66c2a5cbd..3b88c9664 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -568,6 +568,25 @@ func (s *InMemoryState) GetNetworkAliases(ctr *Container, network string) ([]str
return netAliases, nil
}
+// GetAllNetworkAliases gets all network aliases for the given container.
+func (s *InMemoryState) GetAllNetworkAliases(ctr *Container) (map[string][]string, error) {
+ if !ctr.valid {
+ return nil, define.ErrCtrRemoved
+ }
+
+ ctr, ok := s.containers[ctr.ID()]
+ if !ok {
+ return nil, define.ErrNoSuchCtr
+ }
+
+ ctrAliases, ok := s.ctrNetworkAliases[ctr.ID()]
+ if !ok {
+ return map[string][]string{}, nil
+ }
+
+ return ctrAliases, nil
+}
+
// SetNetworkAliases sets network aliases for the given container in the given
// network.
func (s *InMemoryState) SetNetworkAliases(ctr *Container, network string, aliases []string) error {