parseMounts parses a list of mounts from containerMounts. The format should be "src:dst[:ro],src:dst[:ro]".
(containerMounts string)
| 912 | // parseMounts parses a list of mounts from containerMounts. The format should |
| 913 | // be "src:dst[:ro],src:dst[:ro]". |
| 914 | func parseMounts(containerMounts string) ([]xunix.Mount, error) { |
| 915 | if containerMounts == "" { |
| 916 | return nil, nil |
| 917 | } |
| 918 | |
| 919 | mountsStr := strings.Split(containerMounts, ",") |
| 920 | |
| 921 | mounts := make([]xunix.Mount, 0, len(mountsStr)) |
| 922 | for _, mount := range mountsStr { |
| 923 | tokens := strings.Split(mount, ":") |
| 924 | if len(tokens) < 2 || len(tokens) > 3 { |
| 925 | return nil, xerrors.Errorf("malformed mounts value %q", containerMounts) |
| 926 | } |
| 927 | m := xunix.Mount{ |
| 928 | Source: tokens[0], |
| 929 | Mountpoint: tokens[1], |
| 930 | } |
| 931 | if len(tokens) == 3 { |
| 932 | m.ReadOnly = tokens[2] == "ro" |
| 933 | } |
| 934 | mounts = append(mounts, m) |
| 935 | } |
| 936 | |
| 937 | return mounts, nil |
| 938 | } |
| 939 | |
| 940 | // defaultContainerEnvs returns environment variables that should always |
| 941 | // be passed to the inner container. |