Skip to content

Commit

Permalink
Merge pull request #576 from dprince/to_core_volume_fix
Browse files Browse the repository at this point in the history
Simplify and fix name issue with ToCoreVolume
  • Loading branch information
stuggi authored Oct 29, 2024
2 parents a8404d0 + fd3b69f commit 1fa2876
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions modules/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,13 @@ func (s *VolumeSource) ToCoreVolumeSource() (*corev1.VolumeSource, error) {

// ToCoreVolume - convert Volume to corev1.Volume
func (s *Volume) ToCoreVolume() (*corev1.Volume, error) {
coreVolume := &corev1.Volume{}

coreVolumeBytes, err := json.Marshal(s)
volSource, err := s.VolumeSource.ToCoreVolumeSource()
if err != nil {
return nil, fmt.Errorf("error marshalling Volume: %w", err)
return nil, err
}

err = json.Unmarshal(coreVolumeBytes, coreVolume)
if err != nil {
return nil, fmt.Errorf("error unmarshalling Volume: %w", err)
coreVolume := &corev1.Volume{
Name: s.Name,
VolumeSource: *volSource,
}

return coreVolume, nil
}

0 comments on commit 1fa2876

Please sign in to comment.