mirror of
https://github.com/containers/podman.git
synced 2025-06-21 17:38:12 +08:00
Merge pull request #13757 from andrewaylett/anonymous_volumes
Allow creating anonymous volumes with --mount
This commit is contained in:
@ -518,7 +518,7 @@ func getDevptsMount(args []string) (spec.Mount, error) {
|
|||||||
func getNamedVolume(args []string) (*specgen.NamedVolume, error) {
|
func getNamedVolume(args []string) (*specgen.NamedVolume, error) {
|
||||||
newVolume := new(specgen.NamedVolume)
|
newVolume := new(specgen.NamedVolume)
|
||||||
|
|
||||||
var setSource, setDest, setRORW, setSuid, setDev, setExec, setOwnership bool
|
var setDest, setRORW, setSuid, setDev, setExec, setOwnership bool
|
||||||
|
|
||||||
for _, val := range args {
|
for _, val := range args {
|
||||||
kv := strings.SplitN(val, "=", 2)
|
kv := strings.SplitN(val, "=", 2)
|
||||||
@ -554,7 +554,6 @@ func getNamedVolume(args []string) (*specgen.NamedVolume, error) {
|
|||||||
return nil, errors.Wrapf(optionArgError, kv[0])
|
return nil, errors.Wrapf(optionArgError, kv[0])
|
||||||
}
|
}
|
||||||
newVolume.Name = kv[1]
|
newVolume.Name = kv[1]
|
||||||
setSource = true
|
|
||||||
case "target", "dst", "destination":
|
case "target", "dst", "destination":
|
||||||
if len(kv) == 1 {
|
if len(kv) == 1 {
|
||||||
return nil, errors.Wrapf(optionArgError, kv[0])
|
return nil, errors.Wrapf(optionArgError, kv[0])
|
||||||
@ -585,9 +584,6 @@ func getNamedVolume(args []string) (*specgen.NamedVolume, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !setSource {
|
|
||||||
return nil, errors.Errorf("must set source volume")
|
|
||||||
}
|
|
||||||
if !setDest {
|
if !setDest {
|
||||||
return nil, noDestError
|
return nil, noDestError
|
||||||
}
|
}
|
||||||
|
@ -778,6 +778,13 @@ VOLUME /test/`, ALPINE)
|
|||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
Expect(session.OutputToString()).Should(Equal("888:888"))
|
Expect(session.OutputToString()).Should(Equal("888:888"))
|
||||||
|
|
||||||
|
// anonymous volume mount
|
||||||
|
vol = "type=volume," + "dst=" + dest
|
||||||
|
session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--mount", vol, ALPINE, "stat", "-c", "%u:%g", dest})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
Expect(session.OutputToString()).Should(Equal("888:888"))
|
||||||
|
|
||||||
// named volume mount
|
// named volume mount
|
||||||
namedVolume := podmanTest.Podman([]string{"volume", "create", "foo"})
|
namedVolume := podmanTest.Podman([]string{"volume", "create", "foo"})
|
||||||
namedVolume.WaitWithDefaultTimeout()
|
namedVolume.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user