Skip to content

Commit

Permalink
Merge pull request #575 from dprince/storage_updates
Browse files Browse the repository at this point in the history
storage: Add new ToCoreVolume and ProjectVolumeSource
  • Loading branch information
stuggi authored Oct 28, 2024
2 parents 30baa23 + 333dbab commit 5d66385
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ type VolumeSource struct {
// csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature).
// +optional
CSI *corev1.CSIVolumeSource `json:"csi,omitempty" protobuf:"bytes,28,opt,name=csi"`

// projected items for all in one resources secrets, configmaps, and downward API
Projected *corev1.ProjectedVolumeSource `json:"projected,omitempty" protobuf:"bytes,26,opt,name=projected"`
}

// Volume our slimmed down version of Volume
Expand Down Expand Up @@ -161,3 +164,20 @@ func (s *VolumeSource) ToCoreVolumeSource() (*corev1.VolumeSource, error) {

return coreVolumeSource, nil
}

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

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

err = json.Unmarshal(coreVolumeBytes, coreVolume)
if err != nil {
return nil, fmt.Errorf("error unmarshalling Volume: %w", err)
}

return coreVolume, nil
}

0 comments on commit 5d66385

Please sign in to comment.