diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-22 07:08:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 07:08:32 -0400 |
commit | 04acbaa4b161b23e93b990321582b1586d86f2a8 (patch) | |
tree | 746b762b7450ed10d6500a97f7199fc1fd876c1c /pkg | |
parent | 0d6af1438710acc03ef9e7395e1bc8ecf46f4294 (diff) | |
parent | f87f23e3b624e2831d501589c84767ff11419398 (diff) | |
download | podman-04acbaa4b161b23e93b990321582b1586d86f2a8.tar.gz podman-04acbaa4b161b23e93b990321582b1586d86f2a8.tar.bz2 podman-04acbaa4b161b23e93b990321582b1586d86f2a8.zip |
Merge pull request #13969 from flouthoc/mount-csv-parsing
specgen-volumes: parse `--mount` using csv-reader instead of split.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgenutil/volumes.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/specgenutil/volumes.go b/pkg/specgenutil/volumes.go index aa07de0af..95ce420f8 100644 --- a/pkg/specgenutil/volumes.go +++ b/pkg/specgenutil/volumes.go @@ -1,6 +1,7 @@ package specgenutil import ( + "encoding/csv" "fmt" "path/filepath" "strings" @@ -152,7 +153,15 @@ func findMountType(input string) (mountType string, tokens []string, err error) // Split by comma, iterate over the slice and look for // "type=$mountType". Everything else is appended to tokens. found := false - for _, s := range strings.Split(input, ",") { + csvReader := csv.NewReader(strings.NewReader(input)) + records, err := csvReader.ReadAll() + if err != nil { + return "", nil, err + } + if len(records) != 1 { + return "", nil, errInvalidSyntax + } + for _, s := range records[0] { kv := strings.Split(s, "=") if found || !(len(kv) == 2 && kv[0] == "type") { tokens = append(tokens, s) |