rebase: update kubernetes in api folder

updating the kubernetes to 1.31.0 in the
api folder.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2024-08-14 09:27:23 +02:00
committed by mergify[bot]
parent 2c0e65b828
commit 63c4c05b35
80 changed files with 16208 additions and 2614 deletions

View File

@ -25,6 +25,8 @@ import (
"strconv"
"strings"
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
inf "gopkg.in/inf.v0"
)
@ -683,6 +685,12 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
return result, nil
}
func (q Quantity) MarshalCBOR() ([]byte, error) {
// The call to String() should never return the string "<nil>" because the receiver's
// address will never be nil.
return cbor.Marshal(q.String())
}
// ToUnstructured implements the value.UnstructuredConverter interface.
func (q Quantity) ToUnstructured() interface{} {
return q.String()
@ -711,6 +719,27 @@ func (q *Quantity) UnmarshalJSON(value []byte) error {
return nil
}
func (q *Quantity) UnmarshalCBOR(value []byte) error {
var s *string
if err := cbor.Unmarshal(value, &s); err != nil {
return err
}
if s == nil {
q.d.Dec = nil
q.i = int64Amount{}
return nil
}
parsed, err := ParseQuantity(strings.TrimSpace(*s))
if err != nil {
return err
}
*q = parsed
return nil
}
// NewDecimalQuantity returns a new Quantity representing the given
// value in the given format.
func NewDecimalQuantity(b inf.Dec, format Format) *Quantity {