MCPcopy
hub / github.com/fluid-cloudnative/fluid / TransformQuantityToGooseFSUnit

Function TransformQuantityToGooseFSUnit

pkg/utils/quantity.go:56–65  ·  view source on GitHub ↗

TransformQuantityToGooseFSUnit transform a given input quantity to another one that can be recognized by GooseFS. This is necessary because GooseFS takes decimal byte units(e.g. KB, MB, GB, etc.) as binary byte units(e.g. Ki, Mi, Gi)

(q *resource.Quantity)

Source from the content-addressed store, hash-verified

54// that can be recognized by GooseFS. This is necessary because GooseFS takes decimal byte units(e.g. KB, MB, GB, etc.)
55// as binary byte units(e.g. Ki, Mi, Gi)
56func TransformQuantityToGooseFSUnit(q *resource.Quantity) (value string) {
57 value = q.String()
58
59 if strings.HasSuffix(value, "i") {
60 value = strings.ReplaceAll(value, "i", "B")
61 }
62 return
63 // return units.BytesSize(units.BytesSize(float64(q.Value())))
64
65}
66
67// TransformQuantityToEFCUnit transform a given input quantity to another one
68// that can be recognized by EFC. This is necessary because EFC takes decimal byte units(e.g. KB, MB, GB, etc.)

Callers 2

transformCommonPartMethod · 0.92

Calls 1

StringMethod · 0.45

Tested by 1