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:
27
vendor/k8s.io/cli-runtime/pkg/genericclioptions/command_headers.go
generated
vendored
27
vendor/k8s.io/cli-runtime/pkg/genericclioptions/command_headers.go
generated
vendored
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user