aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/common/createparse.go
blob: 059f9050f2dbc687d2ae0bc28fa21128bdebdd5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package common

import (
	"github.com/containers/podman/v2/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
	}

	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

}