MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / generatePVCObject

Method generatePVCObject

internal/cmd/plugin/fio/fio.go:96–129  ·  view source on GitHub ↗

CreatePVC creates spec of a PVC, given its name and the storage configuration

()

Source from the content-addressed store, hash-verified

94
95// CreatePVC creates spec of a PVC, given its name and the storage configuration
96func (cmd *fioCommand) generatePVCObject() (*corev1.PersistentVolumeClaim, error) {
97 result := &corev1.PersistentVolumeClaim{
98 TypeMeta: metav1.TypeMeta{
99 APIVersion: "v1",
100 Kind: "PersistentVolumeClaim",
101 },
102 ObjectMeta: metav1.ObjectMeta{
103 Name: cmd.name,
104 Namespace: plugin.Namespace,
105 },
106 Spec: corev1.PersistentVolumeClaimSpec{
107 AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
108 VolumeName: "",
109 },
110 }
111
112 if cmd.pvcSize != "" {
113 parsedSize, err := resource.ParseQuantity(cmd.pvcSize)
114 if err != nil {
115 return nil, err
116 }
117
118 result.Spec.Resources = corev1.VolumeResourceRequirements{
119 Requests: corev1.ResourceList{
120 "storage": parsedSize,
121 },
122 }
123 }
124
125 if cmd.storageClassName != "" {
126 result.Spec.StorageClassName = &cmd.storageClassName
127 }
128 return result, nil
129}
130
131// createConfigMap creates spec of configmap.
132func (cmd *fioCommand) generateConfigMapObject() *corev1.ConfigMap {

Callers 1

executeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected