Documentation
¶
Index ¶
- Variables
- func KubeconfigNamespace(kubeconfigPath, contextName string) (string, error)
- func NewRESTConfig(flags ...*pflag.FlagSet) (*rest.Config, error)
- func NewRuntimeClient(config *rest.Config, schemeFuncs ...func(s *apiruntime.Scheme) error) (ctrlrtclient.Client, error)
- func ValidateHTTPSIdentity(rawURL string, caData []byte) error
- type Client
- func (c *Client) Copy() *Client
- func (c *Client) HTTPDo(req *http.Request) (*http.Response, error)
- func (c *Client) NewPersistentHTTPClient() (*PersistentHTTPClient, error)
- func (c *Client) NewPersistentHTTPClientForOrigin(rawURL string) (*PersistentHTTPClient, error)
- func (c *Client) NewPersistentHTTPSClientForOrigin(rawURL string) (*PersistentHTTPClient, error)
- func (c *Client) NewRTClient(schemeFuncs ...func(s *apiruntime.Scheme) error) (ctrlrtclient.Client, error)
- func (c *Client) RESTConfig() *rest.Config
- func (c *Client) SetNetworkTimeouts(timeouts NetworkTimeouts) error
- func (c *Client) SetProbeEndpoint(timeout time.Duration, targetHost, kubeServiceServerName string)
- func (c *Client) SetQPS(qps float32, burst int)
- func (c *Client) SetRequestTimeout(timeout time.Duration)
- func (c *Client) SetResponseHeaderTimeout(timeout time.Duration)
- func (c *Client) SetTLSCAData(caData []byte)
- func (c *Client) SetTLSIdentityCAData(caData []byte) error
- type NetworkTimeouts
- type PersistentHTTPClient
- type RESTConfigLoader
Constants ¶
This section is empty.
Variables ¶
var ErrResponseBodyLimitExceeded = errors.New("response body limit exceeded")
ErrResponseBodyLimitExceeded identifies a response body that exceeded its configured finite control-response byte budget.
Functions ¶
func KubeconfigNamespace ¶
KubeconfigNamespace resolves the namespace selected by the given kubeconfig path and context, mirroring kubectl: it returns the context's namespace, or "default" when the context does not pin one. It uses the same loading rules as utilk8s.SetupK8sClientSet so flag handling stays consistent across commands.
func NewRESTConfig ¶
NewRESTConfig parses Kubernetes client flags once and returns the command-scoped configuration from which every snapshot control-plane and data-plane client is derived.
func NewRuntimeClient ¶
func NewRuntimeClient( config *rest.Config, schemeFuncs ...func(s *apiruntime.Scheme) error, ) (ctrlrtclient.Client, error)
NewRuntimeClient builds a controller-runtime client from the same tuned REST configuration used by the command's other Kubernetes clients.
func ValidateHTTPSIdentity ¶
ValidateHTTPSIdentity requires an HTTPS origin and a strictly parseable, non-empty PEM certificate bundle suitable for endpoint-specific trust.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client owns snapshot-specific authenticated HTTP transport configuration.
func NewClientForConfig ¶
NewClientForConfig derives a data-plane client from the command-scoped REST configuration without parsing kubeconfig a second time.
func (*Client) NewPersistentHTTPClient ¶
func (c *Client) NewPersistentHTTPClient() (*PersistentHTTPClient, error)
NewPersistentHTTPClient materializes the current rest.Config exactly once, retaining client-go's TLS, proxy, dial, certificate, exec, auth-provider, bearer, and basic-auth behavior for every request made through the result.
The standard client-go base *http.Transport is cloned before caller-installed WrapTransport functions run. Its inherited HTTP/2 upgrade closures are suppressed while those wrappers clone and customize the transport, then HTTP/2 is configured anew on the final private transport. Cleanup retains both the pre-auth wrapper stack and the private base transport.
func (*Client) NewPersistentHTTPClientForOrigin ¶
func (c *Client) NewPersistentHTTPClientForOrigin(rawURL string) (*PersistentHTTPClient, error)
NewPersistentHTTPClientForOrigin materializes a persistent client whose credential-bearing transport can only send to rawURL's HTTP origin. Direct cross-origin requests and cross-origin redirects are rejected before the auth wrappers see them; same-origin redirects retain the standard ten-hop limit.
func (*Client) NewPersistentHTTPSClientForOrigin ¶
func (c *Client) NewPersistentHTTPSClientForOrigin(rawURL string) (*PersistentHTTPClient, error)
NewPersistentHTTPSClientForOrigin materializes an origin-bound client for a credential-bearing HTTPS endpoint. Plaintext origins are rejected before the authenticated transport stack is built.
func (*Client) NewRTClient ¶
func (c *Client) NewRTClient(schemeFuncs ...func(s *apiruntime.Scheme) error) (ctrlrtclient.Client, error)
NewRTClient builds a controller-runtime client from this client's REST configuration. New command code should prefer NewRuntimeClient with its command-scoped configuration.
func (*Client) RESTConfig ¶
RESTConfig returns a deep copy of the underlying *rest.Config so callers (e.g. the aggregated-API client) can build their own discovery REST client without mutating or depending on the Client's auth handling.
func (*Client) SetNetworkTimeouts ¶
func (c *Client) SetNetworkTimeouts(timeouts NetworkTimeouts) error
SetNetworkTimeouts installs finite connection, TLS-handshake, response-header, request-write-idle, response-read-idle, and finite total response bounds on persistent HTTP clients. WriteIdle and ReadIdle reset after every successful body read, while ResponseTotal and ResponseBytes independently bound control responses even when a peer continuously trickles bytes.
func (*Client) SetProbeEndpoint ¶
SetProbeEndpoint configures host, TLS ServerName and timeout for probe requests.
func (*Client) SetQPS ¶
SetQPS raises the underlying rest.Config's client-side rate limiter above client-go's built-in defaults (QPS=5, Burst=10). Callers with many concurrent short-lived requests against the SAME client (e.g. several DataExport Get/Create/Delete lifecycles racing to completion) opt into this explicitly; Client's own default is unchanged for every other caller of NewClient that never calls it.
func (*Client) SetRequestTimeout ¶
SetRequestTimeout sets the rest.Config total timeout used by short control-plane requests. Streaming callers can clear it on a copied Client before building a progress-aware persistent client.
func (*Client) SetResponseHeaderTimeout ¶
SetResponseHeaderTimeout makes this client abort a request whose server accepts the TCP connection but does not send response headers within timeout, so a wedged endpoint that never answers fails fast instead of blocking a caller indefinitely (rest.HTTPClientFor builds its transport with restConfig.Timeout = 0, i.e. no response-header timeout by default).
It is strictly opt-in and mutates only THIS client's rest.Config: it chains onto any existing WrapTransport (e.g. the one SetTLSCAData installs) rather than replacing it, and a Client that never calls it keeps its previous behavior (WrapTransport unchanged). The timeout is applied to the transport that rest.HTTPClientFor builds for the credential-bearing branches of HTTPDo.
func (*Client) SetTLSCAData ¶
func (*Client) SetTLSIdentityCAData ¶
SetTLSIdentityCAData replaces inherited server trust with the supplied endpoint-specific certificate bundle. Client credentials, proxy, dial, and transport wrappers remain intact, but inherited insecure verification, ServerName overrides, system roots, and cluster roots cannot bypass this CA.
type NetworkTimeouts ¶
type NetworkTimeouts struct {
Connect time.Duration
TLSHandshake time.Duration
ResponseHeader time.Duration
WriteIdle time.Duration
ReadIdle time.Duration
ResponseTotal time.Duration
ResponseBytes int64
}
NetworkTimeouts bounds silent stalls in each HTTP transport phase without imposing one total duration on a request whose body keeps making progress.
type PersistentHTTPClient ¶
type PersistentHTTPClient struct {
// contains filtered or unexported fields
}
PersistentHTTPClient owns one materialized client-go HTTP transport stack. It is safe for concurrent use. Call CloseIdleConnections when the caller's lifecycle ends so this client's private connection pool is released.
func (*PersistentHTTPClient) CloseIdleConnections ¶
func (c *PersistentHTTPClient) CloseIdleConnections()
CloseIdleConnections stops new requests, waits for owned request bodies to quiesce, and closes this client's privately owned connection pool.