Skip to content
This repository was archived by the owner on Nov 9, 2020. It is now read-only.

Commit 51fc34d

Browse files
committed
Fix vsan datastore affinity parse error
VSAN datastore id contains ':', e.g. vsan:5702b3e6ff547cfa-d912ecf4bbdc5db0. So an affinity string may contain more than 2 ':'s. To handle this case, we need to tell Split method to only split at the first ':'. Affinity kind should never contain ':', but the id may. Change-Id: I7206db322d1322e9a62a010986897c508893ced8
1 parent 2ce7735 commit 51fc34d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

photon/command/flagparsehelpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func parseAffinitiesListFromFlag(affinities string) ([]photon.LocalitySpec, erro
4848
if len(affinities) != 0 {
4949
affinitiesListOri := regexp.MustCompile(`\s*,\s*`).Split(affinities, -1)
5050
for i := 0; i < len(affinitiesListOri); i++ {
51-
affinity := regexp.MustCompile(`\s*:\s*`).Split(affinitiesListOri[i], -1)
51+
affinity := regexp.MustCompile(`\s*:\s*`).Split(affinitiesListOri[i], 2)
5252
if len(affinity) != 2 {
5353
return affinitiesList, fmt.Errorf("Error parsing affinities, should be: <kind>:<id>, <kind>:<id>...")
5454
}

0 commit comments

Comments
 (0)