diff --git a/docs/source/markdown/options/mount.md b/docs/source/markdown/options/mount.md index 39dafa9304..0d298c61b4 100644 --- a/docs/source/markdown/options/mount.md +++ b/docs/source/markdown/options/mount.md @@ -13,7 +13,7 @@ Options common to all mount types: - *src*, *source*: mount source spec for **bind**, **glob**, and **volume**. Mandatory for **artifact**, **bind**, **glob**, **image** and **volume**. -- *dst*, *destination*, *target*: mount destination spec. +- *dst*, *dest*, *destination*, *target*: mount destination spec. When source globs are specified without the destination directory, the files and directories are mounted with their complete path diff --git a/pkg/specgenutil/volumes.go b/pkg/specgenutil/volumes.go index 7fa497c75b..02a7627a36 100644 --- a/pkg/specgenutil/volumes.go +++ b/pkg/specgenutil/volumes.go @@ -446,7 +446,7 @@ func parseMountOptions(mountType string, args []string) (*universalMount, error) return nil, fmt.Errorf("%v: %w", name, errOptionArg) } mnt.subPath = value - case "target", "dst", "destination": + case "target", "dst", "dest", "destination": if mnt.mount.Destination != "" { return nil, fmt.Errorf("cannot pass %q option more than once: %w", name, errOptionArg) } @@ -617,7 +617,7 @@ func getDevptsMount(args []string) (spec.Mount, error) { switch name { case "uid", "gid", "mode", "ptmxmode", "newinstance", "max": newMount.Options = append(newMount.Options, arg) - case "target", "dst", "destination": + case "target", "dst", "dest", "destination": if !hasValue { return newMount, fmt.Errorf("%v: %w", name, errOptionArg) } @@ -674,7 +674,7 @@ func getImageVolume(args []string) (*specgen.ImageVolume, error) { return nil, fmt.Errorf("%v: %w", name, errOptionArg) } newVolume.Source = value - case "target", "dst", "destination": + case "target", "dst", "dest", "destination": if !hasValue { return nil, fmt.Errorf("%v: %w", name, errOptionArg) } @@ -728,7 +728,7 @@ func getArtifactVolume(args []string) (*specgen.ArtifactVolume, error) { return nil, fmt.Errorf("%v: %w", name, errOptionArg) } newVolume.Source = value - case "target", "dst", "destination": + case "target", "dst", "dest", "destination": if !hasValue { return nil, fmt.Errorf("%v: %w", name, errOptionArg) } diff --git a/pkg/specgenutilexternal/mount.go b/pkg/specgenutilexternal/mount.go index 2671817e1f..eb48ab7fb9 100644 --- a/pkg/specgenutilexternal/mount.go +++ b/pkg/specgenutilexternal/mount.go @@ -6,10 +6,6 @@ import ( "strings" ) -var ( - errInvalidSyntax = errors.New("incorrect mount format: should be --mount type=,[src=,]target=[,options]") -) - // FindMountType parses the input and extracts the type of the mount type and // the remaining non-type tokens. func FindMountType(input string) (mountType string, tokens []string, err error) { @@ -22,7 +18,7 @@ func FindMountType(input string) (mountType string, tokens []string, err error) return "", nil, err } if len(records) != 1 { - return "", nil, errInvalidSyntax + return "", nil, errors.New("incorrect mount format: should be --mount type=,[src=,]target=[,options]") } for _, s := range records[0] { kv := strings.Split(s, "=") @@ -34,7 +30,7 @@ func FindMountType(input string) (mountType string, tokens []string, err error) found = true } if !found { - err = errInvalidSyntax + mountType = "volume" } return } diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index 7742e655ba..ae4625055c 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -1122,4 +1122,13 @@ RUN chmod 755 /test1 /test2 /test3`, ALPINE) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) + + It("--mount flag defaults to volume if no type given", func() { + volName := "testvol" + podmanTest.PodmanExitCleanly("volume", "create", volName) + + podmanTest.PodmanExitCleanly("run", "--rm", "--mount", fmt.Sprintf("src=%s,dest=/mnt", volName), ALPINE, "touch", "/mnt/testfile") + outTest := podmanTest.PodmanExitCleanly("run", "--rm", "--mount", fmt.Sprintf("type=volume,src=%s,dest=/mnt", volName), ALPINE, "ls", "/mnt") + Expect(outTest.OutputToString()).To(ContainSubstring("testfile")) + }) })