diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-04-30 11:09:48 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-03 12:23:12 +0000 |
commit | a0e8f887009bb336ef887df0ffbb9561a603bf35 (patch) | |
tree | e439723f44c74366ae9c8994cf81e648356f92a4 /libpod/options.go | |
parent | f6d41abfb04550f473b80d89cf8c02e5744a5b0b (diff) | |
download | podman-a0e8f887009bb336ef887df0ffbb9561a603bf35.tar.gz podman-a0e8f887009bb336ef887df0ffbb9561a603bf35.tar.bz2 podman-a0e8f887009bb336ef887df0ffbb9561a603bf35.zip |
Add config bool to indicate there are user volumes
This allows us to accurately trigger OCI hooks that trigger on
the presence of volume mounts.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #700
Approved by: rhatdan
Diffstat (limited to 'libpod/options.go')
-rw-r--r-- | libpod/options.go | 85 |
1 files changed, 49 insertions, 36 deletions
diff --git a/libpod/options.go b/libpod/options.go index 981ca9a9d..eabb9d425 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -741,42 +741,6 @@ func WithCgroupParent(parent string) CtrCreateOption { } } -// Pod Creation Options - -// WithPodName sets the name of the pod -func WithPodName(name string) PodCreateOption { - return func(pod *Pod) error { - if pod.valid { - return ErrPodFinalized - } - - // Check the name against a regex - if !nameRegex.MatchString(name) { - return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+") - } - - pod.config.Name = name - - return nil - } -} - -// WithPodLabels sets the labels of a pod -func WithPodLabels(labels map[string]string) PodCreateOption { - return func(pod *Pod) error { - if pod.valid { - return ErrPodFinalized - } - - pod.config.Labels = make(map[string]string) - for key, value := range labels { - pod.config.Labels[key] = value - } - - return nil - } -} - // WithDNSSearch sets the additional search domains of a container func WithDNSSearch(searchDomains []string) CtrCreateOption { return func(ctr *Container) error { @@ -850,3 +814,52 @@ func WithGroups(groups []string) CtrCreateOption { return nil } } + +// WithUserVolumes informs libpod that the container has user-added volumes +// It is used to for triggering hooks that check for the presence of volume +// mounts +func WithUserVolumes() CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return ErrCtrFinalized + } + ctr.config.UserVolumes = true + return nil + } +} + +// Pod Creation Options + +// WithPodName sets the name of the pod +func WithPodName(name string) PodCreateOption { + return func(pod *Pod) error { + if pod.valid { + return ErrPodFinalized + } + + // Check the name against a regex + if !nameRegex.MatchString(name) { + return errors.Wrapf(ErrInvalidArg, "name must match regex [a-zA-Z0-9_-]+") + } + + pod.config.Name = name + + return nil + } +} + +// WithPodLabels sets the labels of a pod +func WithPodLabels(labels map[string]string) PodCreateOption { + return func(pod *Pod) error { + if pod.valid { + return ErrPodFinalized + } + + pod.config.Labels = make(map[string]string) + for key, value := range labels { + pod.config.Labels[key] = value + } + + return nil + } +} |