Upgrade k8s package verison (#5358)

* upgrade k8s package version

Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>

* Script upgrade and code formatting.

Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>

Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
hongzhouzi
2022-11-15 14:56:38 +08:00
committed by GitHub
parent 5f91c1663a
commit 44167aa47a
3106 changed files with 321340 additions and 172080 deletions

View File

@@ -25,8 +25,8 @@ import (
)
const (
kubectlCommandHeader = "X-Kubectl-Command"
kubectlSessionHeader = "X-Kubectl-Session"
kubectlCommandHeader = "Kubectl-Command"
kubectlSessionHeader = "Kubectl-Session"
)
// CommandHeaderRoundTripper adds a layer around the standard
@@ -40,7 +40,8 @@ type CommandHeaderRoundTripper struct {
// CommandHeaderRoundTripper adds Request headers before delegating to standard
// round tripper. These headers are kubectl command headers which
// detail the kubectl command. See SIG CLI KEP 859:
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers
//
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers
func (c *CommandHeaderRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
for header, value := range c.Headers {
req.Header.Set(header, value)
@@ -48,9 +49,11 @@ func (c *CommandHeaderRoundTripper) RoundTrip(req *http.Request) (*http.Response
return c.Delegate.RoundTrip(req)
}
// ParseCommandHeaders fills in a map of X-Headers into the CommandHeaderRoundTripper. These
// headers are then filled into each request. For details on X-Headers see:
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers
// ParseCommandHeaders fills in a map of custom headers into the CommandHeaderRoundTripper. These
// headers are then filled into each request. For details on the custom headers see:
//
// https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers
//
// Each call overwrites the previously parsed command headers (not additive).
// TODO(seans3): Parse/add flags removing PII from flag values.
func (c *CommandHeaderRoundTripper) ParseCommandHeaders(cmd *cobra.Command, args []string) {
@@ -77,3 +80,15 @@ func (c *CommandHeaderRoundTripper) ParseCommandHeaders(cmd *cobra.Command, args
c.Headers[kubectlCommandHeader] = strings.Join(cmdStrs, " ")
}
}
// CancelRequest is propagated to the Delegate RoundTripper within
// if the wrapped RoundTripper implements this function.
func (c *CommandHeaderRoundTripper) CancelRequest(req *http.Request) {
type canceler interface {
CancelRequest(*http.Request)
}
// If possible, call "CancelRequest" on the wrapped Delegate RoundTripper.
if cr, ok := c.Delegate.(canceler); ok {
cr.CancelRequest(req)
}
}