Merge pull request #22204 from thockin/path-colon

Validate volume paths do not have ':'
pull/6/head
Jeff Lowdermilk 2016-03-03 11:41:47 -08:00
commit b05cf6d53a
10 changed files with 14 additions and 10 deletions

View File

@ -1965,7 +1965,7 @@
},
"mountPath": {
"type": "string",
"description": "Path within the container at which the volume should be mounted."
"description": "Path within the container at which the volume should be mounted. Must not contain ':'."
}
}
},

View File

@ -6293,7 +6293,7 @@
},
"mountPath": {
"type": "string",
"description": "Path within the container at which the volume should be mounted."
"description": "Path within the container at which the volume should be mounted. Must not contain ':'."
}
}
},

View File

@ -16826,7 +16826,7 @@
},
"mountPath": {
"type": "string",
"description": "Path within the container at which the volume should be mounted."
"description": "Path within the container at which the volume should be mounted. Must not contain ':'."
}
}
},

View File

@ -814,7 +814,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">mountPath</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path within the container at which the volume should be mounted.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path within the container at which the volume should be mounted. Must not contain <em>:</em>.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
@ -5591,7 +5591,7 @@ Populated by the system when a graceful deletion is requested. Read-only. More i
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-02-27 01:28:36 UTC
Last updated 2016-02-29 20:12:48 UTC
</div>
</div>
</body>

View File

@ -764,7 +764,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">mountPath</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path within the container at which the volume should be mounted.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path within the container at which the volume should be mounted. Must not contain <em>:</em>.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
@ -7488,7 +7488,7 @@ The resulting set of endpoints can be viewed as:<br>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-02-27 01:28:28 UTC
Last updated 2016-02-29 20:12:40 UTC
</div>
</div>
</body>

View File

@ -742,7 +742,7 @@ type VolumeMount struct {
Name string `json:"name"`
// Optional: Defaults to false (read-write).
ReadOnly bool `json:"readOnly,omitempty"`
// Required.
// Required. Must not contain ':'.
MountPath string `json:"mountPath"`
}

View File

@ -866,7 +866,8 @@ type VolumeMount struct {
// Mounted read-only if true, read-write otherwise (false or unspecified).
// Defaults to false.
ReadOnly bool `json:"readOnly,omitempty"`
// Path within the container at which the volume should be mounted.
// Path within the container at which the volume should be mounted. Must
// not contain ':'.
MountPath string `json:"mountPath"`
}

View File

@ -1565,7 +1565,7 @@ var map_VolumeMount = map[string]string{
"": "VolumeMount describes a mounting of a Volume within a container.",
"name": "This must match the Name of a Volume.",
"readOnly": "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.",
"mountPath": "Path within the container at which the volume should be mounted.",
"mountPath": "Path within the container at which the volume should be mounted. Must not contain ':'.",
}
func (VolumeMount) SwaggerDoc() map[string]string {

View File

@ -1091,6 +1091,8 @@ func validateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, fldPath
}
if len(mnt.MountPath) == 0 {
allErrs = append(allErrs, field.Required(idxPath.Child("mountPath"), ""))
} else if strings.Contains(mnt.MountPath, ":") {
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must not contain ':'"))
}
}
return allErrs

View File

@ -1134,6 +1134,7 @@ func TestValidateVolumeMounts(t *testing.T) {
"empty name": {{Name: "", MountPath: "/foo"}},
"name not found": {{Name: "", MountPath: "/foo"}},
"empty mountpath": {{Name: "abc", MountPath: ""}},
"colon mountpath": {{Name: "abc", MountPath: "foo:bar"}},
}
for k, v := range errorCases {
if errs := validateVolumeMounts(v, volumes, field.NewPath("field")); len(errs) == 0 {