GetAutoGrowFromSpec extracts AutoGrow settings from the provided AutoGrowSpec. It returns two strings: (trigger, maxGrow). - trigger: the auto-grow threshold as a decimal percentage string (e.g., "75"). Defaults to "75" when no trigger is configured. - maxGrow: the maximum growth size as a whole nu
(spec *v1beta1.VolumeClaimSpecWithAutoGrow)
| 113 | // maxGrow empty. When set, Trigger is formatted as a base-10 string and MaxGrow is |
| 114 | // converted from a resource quantity (bytes) to mebibytes by dividing bytes by 1024*1024. |
| 115 | func GetAutoGrowFromSpec(spec *v1beta1.VolumeClaimSpecWithAutoGrow) (string, string) { |
| 116 | // MaxGrow is optional; an empty string means "no limit" on growth and the volume |
| 117 | // will grow by 50% each time it is triggered. |
| 118 | maxGrow := "" |
| 119 | |
| 120 | // We always want to set default trigger; We will override it if |
| 121 | // the user has set a different value. |
| 122 | trigger := AutoGrowTriggerDefault |
| 123 | |
| 124 | // If AutoGrow is configured on the VolumeClaimSpecWithAutoGrow, extract |
| 125 | // the Trigger and MaxGrow values |
| 126 | if spec != nil && spec.AutoGrow != nil { |
| 127 | if t := spec.AutoGrow.Trigger; t != nil { |
| 128 | trigger = fmt.Sprintf("%d", initialize.FromPointer(t)) |
| 129 | } |
| 130 | if mg := spec.AutoGrow.MaxGrow; mg != nil { |
| 131 | // Value() returns bytes, convert to mebibytes |
| 132 | mebibytes := mg.Value() / (1024 * 1024) |
| 133 | maxGrow = fmt.Sprintf("%d", mebibytes) |
| 134 | } |
| 135 | } |
| 136 | return trigger, maxGrow |
| 137 | } |