Skip to content

Commit

Permalink
suspect nil pointer for HostPathType
Browse files Browse the repository at this point in the history
  • Loading branch information
dixudx committed Sep 10, 2017
1 parent e821e53 commit 29249e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/volume/host_path/host_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 29249e0

Please sign in to comment.