aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-08-10 12:59:06 -0400
committerGitHub <noreply@github.com>2020-08-10 12:59:06 -0400
commit68fd9aa2cf67a749258ccdc6fa8fd89c2557ebfc (patch)
treec3b6d5d3f767326407e80f54324acb45daa0fa45 /libpod/runtime.go
parent5ba21849a517659203a5879553f5dfb20963b7b5 (diff)
parent569854d6348e1cd74e8d654c88720e5517898f1a (diff)
downloadpodman-68fd9aa2cf67a749258ccdc6fa8fd89c2557ebfc.tar.gz
podman-68fd9aa2cf67a749258ccdc6fa8fd89c2557ebfc.tar.bz2
podman-68fd9aa2cf67a749258ccdc6fa8fd89c2557ebfc.zip
Merge pull request #7223 from mheon/fix_7214
Unconditionally retrieve pod names via API
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 3021ef3f4..8a7053e33 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -732,6 +732,22 @@ func (r *Runtime) GetStore() storage.Store {
return r.store
}
+// GetName retrieves the name associated with a given full ID.
+// This works for both containers and pods, and does not distinguish between the
+// two.
+// If the given ID does not correspond to any existing Pod or Container,
+// ErrNoSuchCtr is returned.
+func (r *Runtime) GetName(id string) (string, error) {
+ r.lock.RLock()
+ defer r.lock.RUnlock()
+
+ if !r.valid {
+ return "", define.ErrRuntimeStopped
+ }
+
+ return r.state.GetName(id)
+}
+
// DBConfig is a set of Libpod runtime configuration settings that are saved in
// a State when it is first created, and can subsequently be retrieved.
type DBConfig struct {