Bump helm.sh/helm/v3 from 3.10.3 to 3.11.1 (#5528)
This commit is contained in:
130
vendor/github.com/alecthomas/units/bytes.go
generated
vendored
130
vendor/github.com/alecthomas/units/bytes.go
generated
vendored
@@ -40,9 +40,76 @@ func (b Base2Bytes) String() string {
|
||||
return ToString(int64(b), 1024, "iB", "B")
|
||||
}
|
||||
|
||||
var (
|
||||
metricBytesUnitMap = MakeUnitMap("B", "B", 1000)
|
||||
)
|
||||
// MarshalText implement encoding.TextMarshaler to process json/yaml.
|
||||
func (b Base2Bytes) MarshalText() ([]byte, error) {
|
||||
return []byte(b.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implement encoding.TextUnmarshaler to process json/yaml.
|
||||
func (b *Base2Bytes) UnmarshalText(text []byte) error {
|
||||
n, err := ParseBase2Bytes(string(text))
|
||||
*b = n
|
||||
return err
|
||||
}
|
||||
|
||||
// Floor returns Base2Bytes with all but the largest unit zeroed out. So that e.g. 1GiB1MiB1KiB → 1GiB.
|
||||
func (b Base2Bytes) Floor() Base2Bytes {
|
||||
switch {
|
||||
case b > Exbibyte:
|
||||
return (b / Exbibyte) * Exbibyte
|
||||
case b > Pebibyte:
|
||||
return (b / Pebibyte) * Pebibyte
|
||||
case b > Tebibyte:
|
||||
return (b / Tebibyte) * Tebibyte
|
||||
case b > Gibibyte:
|
||||
return (b / Gibibyte) * Gibibyte
|
||||
case b > Mebibyte:
|
||||
return (b / Mebibyte) * Mebibyte
|
||||
case b > Kibibyte:
|
||||
return (b / Kibibyte) * Kibibyte
|
||||
default:
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
// Round returns Base2Bytes with all but the first n units zeroed out. So that e.g. 1GiB1MiB1KiB → 1GiB1MiB, if n is 2.
|
||||
func (b Base2Bytes) Round(n int) Base2Bytes {
|
||||
idx := 0
|
||||
|
||||
switch {
|
||||
case b > Exbibyte:
|
||||
idx = n
|
||||
case b > Pebibyte:
|
||||
idx = n + 1
|
||||
case b > Tebibyte:
|
||||
idx = n + 2
|
||||
case b > Gibibyte:
|
||||
idx = n + 3
|
||||
case b > Mebibyte:
|
||||
idx = n + 4
|
||||
case b > Kibibyte:
|
||||
idx = n + 5
|
||||
}
|
||||
|
||||
switch idx {
|
||||
case 1:
|
||||
return b - b%Exbibyte
|
||||
case 2:
|
||||
return b - b%Pebibyte
|
||||
case 3:
|
||||
return b - b%Tebibyte
|
||||
case 4:
|
||||
return b - b%Gibibyte
|
||||
case 5:
|
||||
return b - b%Mebibyte
|
||||
case 6:
|
||||
return b - b%Kibibyte
|
||||
default:
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
var metricBytesUnitMap = MakeUnitMap("B", "B", 1000)
|
||||
|
||||
// MetricBytes are SI byte units (1000 bytes in a kilobyte).
|
||||
type MetricBytes SI
|
||||
@@ -74,6 +141,63 @@ func (m MetricBytes) String() string {
|
||||
return ToString(int64(m), 1000, "B", "B")
|
||||
}
|
||||
|
||||
// Floor returns MetricBytes with all but the largest unit zeroed out. So that e.g. 1GB1MB1KB → 1GB.
|
||||
func (b MetricBytes) Floor() MetricBytes {
|
||||
switch {
|
||||
case b > Exabyte:
|
||||
return (b / Exabyte) * Exabyte
|
||||
case b > Petabyte:
|
||||
return (b / Petabyte) * Petabyte
|
||||
case b > Terabyte:
|
||||
return (b / Terabyte) * Terabyte
|
||||
case b > Gigabyte:
|
||||
return (b / Gigabyte) * Gigabyte
|
||||
case b > Megabyte:
|
||||
return (b / Megabyte) * Megabyte
|
||||
case b > Kilobyte:
|
||||
return (b / Kilobyte) * Kilobyte
|
||||
default:
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
// Round returns MetricBytes with all but the first n units zeroed out. So that e.g. 1GB1MB1KB → 1GB1MB, if n is 2.
|
||||
func (b MetricBytes) Round(n int) MetricBytes {
|
||||
idx := 0
|
||||
|
||||
switch {
|
||||
case b > Exabyte:
|
||||
idx = n
|
||||
case b > Petabyte:
|
||||
idx = n + 1
|
||||
case b > Terabyte:
|
||||
idx = n + 2
|
||||
case b > Gigabyte:
|
||||
idx = n + 3
|
||||
case b > Megabyte:
|
||||
idx = n + 4
|
||||
case b > Kilobyte:
|
||||
idx = n + 5
|
||||
}
|
||||
|
||||
switch idx {
|
||||
case 1:
|
||||
return b - b%Exabyte
|
||||
case 2:
|
||||
return b - b%Petabyte
|
||||
case 3:
|
||||
return b - b%Terabyte
|
||||
case 4:
|
||||
return b - b%Gigabyte
|
||||
case 5:
|
||||
return b - b%Megabyte
|
||||
case 6:
|
||||
return b - b%Kilobyte
|
||||
default:
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
// ParseStrictBytes supports both iB and B suffixes for base 2 and metric,
|
||||
// respectively. That is, KiB represents 1024 and kB, KB represent 1000.
|
||||
func ParseStrictBytes(s string) (int64, error) {
|
||||
|
||||
Reference in New Issue
Block a user