summaryrefslogtreecommitdiff
path: root/cmd/podmanV2/common/createparse.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-29 11:25:56 -0500
committerBrent Baude <bbaude@redhat.com>2020-04-03 15:43:03 -0500
commit6514a5c80ef91ef6e16e283339cd0b5f78a42322 (patch)
tree33ced51adee58d38b39416191e2e8a207ce4ec47 /cmd/podmanV2/common/createparse.go
parent35f586783388cdff6b4f15e7aff4df1ee72d9b67 (diff)
downloadpodman-6514a5c80ef91ef6e16e283339cd0b5f78a42322.tar.gz
podman-6514a5c80ef91ef6e16e283339cd0b5f78a42322.tar.bz2
podman-6514a5c80ef91ef6e16e283339cd0b5f78a42322.zip
v2podman container create
create a container in podmanv2 using specgen approach. this is the core implementation and still has quite a bit of code commented out specifically around volumes, devices, and namespaces. need contributions from smes on these parts. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podmanV2/common/createparse.go')
-rw-r--r--cmd/podmanV2/common/createparse.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/cmd/podmanV2/common/createparse.go b/cmd/podmanV2/common/createparse.go
new file mode 100644
index 000000000..89524a04b
--- /dev/null
+++ b/cmd/podmanV2/common/createparse.go
@@ -0,0 +1,51 @@
+package common
+
+import (
+ "github.com/containers/libpod/cmd/podmanV2/parse"
+ "github.com/containers/libpod/pkg/util"
+ "github.com/pkg/errors"
+)
+
+// validate determines if the flags and values given by the user are valid. things checked
+// by validate must not need any state information on the flag (i.e. changed)
+func (c *ContainerCLIOpts) validate() error {
+ var ()
+ if c.Rm && c.Restart != "" && c.Restart != "no" {
+ return errors.Errorf("the --rm option conflicts with --restart")
+ }
+
+ if _, err := util.ValidatePullType(c.Pull); err != nil {
+ return err
+ }
+ // Verify the additional hosts are in correct format
+ for _, host := range c.Net.AddHosts {
+ if _, err := parse.ValidateExtraHost(host); err != nil {
+ return err
+ }
+ }
+
+ if dnsSearches := c.Net.DNSSearch; len(dnsSearches) > 0 {
+ // Validate domains are good
+ for _, dom := range dnsSearches {
+ if dom == "." {
+ if len(dnsSearches) > 1 {
+ return errors.Errorf("cannot pass additional search domains when also specifying '.'")
+ }
+ continue
+ }
+ if _, err := parse.ValidateDomain(dom); err != nil {
+ return err
+ }
+ }
+ }
+ var imageVolType = map[string]string{
+ "bind": "",
+ "tmpfs": "",
+ "ignore": "",
+ }
+ if _, ok := imageVolType[c.ImageVolume]; !ok {
+ return errors.Errorf("invalid image-volume type %q. Pick one of bind, tmpfs, or ignore", c.ImageVolume)
+ }
+ return nil
+
+}