This repository was archived by the owner on Jan 20, 2026. It is now read-only.
Update third_party directory with files from Kubernetes v1.35.0#210
Merged
viccuad merged 6 commits intoJan 5, 2026
Conversation
Member
|
PR closed and reopened to trigger the tests |
Made with ❤️️ by updatecli Signed-off-by: Kubewarden bot <cncf-kubewarden-maintainers@lists.cncf.io>
Made with ❤️️ by updatecli Signed-off-by: Kubewarden bot <cncf-kubewarden-maintainers@lists.cncf.io>
... inery packages Made with ❤️️ by updatecli Signed-off-by: Kubewarden bot <cncf-kubewarden-maintainers@lists.cncf.io>
Made with ❤️️ by updatecli Signed-off-by: Kubewarden bot <cncf-kubewarden-maintainers@lists.cncf.io>
Made with ❤️️ by updatecli Signed-off-by: Kubewarden bot <cncf-kubewarden-maintainers@lists.cncf.io>
46a6a58 to
b9a03a9
Compare
…6a23affcb71b79a70cdaf654a33cc886556 Signed-off-by: Víctor Cuadrado Juan <2196685+viccuad@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automatic third_party directory update with the files from the Kubernetes v1.35.0.
REMEMBER IF YOU WANT TO MERGE IN A SINGLE COMMIT CHANGES AND VERSION BUMP, YOU MUST SQUASH THE COMMIT BEFORE MERGING THIS PR!
Update the third party directory with files from Kubernetes repositories
update pkg/api/resource/quantity.go
1 file(s) updated with "/*\nCopyright 2014 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage resource\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\tmath \"math\"\n\t\"math/big\"\n\t\"strconv\"\n\t\"strings\"\n\n\tcbor \"k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct\"\n\n\tinf \"gopkg.in/inf.v0\"\n)\n\n// Quantity is a fixed-point representation of a number.\n// It provides convenient marshaling/unmarshaling in JSON and YAML,\n// in addition to String() and AsInt64() accessors.\n//\n// The serialization format is:\n//\n// ```\n// <quantity> ::= <signedNumber><suffix>\n//\n//\t(Note that <suffix> may be empty, from the \"\" case in <decimalSI>.)\n//\n// <digit> ::= 0 | 1 | ... | 9\n// <digits> ::= <digit> | <digit><digits>\n// <number> ::= <digits> | <digits>.<digits> | <digits>. | .<digits>\n// <sign> ::= \"+\" | \"-\"\n// <signedNumber> ::= <number> | <sign><number>\n// <suffix> ::= <binarySI> | <decimalExponent> | <decimalSI>\n// <binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei\n//\n//\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n//\n// <decimalSI> ::= m | \"\" | k | M | G | T | P | E\n//\n//\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n//\n// <decimalExponent> ::= \"e\" <signedNumber> | \"E\" <signedNumber>\n// ```\n//\n// No matter which of the three exponent forms is used, no quantity may represent\n// a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal\n// places. Numbers larger or more precise will be capped or rounded up.\n// (E.g.: 0.1m will rounded up to 1m.)\n// This may be extended in the future if we require larger or smaller quantities.\n//\n// When a Quantity is parsed from a string, it will remember the type of suffix\n// it had, and will use the same type again when it is serialized.\n//\n// Before serializing, Quantity will be put in \"canonical form\".\n// This means that Exponent/suffix will be adjusted up or down (with a\n// corresponding increase or decrease in Mantissa) such that:\n//\n// - No precision is lost\n// - No fractional digits will be emitted\n// - The exponent (or suffix) is as large as possible.\n//\n// The sign will be omitted unless the number is negative.\n//\n// Examples:\n//\n// - 1.5 will be serialized as \"1500m\"\n// - 1.5Gi will be serialized as \"1536Mi\"\n//\n// Note that the quantity will NEVER be internally represented by a\n// floating point number. That is the whole point of this exercise.\n//\n// Non-canonical values will still parse as long as they are well formed,\n// but will be re-emitted in their canonical form. (So always use canonical\n// form, or don't diff.)\n//\n// This format is intended to make it difficult to use these numbers without\n// writing some sort of special handling code in the hopes that that will\n// cause implementors to also use a fixed point implementation.\n//\n// +protobuf=true\n// +protobuf.embed=string\n// +protobuf.options.marshal=false\n// +protobuf.options.(gogoproto.goproto_stringer)=false\n// +k8s:deepcopy-gen=true\n// +k8s:openapi-gen=true\n// +k8s:openapi-model-package=io.k8s.apimachinery.pkg.api.resource\ntype Quantity struct {\n\t// i is the quantity in int64 scaled form, if d.Dec == nil\n\ti int64Amount\n\t// d is the quantity in inf.Dec form if d.Dec != nil\n\td infDecAmount\n\t// s is the generated value of this quantity to avoid recalculation\n\ts string\n\n\t// Change Format at will. See the comment for Canonicalize for\n\t// more details.\n\tFormat\n}\n\n// CanonicalValue allows a quantity amount to be converted to a string.\ntype CanonicalValue interface {\n\t// AsCanonicalBytes returns a byte array representing the string representation\n\t// of the value mantissa and an int32 representing its exponent in base-10. Callers may\n\t// pass a byte slice to the method to avoid allocations.\n\tAsCanonicalBytes(out []byte) ([]byte, int32)\n\t// AsCanonicalBase1024Bytes returns a byte array representing the string representation\n\t// of the value mantissa and an int32 representing its exponent in base-1024. Callers\n\t// may pass a byte slice to the method to avoid allocations.\n\tAsCanonicalBase1024Bytes(out []byte) ([]byte, int32)\n}\n\n// Format lists the three possible formattings of a quantity.\ntype Format string\n\nconst (\n\tDecimalExponent = Format(\"DecimalExponent\") // e.g., 12e6\n\tBinarySI = Format(\"BinarySI\") // e.g., 12Mi (12 * 2^20)\n\tDecimalSI = Format(\"DecimalSI\") // e.g., 12M (12 * 10^6)\n)\n\n// MustParse turns the given string into a quantity or panics; for tests\n// or other cases where you know the string is valid.\nfunc MustParse(str string) Quantity {\n\tq, err := ParseQuantity(str)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"cannot parse '%v': %v\", str, err))\n\t}\n\treturn q\n}\n\nconst (\n\t// splitREString is used to separate a number from its suffix; as such,\n\t// this is overly permissive, but that's OK-- it will be checked later.\n\tsplitREString = \"^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$\"\n)\n\nvar (\n\t// Errors that could happen while parsing a string.\n\tErrFormatWrong = errors.New(\"quantities must match the regular expression '\" + splitREString + \"'\")\n\tErrNumeric = errors.New(\"unable to parse numeric part of quantity\")\n\tErrSuffix = errors.New(\"unable to parse quantity's suffix\")\n)\n\n// parseQuantityString is a fast scanner for quantity values.\nfunc parseQuantityString(str string) (positive bool, value, num, denom, suffix string, err error) {\n\tpositive = true\n\tpos := 0\n\tend := len(str)\n\n\t// handle leading sign\n\tif pos < end {\n\t\tswitch str[0] {\n\t\tcase '-':\n\t\t\tpositive = false\n\t\t\tpos++\n\t\tcase '+':\n\t\t\tpos++\n\t\t}\n\t}\n\n\t// strip leading zeros\nZeroes:\n\tfor i := pos; ; i++ {\n\t\tif i >= end {\n\t\t\tnum = \"0\"\n\t\t\tvalue = num\n\t\t\treturn\n\t\t}\n\t\tswitch str[i] {\n\t\tcase '0':\n\t\t\tpos++\n\t\tdefault:\n\t\t\tbreak Zeroes\n\t\t}\n\t}\n\n\t// extract the numerator\nNum:\n\tfor i := pos; ; i++ {\n\t\tif i >= end {\n\t\t\tnum = str[pos:end]\n\t\t\tvalue = str[0:end]\n\t\t\treturn\n\t\t}\n\t\tswitch str[i] {\n\t\tcase '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':\n\t\tdefault:\n\t\t\tnum = str[pos:i]\n\t\t\tpos = i\n\t\t\tbreak Num\n\t\t}\n\t}\n\n\t// if we stripped all numerator positions, always return 0\n\tif len(num) == 0 {\n\t\tnum = \"0\"\n\t}\n\n\t// handle a denominator\n\tif pos < end && str[pos] == '.' {\n\t\tpos++\n\tDenom:\n\t\tfor i := pos; ; i++ {\n\t\t\tif i >= end {\n\t\t\t\tdenom = str[pos:end]\n\t\t\t\tvalue = str[0:end]\n\t\t\t\treturn\n\t\t\t}\n\t\t\tswitch str[i] {\n\t\t\tcase '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':\n\t\t\tdefault:\n\t\t\t\tdenom = str[pos:i]\n\t\t\t\tpos = i\n\t\t\t\tbreak Denom\n\t\t\t}\n\t\t}\n\t\t// TODO: we currently allow 1.G, but we may not want to in the future.\n\t\t// if len(denom) == 0 {\n\t\t// \terr = ErrFormatWrong\n\t\t// \treturn\n\t\t// }\n\t}\n\tvalue = str[0:pos]\n\n\t// grab the elements of the suffix\n\tsuffixStart := pos\n\tfor i := pos; ; i++ {\n\t\tif i >= end {\n\t\t\tsuffix = str[suffixStart:end]\n\t\t\treturn\n\t\t}\n\t\tif !strings.ContainsAny(str[i:i+1], \"eEinumkKMGTP\") {\n\t\t\tpos = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif pos < end {\n\t\tswitch str[pos] {\n\t\tcase '-', '+':\n\t\t\tpos++\n\t\t}\n\t}\nSuffix:\n\tfor i := pos; ; i++ {\n\t\tif i >= end {\n\t\t\tsuffix = str[suffixStart:end]\n\t\t\treturn\n\t\t}\n\t\tswitch str[i] {\n\t\tcase '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':\n\t\tdefault:\n\t\t\tbreak Suffix\n\t\t}\n\t}\n\t// we encountered a non decimal in the Suffix loop, but the last character\n\t// was not a valid exponent\n\terr = ErrFormatWrong\n\treturn\n}\n\n// ParseQuantity turns str into a Quantity, or returns an error.\nfunc ParseQuantity(str string) (Quantity, error) {\n\tif len(str) == 0 {\n\t\treturn Quantity{}, ErrFormatWrong\n\t}\n\tif str == \"0\" {\n\t\treturn Quantity{Format: DecimalSI, s: str}, nil\n\t}\n\n\tpositive, value, num, denom, suf, err := parseQuantityString(str)\n\tif err != nil {\n\t\treturn Quantity{}, err\n\t}\n\n\tbase, exponent, format, ok := quantitySuffixer.interpret(suffix(suf))\n\tif !ok {\n\t\treturn Quantity{}, ErrSuffix\n\t}\n\n\tprecision := int32(0)\n\tscale := int32(0)\n\tmantissa := int64(1)\n\tswitch format {\n\tcase DecimalExponent, DecimalSI:\n\t\tscale = exponent\n\t\tprecision = maxInt64Factors - int32(len(num)+len(denom))\n\tcase BinarySI:\n\t\tscale = 0\n\t\tswitch {\n\t\tcase exponent >= 0 && len(denom) == 0:\n\t\t\t// only handle positive binary numbers with the fast path\n\t\t\tmantissa = int64(int64(mantissa) << uint64(exponent))\n\t\t\t// 1Mi (2^20) has ~6 digits of decimal precision, so exponent*3/10 -1 is roughly the precision\n\t\t\tprecision = 15 - int32(len(num)) - int32(float32(exponent)*3/10) - 1\n\t\tdefault:\n\t\t\tprecision = -1\n\t\t}\n\t}\n\n\tif precision >= 0 {\n\t\t// if we have a denominator, shift the entire value to the left by the number of places in the\n\t\t// denominator\n\t\tscale -= int32(len(denom))\n\t\tif scale >= int32(Nano) {\n\t\t\tshifted := num + denom\n\n\t\t\tvar value int64\n\t\t\tvalue, err := strconv.ParseInt(shifted, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn Quantity{}, ErrNumeric\n\t\t\t}\n\t\t\tif result, ok := int64Multiply(value, int64(mantissa)); ok {\n\t\t\t\tif !positive {\n\t\t\t\t\tresult = -result\n\t\t\t\t}\n\t\t\t\t// if the number is in canonical form, reuse the string\n\t\t\t\tswitch format {\n\t\t\t\tcase BinarySI:\n\t\t\t\t\tif exponent%10 == 0 && (value&0x07 != 0) {\n\t\t\t\t\t\treturn Quantity{i: int64Amount{value: result, scale: Scale(scale)}, Format: format, s: str}, nil\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tif scale%3 == 0 && !strings.HasSuffix(shifted, \"000\") && shifted[0] != '0' {\n\t\t\t\t\t\treturn Quantity{i: int64Amount{value: result, scale: Scale(scale)}, Format: format, s: str}, nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn Quantity{i: int64Amount{value: result, scale: Scale(scale)}, Format: format}, nil\n\t\t\t}\n\t\t}\n\t}\n\n\tamount := new(inf.Dec)\n\tif _, ok := amount.SetString(value); !ok {\n\t\treturn Quantity{}, ErrNumeric\n\t}\n\n\t// So that no one but us has to think about suffixes, remove it.\n\tif base == 10 {\n\t\tamount.SetScale(amount.Scale() + Scale(exponent).infScale())\n\t} else if base == 2 {\n\t\t// numericSuffix = 2 ** exponent\n\t\tnumericSuffix := big.NewInt(1).Lsh(bigOne, uint(exponent))\n\t\tub := amount.UnscaledBig()\n\t\tamount.SetUnscaledBig(ub.Mul(ub, numericSuffix))\n\t}\n\n\t// Cap at min/max bounds.\n\tsign := amount.Sign()\n\tif sign == -1 {\n\t\tamount.Neg(amount)\n\t}\n\n\t// This rounds non-zero values up to the minimum representable value, under the theory that\n\t// if you want some resources, you should get some resources, even if you asked for way too small\n\t// of an amount. Arguably, this should be inf.RoundHalfUp (normal rounding), but that would have\n\t// the side effect of rounding values < .5n to zero.\n\tif v, ok := amount.Unscaled(); v != int64(0) || !ok {\n\t\tamount.Round(amount, Nano.infScale(), inf.RoundUp)\n\t}\n\n\t// The max is just a simple cap.\n\t// TODO: this prevents accumulating quantities greater than int64, for instance quota across a cluster\n\tif format == BinarySI && amount.Cmp(maxAllowed.Dec) > 0 {\n\t\tamount.Set(maxAllowed.Dec)\n\t}\n\n\tif format == BinarySI && amount.Cmp(decOne) < 0 && amount.Cmp(decZero) > 0 {\n\t\t// This avoids rounding and hopefully confusion, too.\n\t\tformat = DecimalSI\n\t}\n\tif sign == -1 {\n\t\tamount.Neg(amount)\n\t}\n\n\treturn Quantity{d: infDecAmount{amount}, Format: format}, nil\n}\n\n// DeepCopy returns a deep-copy of the Quantity value. Note that the method\n// receiver is a value, so we can mutate it in-place and return it.\nfunc (q Quantity) DeepCopy() Quantity {\n\tif q.d.Dec != nil {\n\t\ttmp := &inf.Dec{}\n\t\tq.d.Dec = tmp.Set(q.d.Dec)\n\t}\n\treturn q\n}\n\n// OpenAPISchemaType is used by the kube-openapi generator when constructing\n// the OpenAPI spec of this type.\n//\n// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators\nfunc (_ Quantity) OpenAPISchemaType() []string { return []string{\"string\"} }\n\n// OpenAPISchemaFormat is used by the kube-openapi generator when constructing\n// the OpenAPI spec of this type.\nfunc (_ Quantity) OpenAPISchemaFormat() string { return \"\" }\n\n// OpenAPIV3OneOfTypes is used by the kube-openapi generator when constructing\n// the OpenAPI v3 spec of this type.\nfunc (Quantity) OpenAPIV3OneOfTypes() []string { return []string{\"string\", \"number\"} }\n\n// CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity).\n//\n// Note about BinarySI:\n// - If q.Format is set to BinarySI and q.Amount represents a non-zero value between\n// -1 and +1, it will be emitted as if q.Format were DecimalSI.\n// - Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be\n// rounded up. (1.1i becomes 2i.)\nfunc (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) {\n\tif q.IsZero() {\n\t\treturn zeroBytes, nil\n\t}\n\n\tvar rounded CanonicalValue\n\tformat := q.Format\n\tswitch format {\n\tcase DecimalExponent, DecimalSI:\n\tcase BinarySI:\n\t\tif q.CmpInt64(-1024) > 0 && q.CmpInt64(1024) < 0 {\n\t\t\t// This avoids rounding and hopefully confusion, too.\n\t\t\tformat = DecimalSI\n\t\t} else {\n\t\t\tvar exact bool\n\t\t\tif rounded, exact = q.AsScale(0); !exact {\n\t\t\t\t// Don't lose precision-- show as DecimalSI\n\t\t\t\tformat = DecimalSI\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tformat = DecimalExponent\n\t}\n\n\t// TODO: If BinarySI formatting is requested but would cause rounding, upgrade to\n\t// one of the other formats.\n\tswitch format {\n\tcase DecimalExponent, DecimalSI:\n\t\tnumber, exponent := q.AsCanonicalBytes(out)\n\t\tsuffix, _ := quantitySuffixer.constructBytes(10, exponent, format)\n\t\treturn number, suffix\n\tdefault:\n\t\t// format must be BinarySI\n\t\tnumber, exponent := rounded.AsCanonicalBase1024Bytes(out)\n\t\tsuffix, _ := quantitySuffixer.constructBytes(2, exponent*10, format)\n\t\treturn number, suffix\n\t}\n}\n\n// AsApproximateFloat64 returns a float64 representation of the quantity which\n// may lose precision. If precision matter more than performance, see\n// AsFloat64Slow. If the value of the quantity is outside the range of a\n// float64 +Inf/-Inf will be returned.\nfunc (q *Quantity) AsApproximateFloat64() float64 {\n\tvar base float64\n\tvar exponent int\n\tif q.d.Dec != nil {\n\t\tbase, _ = big.NewFloat(0).SetInt(q.d.Dec.UnscaledBig()).Float64()\n\t\texponent = int(-q.d.Dec.Scale())\n\t} else {\n\t\tbase = float64(q.i.value)\n\t\texponent = int(q.i.scale)\n\t}\n\tif exponent == 0 {\n\t\treturn base\n\t}\n\n\treturn base * math.Pow10(exponent)\n}\n\n// AsFloat64Slow returns a float64 representation of the quantity. This is\n// more precise than AsApproximateFloat64 but significantly slower. If the\n// value of the quantity is outside the range of a float64 +Inf/-Inf will be\n// returned.\nfunc (q *Quantity) AsFloat64Slow() float64 {\n\tinfDec := q.AsDec()\n\n\tvar absScale int64\n\tif infDec.Scale() < 0 {\n\t\tabsScale = int64(-infDec.Scale())\n\t} else {\n\t\tabsScale = int64(infDec.Scale())\n\t}\n\tpow10AbsScale := big.NewInt(10)\n\tpow10AbsScale = pow10AbsScale.Exp(pow10AbsScale, big.NewInt(absScale), nil)\n\n\tvar resultBigFloat *big.Float\n\tif infDec.Scale() < 0 {\n\t\tresultBigInt := new(big.Int).Mul(infDec.UnscaledBig(), pow10AbsScale)\n\t\tresultBigFloat = new(big.Float).SetInt(resultBigInt)\n\t} else {\n\t\tpow10AbsScaleFloat := new(big.Float).SetInt(pow10AbsScale)\n\t\tresultBigFloat = new(big.Float).SetInt(infDec.UnscaledBig())\n\t\tresultBigFloat = resultBigFloat.Quo(resultBigFloat, pow10AbsScaleFloat)\n\t}\n\n\tresult, _ := resultBigFloat.Float64()\n\treturn result\n}\n\n// AsInt64 returns a representation of the current value as an int64 if a fast conversion\n// is possible. If false is returned, callers must use the inf.Dec form of this quantity.\nfunc (q *Quantity) AsInt64() (int64, bool) {\n\tif q.d.Dec != nil {\n\t\treturn 0, false\n\t}\n\treturn q.i.AsInt64()\n}\n\n// ToDec promotes the quantity in place to use an inf.Dec representation and returns itself.\nfunc (q *Quantity) ToDec() *Quantity {\n\tif q.d.Dec == nil {\n\t\tq.d.Dec = q.i.AsDec()\n\t\tq.i = int64Amount{}\n\t}\n\treturn q\n}\n\n// AsDec returns the quantity as represented by a scaled inf.Dec.\nfunc (q *Quantity) AsDec() *inf.Dec {\n\tif q.d.Dec != nil {\n\t\treturn q.d.Dec\n\t}\n\tq.d.Dec = q.i.AsDec()\n\tq.i = int64Amount{}\n\treturn q.d.Dec\n}\n\n// AsCanonicalBytes returns the canonical byte representation of this quantity as a mantissa\n// and base 10 exponent. The out byte slice may be passed to the method to avoid an extra\n// allocation.\nfunc (q *Quantity) AsCanonicalBytes(out []byte) (result []byte, exponent int32) {\n\tif q.d.Dec != nil {\n\t\treturn q.d.AsCanonicalBytes(out)\n\t}\n\treturn q.i.AsCanonicalBytes(out)\n}\n\n// IsZero returns true if the quantity is equal to zero.\nfunc (q *Quantity) IsZero() bool {\n\tif q.d.Dec != nil {\n\t\treturn q.d.Dec.Sign() == 0\n\t}\n\treturn q.i.value == 0\n}\n\n// Sign returns 0 if the quantity is zero, -1 if the quantity is less than zero, or 1 if the\n// quantity is greater than zero.\nfunc (q *Quantity) Sign() int {\n\tif q.d.Dec != nil {\n\t\treturn q.d.Dec.Sign()\n\t}\n\treturn q.i.Sign()\n}\n\n// AsScale returns the current value, rounded up to the provided scale, and returns\n// false if the scale resulted in a loss of precision.\nfunc (q *Quantity) AsScale(scale Scale) (CanonicalValue, bool) {\n\tif q.d.Dec != nil {\n\t\treturn q.d.AsScale(scale)\n\t}\n\treturn q.i.AsScale(scale)\n}\n\n// RoundUp updates the quantity to the provided scale, ensuring that the value is at\n// least 1. False is returned if the rounding operation resulted in a loss of precision.\n// Negative numbers are rounded away from zero (-9 scale 1 rounds to -10).\nfunc (q *Quantity) RoundUp(scale Scale) bool {\n\tif q.d.Dec != nil {\n\t\tq.s = \"\"\n\t\td, exact := q.d.AsScale(scale)\n\t\tq.d = d\n\t\treturn exact\n\t}\n\t// avoid clearing the string value if we have already calculated it\n\tif q.i.scale >= scale {\n\t\treturn true\n\t}\n\tq.s = \"\"\n\ti, exact := q.i.AsScale(scale)\n\tq.i = i\n\treturn exact\n}\n\n// Add adds the provide y quantity to the current value. If the current value is zero,\n// the format of the quantity will be updated to the format of y.\nfunc (q *Quantity) Add(y Quantity) {\n\tq.s = \"\"\n\tif q.d.Dec == nil && y.d.Dec == nil {\n\t\tif q.i.value == 0 {\n\t\t\tq.Format = y.Format\n\t\t}\n\t\tif q.i.Add(y.i) {\n\t\t\treturn\n\t\t}\n\t} else if q.IsZero() {\n\t\tq.Format = y.Format\n\t}\n\tq.ToDec().d.Dec.Add(q.d.Dec, y.AsDec())\n}\n\n// Sub subtracts the provided quantity from the current value in place. If the current\n// value is zero, the format of the quantity will be updated to the format of y.\nfunc (q *Quantity) Sub(y Quantity) {\n\tq.s = \"\"\n\tif q.IsZero() {\n\t\tq.Format = y.Format\n\t}\n\tif q.d.Dec == nil && y.d.Dec == nil && q.i.Sub(y.i) {\n\t\treturn\n\t}\n\tq.ToDec().d.Dec.Sub(q.d.Dec, y.AsDec())\n}\n\n// Mul multiplies the provided y to the current value.\n// It will return false if the result is inexact. Otherwise, it will return true.\nfunc (q *Quantity) Mul(y int64) bool {\n\tq.s = \"\"\n\tif q.d.Dec == nil && q.i.Mul(y) {\n\t\treturn true\n\t}\n\treturn q.ToDec().d.Dec.Mul(q.d.Dec, inf.NewDec(y, inf.Scale(0))).UnscaledBig().IsInt64()\n}\n\n// Cmp returns 0 if the quantity is equal to y, -1 if the quantity is less than y, or 1 if the\n// quantity is greater than y.\nfunc (q *Quantity) Cmp(y Quantity) int {\n\tif q.d.Dec == nil && y.d.Dec == nil {\n\t\treturn q.i.Cmp(y.i)\n\t}\n\treturn q.AsDec().Cmp(y.AsDec())\n}\n\n// CmpInt64 returns 0 if the quantity is equal to y, -1 if the quantity is less than y, or 1 if the\n// quantity is greater than y.\nfunc (q *Quantity) CmpInt64(y int64) int {\n\tif q.d.Dec != nil {\n\t\treturn q.d.Dec.Cmp(inf.NewDec(y, inf.Scale(0)))\n\t}\n\treturn q.i.Cmp(int64Amount{value: y})\n}\n\n// Neg sets quantity to be the negative value of itself.\nfunc (q *Quantity) Neg() {\n\tq.s = \"\"\n\tif q.d.Dec == nil {\n\t\tq.i.value = -q.i.value\n\t\treturn\n\t}\n\tq.d.Dec.Neg(q.d.Dec)\n}\n\n// Equal checks equality of two Quantities. This is useful for testing with\n// cmp.Equal.\nfunc (q Quantity) Equal(v Quantity) bool {\n\treturn q.Cmp(v) == 0\n}\n\n// int64QuantityExpectedBytes is the expected width in bytes of the canonical string representation\n// of most Quantity values.\nconst int64QuantityExpectedBytes = 18\n\n// String formats the Quantity as a string, caching the result if not calculated.\n// String is an expensive operation and caching this result significantly reduces the cost of\n// normal parse / marshal operations on Quantity.\nfunc (q *Quantity) String() string {\n\tif q == nil {\n\t\treturn \"<nil>\"\n\t}\n\tif len(q.s) == 0 {\n\t\tresult := make([]byte, 0, int64QuantityExpectedBytes)\n\t\tnumber, suffix := q.CanonicalizeBytes(result)\n\t\tnumber = append(number, suffix...)\n\t\tq.s = string(number)\n\t}\n\treturn q.s\n}\n\n// MarshalJSON implements the json.Marshaller interface.\nfunc (q Quantity) MarshalJSON() ([]byte, error) {\n\tif len(q.s) > 0 {\n\t\tout := make([]byte, len(q.s)+2)\n\t\tout[0], out[len(out)-1] = '\"', '\"'\n\t\tcopy(out[1:], q.s)\n\t\treturn out, nil\n\t}\n\tresult := make([]byte, int64QuantityExpectedBytes)\n\tresult[0] = '\"'\n\tnumber, suffix := q.CanonicalizeBytes(result[1:1])\n\t// if the same slice was returned to us that we passed in, avoid another allocation by copying number into\n\t// the source slice and returning that\n\tif len(number) > 0 && &number[0] == &result[1] && (len(number)+len(suffix)+2) <= int64QuantityExpectedBytes {\n\t\tnumber = append(number, suffix...)\n\t\tnumber = append(number, '\"')\n\t\treturn result[:1+len(number)], nil\n\t}\n\t// if CanonicalizeBytes needed more space than our slice provided, we may need to allocate again so use\n\t// append\n\tresult = result[:1]\n\tresult = append(result, number...)\n\tresult = append(result, suffix...)\n\tresult = append(result, '\"')\n\treturn result, nil\n}\n\nfunc (q Quantity) MarshalCBOR() ([]byte, error) {\n\t// The call to String() should never return the string \"<nil>\" because the receiver's\n\t// address will never be nil.\n\treturn cbor.Marshal(q.String())\n}\n\n// ToUnstructured implements the value.UnstructuredConverter interface.\nfunc (q Quantity) ToUnstructured() interface{} {\n\treturn q.String()\n}\n\n// UnmarshalJSON implements the json.Unmarshaller interface.\n// TODO: Remove support for leading/trailing whitespace\nfunc (q *Quantity) UnmarshalJSON(value []byte) error {\n\tl := len(value)\n\tif l == 4 && bytes.Equal(value, []byte(\"null\")) {\n\t\tq.d.Dec = nil\n\t\tq.i = int64Amount{}\n\t\treturn nil\n\t}\n\tif l >= 2 && value[0] == '\"' && value[l-1] == '\"' {\n\t\tvalue = value[1 : l-1]\n\t}\n\n\tparsed, err := ParseQuantity(strings.TrimSpace(string(value)))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// This copy is safe because parsed will not be referred to again.\n\t*q = parsed\n\treturn nil\n}\n\nfunc (q *Quantity) UnmarshalCBOR(value []byte) error {\n\tvar s *string\n\tif err := cbor.Unmarshal(value, &s); err != nil {\n\t\treturn err\n\t}\n\n\tif s == nil {\n\t\tq.d.Dec = nil\n\t\tq.i = int64Amount{}\n\t\treturn nil\n\t}\n\n\tparsed, err := ParseQuantity(strings.TrimSpace(*s))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*q = parsed\n\treturn nil\n}\n\n// NewDecimalQuantity returns a new Quantity representing the given\n// value in the given format.\nfunc NewDecimalQuantity(b inf.Dec, format Format) *Quantity {\n\treturn &Quantity{\n\t\td: infDecAmount{&b},\n\t\tFormat: format,\n\t}\n}\n\n// NewQuantity returns a new Quantity representing the given\n// value in the given format.\nfunc NewQuantity(value int64, format Format) *Quantity {\n\treturn &Quantity{\n\t\ti: int64Amount{value: value},\n\t\tFormat: format,\n\t}\n}\n\n// NewMilliQuantity returns a new Quantity representing the given\n// value * 1/1000 in the given format. Note that BinarySI formatting\n// will round fractional values, and will be changed to DecimalSI for\n// values x where (-1 < x < 1) && (x != 0).\nfunc NewMilliQuantity(value int64, format Format) *Quantity {\n\treturn &Quantity{\n\t\ti: int64Amount{value: value, scale: -3},\n\t\tFormat: format,\n\t}\n}\n\n// NewScaledQuantity returns a new Quantity representing the given\n// value * 10^scale in DecimalSI format.\nfunc NewScaledQuantity(value int64, scale Scale) *Quantity {\n\treturn &Quantity{\n\t\ti: int64Amount{value: value, scale: scale},\n\t\tFormat: DecimalSI,\n\t}\n}\n\n// Value returns the unscaled value of q rounded up to the nearest integer away from 0.\nfunc (q *Quantity) Value() int64 {\n\treturn q.ScaledValue(0)\n}\n\n// MilliValue returns the value of ceil(q * 1000); this could overflow an int64;\n// if that's a concern, call Value() first to verify the number is small enough.\nfunc (q *Quantity) MilliValue() int64 {\n\treturn q.ScaledValue(Milli)\n}\n\n// ScaledValue returns the value of ceil(q / 10^scale).\n// For example, NewQuantity(1, DecimalSI).ScaledValue(Milli) returns 1000.\n// This could overflow an int64.\n// To detect overflow, call Value() first and verify the expected magnitude.\nfunc (q *Quantity) ScaledValue(scale Scale) int64 {\n\tif q.d.Dec == nil {\n\t\ti, _ := q.i.AsScaledInt64(scale)\n\t\treturn i\n\t}\n\tdec := q.d.Dec\n\treturn scaledValue(dec.UnscaledBig(), int(dec.Scale()), int(scale.infScale()))\n}\n\n// Set sets q's value to be value.\nfunc (q *Quantity) Set(value int64) {\n\tq.SetScaled(value, 0)\n}\n\n// SetMilli sets q's value to be value * 1/1000.\nfunc (q *Quantity) SetMilli(value int64) {\n\tq.SetScaled(value, Milli)\n}\n\n// SetScaled sets q's value to be value * 10^scale\nfunc (q *Quantity) SetScaled(value int64, scale Scale) {\n\tq.s = \"\"\n\tq.d.Dec = nil\n\tq.i = int64Amount{value: value, scale: scale}\n}\n\n// QuantityValue makes it possible to use a Quantity as value for a command\n// line parameter.\n//\n// +protobuf=true\n// +protobuf.embed=string\n// +protobuf.options.marshal=false\n// +protobuf.options.(gogoproto.goproto_stringer)=false\n// +k8s:deepcopy-gen=true\n// +k8s:openapi-model-package=io.k8s.apimachinery.pkg.api.resource\ntype QuantityValue struct {\n\tQuantity\n}\n\n// Set implements pflag.Value.Set and Go flag.Value.Set.\nfunc (q *QuantityValue) Set(s string) error {\n\tquantity, err := ParseQuantity(s)\n\tif err != nil {\n\t\treturn err\n\t}\n\tq.Quantity = quantity\n\treturn nil\n}\n\n// Type implements pflag.Value.Type.\nfunc (q QuantityValue) Type() string {\n\treturn \"quantity\"\n}\n": * third_party/k8s.io/apimachinery/pkg/api/resource/quantity.go
Update third party directory README file
1 file(s) updated with "This folder contains third-party code from kubernetes:\n\n- [kubernetes/apiserver](https://github.com/kubernetes/apiserver).\n- [kubernetes/apimachinery](https://github.com/kubernetes/apimachinery).\n\nThe current version is based on kubernetes v1.35.0).\n\nAll code in this folder is licensed under the Apache License 2.0, see [LICENSE](LICENSE).\n": * ./third_party/README.md
Update go.mod replaces for k8s.io/apiserver and k8s.io/apimachinery packages
ran shell command "go mod edit -replace=k8s.io/apiserver@v1.35.0=./third_party/k8s.io/apiserver/ -replace=k8s.io/apimachinery@v1.35.0=./third_party/k8s.io/apimachinery/"
Update apiserver version in use
go.mod updated Module path "k8s.io/apiserver" version from "v1.34.2" to "v1.35.0"
Run `go mod tidy`
ran shell command "go mod tidy"
Created automatically by Updatecli
Options:
Most of Updatecli configuration is done via its manifest(s).
Feel free to report any issues at github.com/updatecli/updatecli.
If you find this tool useful, do not hesitate to star our GitHub repository as a sign of appreciation, and/or to tell us directly on our chat!