aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/common/createparse.go
blob: 09ee5aa0ce2c84d09dbca4929c116d6500080e38 (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, when the restartPolicy is not "" and "no"`)
	}

	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

}