mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-13 06:57:09 +08:00
vendor: bump k8s to v0.25.4
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
31
vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
generated
vendored
31
vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
generated
vendored
@ -1,20 +1,17 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
reviewers:
|
||||
- thockin
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- deads2k
|
||||
- brendandburns
|
||||
- derekwaynecarr
|
||||
- caesarxuchao
|
||||
- mikedanese
|
||||
- liggitt
|
||||
- saad-ali
|
||||
- janetkuo
|
||||
- tallclair
|
||||
- dims
|
||||
- hongchaodeng
|
||||
- krousey
|
||||
- cjcullen
|
||||
- thockin
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- deads2k
|
||||
- derekwaynecarr
|
||||
- caesarxuchao
|
||||
- mikedanese
|
||||
- liggitt
|
||||
- saad-ali
|
||||
- janetkuo
|
||||
- tallclair
|
||||
- dims
|
||||
- cjcullen
|
||||
|
272
vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
generated
vendored
272
vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
generated
vendored
@ -44,6 +44,28 @@ type APIStatus interface {
|
||||
|
||||
var _ error = &StatusError{}
|
||||
|
||||
var knownReasons = map[metav1.StatusReason]struct{}{
|
||||
// metav1.StatusReasonUnknown : {}
|
||||
metav1.StatusReasonUnauthorized: {},
|
||||
metav1.StatusReasonForbidden: {},
|
||||
metav1.StatusReasonNotFound: {},
|
||||
metav1.StatusReasonAlreadyExists: {},
|
||||
metav1.StatusReasonConflict: {},
|
||||
metav1.StatusReasonGone: {},
|
||||
metav1.StatusReasonInvalid: {},
|
||||
metav1.StatusReasonServerTimeout: {},
|
||||
metav1.StatusReasonTimeout: {},
|
||||
metav1.StatusReasonTooManyRequests: {},
|
||||
metav1.StatusReasonBadRequest: {},
|
||||
metav1.StatusReasonMethodNotAllowed: {},
|
||||
metav1.StatusReasonNotAcceptable: {},
|
||||
metav1.StatusReasonRequestEntityTooLarge: {},
|
||||
metav1.StatusReasonUnsupportedMediaType: {},
|
||||
metav1.StatusReasonInternalError: {},
|
||||
metav1.StatusReasonExpired: {},
|
||||
metav1.StatusReasonServiceUnavailable: {},
|
||||
}
|
||||
|
||||
// Error implements the Error interface.
|
||||
func (e *StatusError) Error() string {
|
||||
return e.ErrStatus.Message
|
||||
@ -65,21 +87,21 @@ func (e *StatusError) DebugError() (string, []interface{}) {
|
||||
|
||||
// HasStatusCause returns true if the provided error has a details cause
|
||||
// with the provided type name.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func HasStatusCause(err error, name metav1.CauseType) bool {
|
||||
_, ok := StatusCause(err, name)
|
||||
return ok
|
||||
}
|
||||
|
||||
// StatusCause returns the named cause from the provided error if it exists and
|
||||
// the error is of the type APIStatus. Otherwise it returns false.
|
||||
// the error unwraps to the type APIStatus. Otherwise it returns false.
|
||||
func StatusCause(err error, name metav1.CauseType) (metav1.StatusCause, bool) {
|
||||
apierr, ok := err.(APIStatus)
|
||||
if !ok || apierr == nil || apierr.Status().Details == nil {
|
||||
return metav1.StatusCause{}, false
|
||||
}
|
||||
for _, cause := range apierr.Status().Details.Causes {
|
||||
if cause.Type == name {
|
||||
return cause, true
|
||||
status, ok := err.(APIStatus)
|
||||
if (ok || errors.As(err, &status)) && status.Status().Details != nil {
|
||||
for _, cause := range status.Status().Details.Causes {
|
||||
if cause.Type == name {
|
||||
return cause, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return metav1.StatusCause{}, false
|
||||
@ -148,6 +170,25 @@ func NewAlreadyExists(qualifiedResource schema.GroupResource, name string) *Stat
|
||||
}}
|
||||
}
|
||||
|
||||
// NewGenerateNameConflict returns an error indicating the server
|
||||
// was not able to generate a valid name for a resource.
|
||||
func NewGenerateNameConflict(qualifiedResource schema.GroupResource, name string, retryAfterSeconds int) *StatusError {
|
||||
return &StatusError{metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusConflict,
|
||||
Reason: metav1.StatusReasonAlreadyExists,
|
||||
Details: &metav1.StatusDetails{
|
||||
Group: qualifiedResource.Group,
|
||||
Kind: qualifiedResource.Resource,
|
||||
Name: name,
|
||||
RetryAfterSeconds: int32(retryAfterSeconds),
|
||||
},
|
||||
Message: fmt.Sprintf(
|
||||
"%s %q already exists, the server was not able to generate a unique name for the object",
|
||||
qualifiedResource.String(), name),
|
||||
}}
|
||||
}
|
||||
|
||||
// NewUnauthorized returns an error indicating the client is not authorized to perform the requested
|
||||
// action.
|
||||
func NewUnauthorized(reason string) *StatusError {
|
||||
@ -248,7 +289,7 @@ func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorLis
|
||||
Field: err.Field,
|
||||
})
|
||||
}
|
||||
return &StatusError{metav1.Status{
|
||||
err := &StatusError{metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusUnprocessableEntity,
|
||||
Reason: metav1.StatusReasonInvalid,
|
||||
@ -258,8 +299,14 @@ func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorLis
|
||||
Name: name,
|
||||
Causes: causes,
|
||||
},
|
||||
Message: fmt.Sprintf("%s %q is invalid: %v", qualifiedKind.String(), name, errs.ToAggregate()),
|
||||
}}
|
||||
aggregatedErrs := errs.ToAggregate()
|
||||
if aggregatedErrs == nil {
|
||||
err.ErrStatus.Message = fmt.Sprintf("%s %q is invalid", qualifiedKind.String(), name)
|
||||
} else {
|
||||
err.ErrStatus.Message = fmt.Sprintf("%s %q is invalid: %v", qualifiedKind.String(), name, aggregatedErrs)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// NewBadRequest creates an error that indicates that the request is invalid and can not be processed.
|
||||
@ -476,138 +523,242 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource schema.Gr
|
||||
}
|
||||
|
||||
// IsNotFound returns true if the specified error was created by NewNotFound.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsNotFound(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonNotFound
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonNotFound {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusNotFound {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsAlreadyExists determines if the err is an error which indicates that a specified resource already exists.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsAlreadyExists(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonAlreadyExists
|
||||
}
|
||||
|
||||
// IsConflict determines if the err is an error which indicates the provided update conflicts.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsConflict(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonConflict
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonConflict {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusConflict {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsInvalid determines if the err is an error which indicates the provided resource is not valid.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsInvalid(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonInvalid
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonInvalid {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusUnprocessableEntity {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsGone is true if the error indicates the requested resource is no longer available.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsGone(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonGone
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonGone {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusGone {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsResourceExpired is true if the error indicates the resource has expired and the current action is
|
||||
// no longer possible.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsResourceExpired(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonExpired
|
||||
}
|
||||
|
||||
// IsNotAcceptable determines if err is an error which indicates that the request failed due to an invalid Accept header
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsNotAcceptable(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonNotAcceptable
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonNotAcceptable {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusNotAcceptable {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsUnsupportedMediaType determines if err is an error which indicates that the request failed due to an invalid Content-Type header
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsUnsupportedMediaType(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonUnsupportedMediaType
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonUnsupportedMediaType {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusUnsupportedMediaType {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsMethodNotSupported determines if the err is an error which indicates the provided action could not
|
||||
// be performed because it is not supported by the server.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsMethodNotSupported(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonMethodNotAllowed
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonMethodNotAllowed {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusMethodNotAllowed {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServiceUnavailable is true if the error indicates the underlying service is no longer available.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsServiceUnavailable(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonServiceUnavailable
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonServiceUnavailable {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusServiceUnavailable {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsBadRequest determines if err is an error which indicates that the request is invalid.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsBadRequest(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonBadRequest
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonBadRequest {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusBadRequest {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsUnauthorized determines if err is an error which indicates that the request is unauthorized and
|
||||
// requires authentication by the user.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsUnauthorized(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonUnauthorized
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonUnauthorized {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusUnauthorized {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsForbidden determines if err is an error which indicates that the request is forbidden and cannot
|
||||
// be completed as requested.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsForbidden(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonForbidden
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonForbidden {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusForbidden {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsTimeout determines if err is an error which indicates that request times out due to long
|
||||
// processing.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsTimeout(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonTimeout
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonTimeout {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusGatewayTimeout {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerTimeout determines if err is an error which indicates that the request needs to be retried
|
||||
// by the client.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsServerTimeout(err error) bool {
|
||||
// do not check the status code, because no https status code exists that can
|
||||
// be scoped to retryable timeouts.
|
||||
return ReasonForError(err) == metav1.StatusReasonServerTimeout
|
||||
}
|
||||
|
||||
// IsInternalError determines if err is an error which indicates an internal server error.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsInternalError(err error) bool {
|
||||
return ReasonForError(err) == metav1.StatusReasonInternalError
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonInternalError {
|
||||
return true
|
||||
}
|
||||
if _, ok := knownReasons[reason]; !ok && code == http.StatusInternalServerError {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsTooManyRequests determines if err is an error which indicates that there are too many requests
|
||||
// that the server cannot handle.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsTooManyRequests(err error) bool {
|
||||
if ReasonForError(err) == metav1.StatusReasonTooManyRequests {
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonTooManyRequests {
|
||||
return true
|
||||
}
|
||||
if status := APIStatus(nil); errors.As(err, &status) {
|
||||
return status.Status().Code == http.StatusTooManyRequests
|
||||
|
||||
// IsTooManyRequests' checking of code predates the checking of the code in
|
||||
// the other Is* functions. In order to maintain backward compatibility, this
|
||||
// does not check that the reason is unknown.
|
||||
if code == http.StatusTooManyRequests {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRequestEntityTooLargeError determines if err is an error which indicates
|
||||
// the request entity is too large.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsRequestEntityTooLargeError(err error) bool {
|
||||
if ReasonForError(err) == metav1.StatusReasonRequestEntityTooLarge {
|
||||
reason, code := reasonAndCodeForError(err)
|
||||
if reason == metav1.StatusReasonRequestEntityTooLarge {
|
||||
return true
|
||||
}
|
||||
if status := APIStatus(nil); errors.As(err, &status) {
|
||||
return status.Status().Code == http.StatusRequestEntityTooLarge
|
||||
|
||||
// IsRequestEntityTooLargeError's checking of code predates the checking of
|
||||
// the code in the other Is* functions. In order to maintain backward
|
||||
// compatibility, this does not check that the reason is unknown.
|
||||
if code == http.StatusRequestEntityTooLarge {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsUnexpectedServerError returns true if the server response was not in the expected API format,
|
||||
// and may be the result of another HTTP actor.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsUnexpectedServerError(err error) bool {
|
||||
if status := APIStatus(nil); errors.As(err, &status) && status.Status().Details != nil {
|
||||
status, ok := err.(APIStatus)
|
||||
if (ok || errors.As(err, &status)) && status.Status().Details != nil {
|
||||
for _, cause := range status.Status().Details.Causes {
|
||||
if cause.Type == metav1.CauseTypeUnexpectedServerResponse {
|
||||
return true
|
||||
@ -618,19 +769,20 @@ func IsUnexpectedServerError(err error) bool {
|
||||
}
|
||||
|
||||
// IsUnexpectedObjectError determines if err is due to an unexpected object from the master.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func IsUnexpectedObjectError(err error) bool {
|
||||
uoe := &UnexpectedObjectError{}
|
||||
return err != nil && errors.As(err, &uoe)
|
||||
uoe, ok := err.(*UnexpectedObjectError)
|
||||
return err != nil && (ok || errors.As(err, &uoe))
|
||||
}
|
||||
|
||||
// SuggestsClientDelay returns true if this error suggests a client delay as well as the
|
||||
// suggested seconds to wait, or false if the error does not imply a wait. It does not
|
||||
// address whether the error *should* be retried, since some errors (like a 3xx) may
|
||||
// request delay without retry.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns false when the error is nil.
|
||||
func SuggestsClientDelay(err error) (int, bool) {
|
||||
if t := APIStatus(nil); errors.As(err, &t) && t.Status().Details != nil {
|
||||
t, ok := err.(APIStatus)
|
||||
if (ok || errors.As(err, &t)) && t.Status().Details != nil {
|
||||
switch t.Status().Reason {
|
||||
// this StatusReason explicitly requests the caller to delay the action
|
||||
case metav1.StatusReasonServerTimeout:
|
||||
@ -645,14 +797,22 @@ func SuggestsClientDelay(err error) (int, bool) {
|
||||
}
|
||||
|
||||
// ReasonForError returns the HTTP status for a particular error.
|
||||
// It supports wrapped errors.
|
||||
// It supports wrapped errors and returns StatusReasonUnknown when
|
||||
// the error is nil or doesn't have a status.
|
||||
func ReasonForError(err error) metav1.StatusReason {
|
||||
if status := APIStatus(nil); errors.As(err, &status) {
|
||||
if status, ok := err.(APIStatus); ok || errors.As(err, &status) {
|
||||
return status.Status().Reason
|
||||
}
|
||||
return metav1.StatusReasonUnknown
|
||||
}
|
||||
|
||||
func reasonAndCodeForError(err error) (metav1.StatusReason, int32) {
|
||||
if status, ok := err.(APIStatus); ok || errors.As(err, &status) {
|
||||
return status.Status().Reason, status.Status().Code
|
||||
}
|
||||
return metav1.StatusReasonUnknown, 0
|
||||
}
|
||||
|
||||
// ErrorReporter converts generic errors into runtime.Object errors without
|
||||
// requiring the caller to take a dependency on meta/v1 (where Status lives).
|
||||
// This prevents circular dependencies in core watch code.
|
||||
|
26
vendor/k8s.io/apimachinery/pkg/api/meta/OWNERS
generated
vendored
26
vendor/k8s.io/apimachinery/pkg/api/meta/OWNERS
generated
vendored
@ -1,18 +1,14 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
reviewers:
|
||||
- thockin
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- deads2k
|
||||
- brendandburns
|
||||
- derekwaynecarr
|
||||
- caesarxuchao
|
||||
- mikedanese
|
||||
- liggitt
|
||||
- janetkuo
|
||||
- ncdc
|
||||
- dims
|
||||
- krousey
|
||||
- resouer
|
||||
- mfojtik
|
||||
- thockin
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- deads2k
|
||||
- derekwaynecarr
|
||||
- caesarxuchao
|
||||
- mikedanese
|
||||
- liggitt
|
||||
- janetkuo
|
||||
- ncdc
|
||||
- dims
|
||||
|
6
vendor/k8s.io/apimachinery/pkg/api/meta/conditions.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/api/meta/conditions.go
generated
vendored
@ -24,9 +24,9 @@ import (
|
||||
|
||||
// SetStatusCondition sets the corresponding condition in conditions to newCondition.
|
||||
// conditions must be non-nil.
|
||||
// 1. if the condition of the specified type already exists (all fields of the existing condition are updated to
|
||||
// newCondition, LastTransitionTime is set to now if the new status differs from the old status)
|
||||
// 2. if a condition of the specified type does not exist (LastTransitionTime is set to now() if unset, and newCondition is appended)
|
||||
// 1. if the condition of the specified type already exists (all fields of the existing condition are updated to
|
||||
// newCondition, LastTransitionTime is set to now if the new status differs from the old status)
|
||||
// 2. if a condition of the specified type does not exist (LastTransitionTime is set to now() if unset, and newCondition is appended)
|
||||
func SetStatusCondition(conditions *[]metav1.Condition, newCondition metav1.Condition) {
|
||||
if conditions == nil {
|
||||
return
|
||||
|
8
vendor/k8s.io/apimachinery/pkg/api/meta/firsthit_restmapper.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/api/meta/firsthit_restmapper.go
generated
vendored
@ -23,6 +23,10 @@ import (
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ResettableRESTMapper = &FirstHitRESTMapper{}
|
||||
)
|
||||
|
||||
// FirstHitRESTMapper is a wrapper for multiple RESTMappers which returns the
|
||||
// first successful result for the singular requests
|
||||
type FirstHitRESTMapper struct {
|
||||
@ -75,6 +79,10 @@ func (m FirstHitRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
|
||||
return nil, collapseAggregateErrors(errors)
|
||||
}
|
||||
|
||||
func (m FirstHitRESTMapper) Reset() {
|
||||
m.MultiRESTMapper.Reset()
|
||||
}
|
||||
|
||||
// collapseAggregateErrors returns the minimal errors. it handles empty as nil, handles one item in a list
|
||||
// by returning the item, and collapses all NoMatchErrors to a single one (since they should all be the same)
|
||||
func collapseAggregateErrors(errors []error) error {
|
||||
|
7
vendor/k8s.io/apimachinery/pkg/api/meta/help.go
generated
vendored
7
vendor/k8s.io/apimachinery/pkg/api/meta/help.go
generated
vendored
@ -40,7 +40,8 @@ var (
|
||||
|
||||
// IsListType returns true if the provided Object has a slice called Items.
|
||||
// TODO: Replace the code in this check with an interface comparison by
|
||||
// creating and enforcing that lists implement a list accessor.
|
||||
//
|
||||
// creating and enforcing that lists implement a list accessor.
|
||||
func IsListType(obj runtime.Object) bool {
|
||||
switch t := obj.(type) {
|
||||
case runtime.Unstructured:
|
||||
@ -97,7 +98,7 @@ func getItemsPtr(list runtime.Object) (interface{}, error) {
|
||||
return nil, errExpectFieldItems
|
||||
}
|
||||
switch items.Kind() {
|
||||
case reflect.Interface, reflect.Ptr:
|
||||
case reflect.Interface, reflect.Pointer:
|
||||
target := reflect.TypeOf(items.Interface()).Elem()
|
||||
if target.Kind() != reflect.Slice {
|
||||
return nil, errExpectSliceItems
|
||||
@ -130,7 +131,7 @@ func EachListItem(obj runtime.Object, fn func(runtime.Object) error) error {
|
||||
return nil
|
||||
}
|
||||
takeAddr := false
|
||||
if elemType := items.Type().Elem(); elemType.Kind() != reflect.Ptr && elemType.Kind() != reflect.Interface {
|
||||
if elemType := items.Type().Elem(); elemType.Kind() != reflect.Pointer && elemType.Kind() != reflect.Interface {
|
||||
if !items.Index(0).CanAddr() {
|
||||
return fmt.Errorf("unable to take address of items in %T for EachListItem", obj)
|
||||
}
|
||||
|
9
vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
generated
vendored
9
vendor/k8s.io/apimachinery/pkg/api/meta/interfaces.go
generated
vendored
@ -132,3 +132,12 @@ type RESTMapper interface {
|
||||
|
||||
ResourceSingularizer(resource string) (singular string, err error)
|
||||
}
|
||||
|
||||
// ResettableRESTMapper is a RESTMapper which is capable of resetting itself
|
||||
// from discovery.
|
||||
// All rest mappers that delegate to other rest mappers must implement this interface and dynamically
|
||||
// check if the delegate mapper supports the Reset() operation.
|
||||
type ResettableRESTMapper interface {
|
||||
RESTMapper
|
||||
Reset()
|
||||
}
|
||||
|
12
vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/api/meta/lazy.go
generated
vendored
@ -32,7 +32,7 @@ type lazyObject struct {
|
||||
mapper RESTMapper
|
||||
}
|
||||
|
||||
// NewLazyObjectLoader handles unrecoverable errors when creating a RESTMapper / ObjectTyper by
|
||||
// NewLazyRESTMapperLoader handles unrecoverable errors when creating a RESTMapper / ObjectTyper by
|
||||
// returning those initialization errors when the interface methods are invoked. This defers the
|
||||
// initialization and any server calls until a client actually needs to perform the action.
|
||||
func NewLazyRESTMapperLoader(fn func() (RESTMapper, error)) RESTMapper {
|
||||
@ -52,7 +52,7 @@ func (o *lazyObject) init() error {
|
||||
return o.err
|
||||
}
|
||||
|
||||
var _ RESTMapper = &lazyObject{}
|
||||
var _ ResettableRESTMapper = &lazyObject{}
|
||||
|
||||
func (o *lazyObject) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error) {
|
||||
if err := o.init(); err != nil {
|
||||
@ -102,3 +102,11 @@ func (o *lazyObject) ResourceSingularizer(resource string) (singular string, err
|
||||
}
|
||||
return o.mapper.ResourceSingularizer(resource)
|
||||
}
|
||||
|
||||
func (o *lazyObject) Reset() {
|
||||
o.lock.Lock()
|
||||
defer o.lock.Unlock()
|
||||
if o.loaded && o.err == nil {
|
||||
MaybeResetRESTMapper(o.mapper)
|
||||
}
|
||||
}
|
||||
|
5
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
5
vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
generated
vendored
@ -130,7 +130,6 @@ func AsPartialObjectMetadata(m metav1.Object) *metav1.PartialObjectMetadata {
|
||||
Annotations: m.GetAnnotations(),
|
||||
OwnerReferences: m.GetOwnerReferences(),
|
||||
Finalizers: m.GetFinalizers(),
|
||||
ClusterName: m.GetClusterName(),
|
||||
ManagedFields: m.GetManagedFields(),
|
||||
},
|
||||
}
|
||||
@ -600,7 +599,7 @@ func (a genericAccessor) SetFinalizers(finalizers []string) {
|
||||
func (a genericAccessor) GetOwnerReferences() []metav1.OwnerReference {
|
||||
var ret []metav1.OwnerReference
|
||||
s := a.ownerReferences
|
||||
if s.Kind() != reflect.Ptr || s.Elem().Kind() != reflect.Slice {
|
||||
if s.Kind() != reflect.Pointer || s.Elem().Kind() != reflect.Slice {
|
||||
klog.Errorf("expect %v to be a pointer to slice", s)
|
||||
return ret
|
||||
}
|
||||
@ -618,7 +617,7 @@ func (a genericAccessor) GetOwnerReferences() []metav1.OwnerReference {
|
||||
|
||||
func (a genericAccessor) SetOwnerReferences(references []metav1.OwnerReference) {
|
||||
s := a.ownerReferences
|
||||
if s.Kind() != reflect.Ptr || s.Elem().Kind() != reflect.Slice {
|
||||
if s.Kind() != reflect.Pointer || s.Elem().Kind() != reflect.Slice {
|
||||
klog.Errorf("expect %v to be a pointer to slice", s)
|
||||
}
|
||||
s = s.Elem()
|
||||
|
12
vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/api/meta/multirestmapper.go
generated
vendored
@ -24,11 +24,15 @@ import (
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ResettableRESTMapper = MultiRESTMapper{}
|
||||
)
|
||||
|
||||
// MultiRESTMapper is a wrapper for multiple RESTMappers.
|
||||
type MultiRESTMapper []RESTMapper
|
||||
|
||||
func (m MultiRESTMapper) String() string {
|
||||
nested := []string{}
|
||||
nested := make([]string, 0, len(m))
|
||||
for _, t := range m {
|
||||
currString := fmt.Sprintf("%v", t)
|
||||
splitStrings := strings.Split(currString, "\n")
|
||||
@ -208,3 +212,9 @@ func (m MultiRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (
|
||||
}
|
||||
return allMappings, nil
|
||||
}
|
||||
|
||||
func (m MultiRESTMapper) Reset() {
|
||||
for _, t := range m {
|
||||
MaybeResetRESTMapper(t)
|
||||
}
|
||||
}
|
||||
|
8
vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/api/meta/priority.go
generated
vendored
@ -29,6 +29,10 @@ const (
|
||||
AnyKind = "*"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ResettableRESTMapper = PriorityRESTMapper{}
|
||||
)
|
||||
|
||||
// PriorityRESTMapper is a wrapper for automatically choosing a particular Resource or Kind
|
||||
// when multiple matches are possible
|
||||
type PriorityRESTMapper struct {
|
||||
@ -220,3 +224,7 @@ func (m PriorityRESTMapper) ResourcesFor(partiallySpecifiedResource schema.Group
|
||||
func (m PriorityRESTMapper) KindsFor(partiallySpecifiedResource schema.GroupVersionResource) (gvk []schema.GroupVersionKind, err error) {
|
||||
return m.Delegate.KindsFor(partiallySpecifiedResource)
|
||||
}
|
||||
|
||||
func (m PriorityRESTMapper) Reset() {
|
||||
MaybeResetRESTMapper(m.Delegate)
|
||||
}
|
||||
|
8
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/api/meta/restmapper.go
generated
vendored
@ -519,3 +519,11 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string
|
||||
}
|
||||
return mappings, nil
|
||||
}
|
||||
|
||||
// MaybeResetRESTMapper calls Reset() on the mapper if it is a ResettableRESTMapper.
|
||||
func MaybeResetRESTMapper(mapper RESTMapper) {
|
||||
m, ok := mapper.(ResettableRESTMapper)
|
||||
if ok {
|
||||
m.Reset()
|
||||
}
|
||||
}
|
||||
|
17
vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
generated
vendored
17
vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
generated
vendored
@ -1,12 +1,11 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
reviewers:
|
||||
- thockin
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- derekwaynecarr
|
||||
- mikedanese
|
||||
- saad-ali
|
||||
- janetkuo
|
||||
- xiang90
|
||||
- thockin
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- derekwaynecarr
|
||||
- mikedanese
|
||||
- saad-ali
|
||||
- janetkuo
|
||||
|
57
vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
generated
vendored
57
vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
generated
vendored
@ -61,8 +61,32 @@ func (m *Quantity) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_Quantity proto.InternalMessageInfo
|
||||
|
||||
func (m *QuantityValue) Reset() { *m = QuantityValue{} }
|
||||
func (*QuantityValue) ProtoMessage() {}
|
||||
func (*QuantityValue) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_612bba87bd70906c, []int{1}
|
||||
}
|
||||
func (m *QuantityValue) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_QuantityValue.Unmarshal(m, b)
|
||||
}
|
||||
func (m *QuantityValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_QuantityValue.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *QuantityValue) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QuantityValue.Merge(m, src)
|
||||
}
|
||||
func (m *QuantityValue) XXX_Size() int {
|
||||
return xxx_messageInfo_QuantityValue.Size(m)
|
||||
}
|
||||
func (m *QuantityValue) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QuantityValue.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QuantityValue proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Quantity)(nil), "k8s.io.apimachinery.pkg.api.resource.Quantity")
|
||||
proto.RegisterType((*QuantityValue)(nil), "k8s.io.apimachinery.pkg.api.resource.QuantityValue")
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -70,20 +94,21 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_612bba87bd70906c = []byte{
|
||||
// 237 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8e, 0xb1, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0x40, 0xcf, 0x0b, 0x2a, 0x19, 0x2b, 0x84, 0x10, 0xc3, 0xa5, 0x42, 0x0c, 0x2c, 0xd8, 0x6b,
|
||||
0xc5, 0xc8, 0xce, 0x00, 0x23, 0x5b, 0x92, 0x1e, 0xae, 0x15, 0xd5, 0x8e, 0x2e, 0x36, 0x52, 0xb7,
|
||||
0x8e, 0x8c, 0x1d, 0x19, 0x9b, 0xbf, 0xe9, 0xd8, 0xb1, 0x03, 0x03, 0x31, 0x3f, 0x82, 0xea, 0x36,
|
||||
0x52, 0xb7, 0x7b, 0xef, 0xf4, 0x4e, 0x97, 0xbd, 0xd4, 0xd3, 0x56, 0x1a, 0xa7, 0xea, 0x50, 0x12,
|
||||
0x5b, 0xf2, 0xd4, 0xaa, 0x4f, 0xb2, 0x33, 0xc7, 0xea, 0xb4, 0x28, 0x1a, 0xb3, 0x28, 0xaa, 0xb9,
|
||||
0xb1, 0xc4, 0x4b, 0xd5, 0xd4, 0xfa, 0x20, 0x14, 0x53, 0xeb, 0x02, 0x57, 0xa4, 0x34, 0x59, 0xe2,
|
||||
0xc2, 0xd3, 0x4c, 0x36, 0xec, 0xbc, 0x1b, 0xdf, 0x1f, 0x2b, 0x79, 0x5e, 0xc9, 0xa6, 0xd6, 0x07,
|
||||
0x21, 0x87, 0xea, 0xf6, 0x51, 0x1b, 0x3f, 0x0f, 0xa5, 0xac, 0xdc, 0x42, 0x69, 0xa7, 0x9d, 0x4a,
|
||||
0x71, 0x19, 0x3e, 0x12, 0x25, 0x48, 0xd3, 0xf1, 0xe8, 0xdd, 0x34, 0x1b, 0xbd, 0x86, 0xc2, 0x7a,
|
||||
0xe3, 0x97, 0xe3, 0xeb, 0xec, 0xa2, 0xf5, 0x6c, 0xac, 0xbe, 0x11, 0x13, 0xf1, 0x70, 0xf9, 0x76,
|
||||
0xa2, 0xa7, 0xab, 0xef, 0x4d, 0x0e, 0x5f, 0x5d, 0x0e, 0xeb, 0x2e, 0x87, 0x4d, 0x97, 0xc3, 0xea,
|
||||
0x67, 0x02, 0xcf, 0x72, 0xdb, 0x23, 0xec, 0x7a, 0x84, 0x7d, 0x8f, 0xb0, 0x8a, 0x28, 0xb6, 0x11,
|
||||
0xc5, 0x2e, 0xa2, 0xd8, 0x47, 0x14, 0xbf, 0x11, 0xc5, 0xfa, 0x0f, 0xe1, 0x7d, 0x34, 0x3c, 0xf6,
|
||||
0x1f, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x08, 0x88, 0x49, 0x0e, 0x01, 0x00, 0x00,
|
||||
// 254 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0xcd, 0xb6, 0x28, 0xd6,
|
||||
0xcb, 0xcc, 0xd7, 0xcf, 0x2e, 0x4d, 0x4a, 0x2d, 0xca, 0x4b, 0x2d, 0x49, 0x2d, 0xd6, 0x2f, 0x4b,
|
||||
0xcd, 0x4b, 0xc9, 0x2f, 0xd2, 0x87, 0x4a, 0x24, 0x16, 0x64, 0xe6, 0x26, 0x26, 0x67, 0x64, 0xe6,
|
||||
0xa5, 0x16, 0x55, 0xea, 0x17, 0x64, 0xa7, 0x83, 0x04, 0xf4, 0x8b, 0x52, 0x8b, 0xf3, 0x4b, 0x8b,
|
||||
0x92, 0x53, 0xf5, 0xd3, 0x53, 0xf3, 0x52, 0x8b, 0x12, 0x4b, 0x52, 0x53, 0xf4, 0x0a, 0x8a, 0xf2,
|
||||
0x4b, 0xf2, 0x85, 0x54, 0x20, 0xba, 0xf4, 0x90, 0x75, 0xe9, 0x15, 0x64, 0xa7, 0x83, 0x04, 0xf4,
|
||||
0x60, 0xba, 0xa4, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xd3,
|
||||
0xf3, 0xd3, 0xf3, 0xf5, 0xc1, 0x9a, 0x93, 0x4a, 0xd3, 0xc0, 0x3c, 0x30, 0x07, 0xcc, 0x82, 0x18,
|
||||
0xaa, 0x64, 0xc1, 0xc5, 0x11, 0x58, 0x9a, 0x98, 0x57, 0x92, 0x59, 0x52, 0x29, 0x24, 0xc6, 0xc5,
|
||||
0x56, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe5, 0x59,
|
||||
0x89, 0xcc, 0x58, 0x20, 0xcf, 0xd0, 0xb1, 0x50, 0x9e, 0x61, 0xc2, 0x42, 0x79, 0x86, 0x05, 0x0b,
|
||||
0xe5, 0x19, 0x1a, 0xee, 0x28, 0x30, 0x28, 0xd9, 0x72, 0xf1, 0xc2, 0x74, 0x86, 0x25, 0xe6, 0x94,
|
||||
0xa6, 0x92, 0xa6, 0xdd, 0xc9, 0xeb, 0xc4, 0x43, 0x39, 0x86, 0x0b, 0x0f, 0xe5, 0x18, 0x6e, 0x3c,
|
||||
0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x37,
|
||||
0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0x43, 0x94, 0x0a, 0x31, 0x21,
|
||||
0x05, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x70, 0x98, 0xa3, 0x69, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
41
vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
generated
vendored
41
vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
generated
vendored
@ -22,7 +22,7 @@ syntax = "proto2";
|
||||
package k8s.io.apimachinery.pkg.api.resource;
|
||||
|
||||
// Package-wide variables from generator "generated".
|
||||
option go_package = "resource";
|
||||
option go_package = "k8s.io/apimachinery/pkg/api/resource";
|
||||
|
||||
// Quantity is a fixed-point representation of a number.
|
||||
// It provides convenient marshaling/unmarshaling in JSON and YAML,
|
||||
@ -30,8 +30,11 @@ option go_package = "resource";
|
||||
//
|
||||
// The serialization format is:
|
||||
//
|
||||
// ```
|
||||
// <quantity> ::= <signedNumber><suffix>
|
||||
// (Note that <suffix> may be empty, from the "" case in <decimalSI>.)
|
||||
//
|
||||
// (Note that <suffix> may be empty, from the "" case in <decimalSI>.)
|
||||
//
|
||||
// <digit> ::= 0 | 1 | ... | 9
|
||||
// <digits> ::= <digit> | <digit><digits>
|
||||
// <number> ::= <digits> | <digits>.<digits> | <digits>. | .<digits>
|
||||
@ -39,10 +42,15 @@ option go_package = "resource";
|
||||
// <signedNumber> ::= <number> | <sign><number>
|
||||
// <suffix> ::= <binarySI> | <decimalExponent> | <decimalSI>
|
||||
// <binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei
|
||||
// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)
|
||||
//
|
||||
// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)
|
||||
//
|
||||
// <decimalSI> ::= m | "" | k | M | G | T | P | E
|
||||
// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)
|
||||
//
|
||||
// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)
|
||||
//
|
||||
// <decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber>
|
||||
// ```
|
||||
//
|
||||
// No matter which of the three exponent forms is used, no quantity may represent
|
||||
// a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal
|
||||
@ -56,14 +64,17 @@ option go_package = "resource";
|
||||
// Before serializing, Quantity will be put in "canonical form".
|
||||
// This means that Exponent/suffix will be adjusted up or down (with a
|
||||
// corresponding increase or decrease in Mantissa) such that:
|
||||
// a. No precision is lost
|
||||
// b. No fractional digits will be emitted
|
||||
// c. The exponent (or suffix) is as large as possible.
|
||||
//
|
||||
// - No precision is lost
|
||||
// - No fractional digits will be emitted
|
||||
// - The exponent (or suffix) is as large as possible.
|
||||
//
|
||||
// The sign will be omitted unless the number is negative.
|
||||
//
|
||||
// Examples:
|
||||
// 1.5 will be serialized as "1500m"
|
||||
// 1.5Gi will be serialized as "1536Mi"
|
||||
//
|
||||
// - 1.5 will be serialized as "1500m"
|
||||
// - 1.5Gi will be serialized as "1536Mi"
|
||||
//
|
||||
// Note that the quantity will NEVER be internally represented by a
|
||||
// floating point number. That is the whole point of this exercise.
|
||||
@ -86,3 +97,15 @@ message Quantity {
|
||||
optional string string = 1;
|
||||
}
|
||||
|
||||
// QuantityValue makes it possible to use a Quantity as value for a command
|
||||
// line parameter.
|
||||
//
|
||||
// +protobuf=true
|
||||
// +protobuf.embed=string
|
||||
// +protobuf.options.marshal=false
|
||||
// +protobuf.options.(gogoproto.goproto_stringer)=false
|
||||
// +k8s:deepcopy-gen=true
|
||||
message QuantityValue {
|
||||
optional string string = 1;
|
||||
}
|
||||
|
||||
|
80
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
80
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
@ -34,8 +34,11 @@ import (
|
||||
//
|
||||
// The serialization format is:
|
||||
//
|
||||
// ```
|
||||
// <quantity> ::= <signedNumber><suffix>
|
||||
// (Note that <suffix> may be empty, from the "" case in <decimalSI>.)
|
||||
//
|
||||
// (Note that <suffix> may be empty, from the "" case in <decimalSI>.)
|
||||
//
|
||||
// <digit> ::= 0 | 1 | ... | 9
|
||||
// <digits> ::= <digit> | <digit><digits>
|
||||
// <number> ::= <digits> | <digits>.<digits> | <digits>. | .<digits>
|
||||
@ -43,10 +46,15 @@ import (
|
||||
// <signedNumber> ::= <number> | <sign><number>
|
||||
// <suffix> ::= <binarySI> | <decimalExponent> | <decimalSI>
|
||||
// <binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei
|
||||
// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)
|
||||
//
|
||||
// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)
|
||||
//
|
||||
// <decimalSI> ::= m | "" | k | M | G | T | P | E
|
||||
// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)
|
||||
//
|
||||
// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)
|
||||
//
|
||||
// <decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber>
|
||||
// ```
|
||||
//
|
||||
// No matter which of the three exponent forms is used, no quantity may represent
|
||||
// a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal
|
||||
@ -60,14 +68,17 @@ import (
|
||||
// Before serializing, Quantity will be put in "canonical form".
|
||||
// This means that Exponent/suffix will be adjusted up or down (with a
|
||||
// corresponding increase or decrease in Mantissa) such that:
|
||||
// a. No precision is lost
|
||||
// b. No fractional digits will be emitted
|
||||
// c. The exponent (or suffix) is as large as possible.
|
||||
//
|
||||
// - No precision is lost
|
||||
// - No fractional digits will be emitted
|
||||
// - The exponent (or suffix) is as large as possible.
|
||||
//
|
||||
// The sign will be omitted unless the number is negative.
|
||||
//
|
||||
// Examples:
|
||||
// 1.5 will be serialized as "1500m"
|
||||
// 1.5Gi will be serialized as "1536Mi"
|
||||
//
|
||||
// - 1.5 will be serialized as "1500m"
|
||||
// - 1.5Gi will be serialized as "1536Mi"
|
||||
//
|
||||
// Note that the quantity will NEVER be internally represented by a
|
||||
// floating point number. That is the whole point of this exercise.
|
||||
@ -397,13 +408,17 @@ func (_ Quantity) OpenAPISchemaType() []string { return []string{"string"} }
|
||||
// the OpenAPI spec of this type.
|
||||
func (_ Quantity) OpenAPISchemaFormat() string { return "" }
|
||||
|
||||
// OpenAPIV3OneOfTypes is used by the kube-openapi generator when constructing
|
||||
// the OpenAPI v3 spec of this type.
|
||||
func (Quantity) OpenAPIV3OneOfTypes() []string { return []string{"string", "number"} }
|
||||
|
||||
// CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity).
|
||||
//
|
||||
// Note about BinarySI:
|
||||
// * If q.Format is set to BinarySI and q.Amount represents a non-zero value between
|
||||
// -1 and +1, it will be emitted as if q.Format were DecimalSI.
|
||||
// * Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be
|
||||
// rounded up. (1.1i becomes 2i.)
|
||||
// - If q.Format is set to BinarySI and q.Amount represents a non-zero value between
|
||||
// -1 and +1, it will be emitted as if q.Format were DecimalSI.
|
||||
// - Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be
|
||||
// rounded up. (1.1i becomes 2i.)
|
||||
func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) {
|
||||
if q.IsZero() {
|
||||
return zeroBytes, nil
|
||||
@ -460,17 +475,7 @@ func (q *Quantity) AsApproximateFloat64() float64 {
|
||||
return base
|
||||
}
|
||||
|
||||
// multiply by the appropriate exponential scale
|
||||
switch q.Format {
|
||||
case DecimalExponent, DecimalSI:
|
||||
return base * math.Pow10(exponent)
|
||||
default:
|
||||
// fast path for exponents that can fit in 64 bits
|
||||
if exponent > 0 && exponent < 7 {
|
||||
return base * float64(int64(1)<<(exponent*10))
|
||||
}
|
||||
return base * math.Pow(2, float64(exponent*10))
|
||||
}
|
||||
return base * math.Pow10(exponent)
|
||||
}
|
||||
|
||||
// AsInt64 returns a representation of the current value as an int64 if a fast conversion
|
||||
@ -649,7 +654,7 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
|
||||
copy(out[1:], q.s)
|
||||
return out, nil
|
||||
}
|
||||
result := make([]byte, int64QuantityExpectedBytes, int64QuantityExpectedBytes)
|
||||
result := make([]byte, int64QuantityExpectedBytes)
|
||||
result[0] = '"'
|
||||
number, suffix := q.CanonicalizeBytes(result[1:1])
|
||||
// if the same slice was returned to us that we passed in, avoid another allocation by copying number into
|
||||
@ -774,3 +779,30 @@ func (q *Quantity) SetScaled(value int64, scale Scale) {
|
||||
q.d.Dec = nil
|
||||
q.i = int64Amount{value: value, scale: scale}
|
||||
}
|
||||
|
||||
// QuantityValue makes it possible to use a Quantity as value for a command
|
||||
// line parameter.
|
||||
//
|
||||
// +protobuf=true
|
||||
// +protobuf.embed=string
|
||||
// +protobuf.options.marshal=false
|
||||
// +protobuf.options.(gogoproto.goproto_stringer)=false
|
||||
// +k8s:deepcopy-gen=true
|
||||
type QuantityValue struct {
|
||||
Quantity
|
||||
}
|
||||
|
||||
// Set implements pflag.Value.Set and Go flag.Value.Set.
|
||||
func (q *QuantityValue) Set(s string) error {
|
||||
quantity, err := ParseQuantity(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
q.Quantity = quantity
|
||||
return nil
|
||||
}
|
||||
|
||||
// Type implements pflag.Value.Type.
|
||||
func (q QuantityValue) Type() string {
|
||||
return "quantity"
|
||||
}
|
||||
|
2
vendor/k8s.io/apimachinery/pkg/api/resource/suffix.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/api/resource/suffix.go
generated
vendored
@ -165,7 +165,7 @@ func (sh *suffixHandler) constructBytes(base, exponent int32, format Format) (s
|
||||
if exponent == 0 {
|
||||
return nil, true
|
||||
}
|
||||
result := make([]byte, 8, 8)
|
||||
result := make([]byte, 8)
|
||||
result[0] = 'e'
|
||||
number := strconv.AppendInt(result[1:1], int64(exponent), 10)
|
||||
if &result[1] == &number[0] {
|
||||
|
18
vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go
generated
vendored
18
vendor/k8s.io/apimachinery/pkg/api/resource/zz_generated.deepcopy.go
generated
vendored
@ -1,3 +1,4 @@
|
||||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
@ -25,3 +26,20 @@ func (in *Quantity) DeepCopyInto(out *Quantity) {
|
||||
*out = in.DeepCopy()
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *QuantityValue) DeepCopyInto(out *QuantityValue) {
|
||||
*out = *in
|
||||
out.Quantity = in.Quantity.DeepCopy()
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QuantityValue.
|
||||
func (in *QuantityValue) DeepCopy() *QuantityValue {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(QuantityValue)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
Reference in New Issue
Block a user