summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-03-23 16:18:17 -0400
committerMatthew Heon <mheon@redhat.com>2020-03-26 13:33:33 -0400
commite42cbdd1b2f6788a814d6aa1838111989cd424ad (patch)
tree5705b12daaa8324c659717e72dfa523f83f5785b /libpod
parent0c40b62c77d8f7dba8e73ac3ced0de536ec220d5 (diff)
downloadpodman-e42cbdd1b2f6788a814d6aa1838111989cd424ad.tar.gz
podman-e42cbdd1b2f6788a814d6aa1838111989cd424ad.tar.bz2
podman-e42cbdd1b2f6788a814d6aa1838111989cd424ad.zip
Add bindings for Container Exec Create + Inspect
Also adds some basic tests for these two. More tests are needed but will have to wait for state to be finished. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_exec.go5
-rw-r--r--libpod/options.go2
2 files changed, 7 insertions, 0 deletions
diff --git a/libpod/container_exec.go b/libpod/container_exec.go
index 795eb7453..912c2c226 100644
--- a/libpod/container_exec.go
+++ b/libpod/container_exec.go
@@ -231,6 +231,11 @@ func (c *Container) ExecStartAndAttach(sessionID string, streams *AttachStreams)
}
}
+ // Verify that we are in a good state to continue
+ if !c.ensureState(define.ContainerStateRunning) {
+ return errors.Wrapf(define.ErrCtrStateInvalid, "can only start exec sessions when their container is running")
+ }
+
session, ok := c.state.ExecSessions[sessionID]
if !ok {
return errors.Wrapf(define.ErrNoSuchExecSession, "container %s has no exec session with ID %s", c.ID(), sessionID)
diff --git a/libpod/options.go b/libpod/options.go
index 9b61d7947..74f9c485e 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -21,6 +21,8 @@ import (
var (
// NameRegex is a regular expression to validate container/pod names.
+ // This must NOT be changed from outside of Libpod. It should be a
+ // constant, but Go won't let us do that.
NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
// RegexError is thrown in presence of an invalid container/pod name.
RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")