mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
suspect nil pointer for HostPathType
This commit is contained in:
@@ -993,7 +993,7 @@ var supportedHostPathTypes = sets.NewString(
|
||||
func validateHostPathType(hostPathType *api.HostPathType, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if !supportedHostPathTypes.Has(string(*hostPathType)) {
|
||||
if hostPathType != nil && !supportedHostPathTypes.Has(string(*hostPathType)) {
|
||||
allErrs = append(allErrs, field.NotSupported(fldPath, hostPathType, supportedHostPathTypes.List()))
|
||||
}
|
||||
|
||||
|
@@ -106,8 +106,14 @@ func (plugin *hostPathPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, opts vo
|
||||
}
|
||||
|
||||
path := hostPathVolumeSource.Path
|
||||
pathType := new(v1.HostPathType)
|
||||
if hostPathVolumeSource.Type == nil {
|
||||
*pathType = v1.HostPathUnset
|
||||
} else {
|
||||
pathType = hostPathVolumeSource.Type
|
||||
}
|
||||
return &hostPathMounter{
|
||||
hostPath: &hostPath{path: path, pathType: hostPathVolumeSource.Type, containerized: opts.Containerized},
|
||||
hostPath: &hostPath{path: path, pathType: pathType, containerized: opts.Containerized},
|
||||
readOnly: readOnly,
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user