Skip to content

Commit

Permalink
Copy deeply nested key to variable
Browse files Browse the repository at this point in the history
To avoid repetition and struct access.

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
  • Loading branch information
Lorenzo Manacorda committed Mar 12, 2018
1 parent a0ebd4b commit 8eb799a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/controller/stateful_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ func (hc *HabitatController) newStatefulSet(h *habv1beta1.Habitat) (*appsv1beta1
}

// Mount Persistent Volume, if requested.
if h.Spec.PersistentStorage != nil {
if ps := h.Spec.PersistentStorage; ps != nil {
vm := &apiv1.VolumeMount{
Name: persistentVolumeName,
MountPath: h.Spec.PersistentStorage.MountPath,
MountPath: ps.MountPath,
}

base.Spec.Template.Spec.Containers[0].VolumeMounts = append(base.Spec.Template.Spec.Containers[0].VolumeMounts, *vm)

q, err := resource.ParseQuantity(h.Spec.PersistentStorage.Size)
q, err := resource.ParseQuantity(ps.Size)
if err != nil {
return nil, err
}
Expand All @@ -192,7 +192,7 @@ func (hc *HabitatController) newStatefulSet(h *habv1beta1.Habitat) (*appsv1beta1
AccessModes: []apiv1.PersistentVolumeAccessMode{
apiv1.ReadWriteOnce,
},
StorageClassName: &h.Spec.PersistentStorage.StorageClassName,
StorageClassName: &ps.StorageClassName,
Resources: apiv1.ResourceRequirements{
Requests: apiv1.ResourceList{
apiv1.ResourceStorage: q,
Expand Down

0 comments on commit 8eb799a

Please sign in to comment.