Documentation
¶
Index ¶
- Constants
- func ConfigAsTransport(options *Config) *http.Transport
- func ConfigAuthAsProxy(options *Config) func(*http.Request) (*url.URL, error)
- func NewBasicAuth(username, password string) func(req *http.Request) error
- func NewHTTPSigner(basepath string) func(req *http.Request) error
- func NewProxyTransport(server *url.URL, tp http.RoundTripper) http.RoundTripper
- func NewRestDecoder(r io.ReadCloser, newitemfunc func() client.Object) *restDecoder
- func NewReverseProxy(addr *url.URL, tp http.RoundTripper) *httputil.ReverseProxy
- func NewTokenAuth(token string) func(req *http.Request) error
- func TLSClientConfig(ca []byte) *tls.Config
- func TLSConfigFrom(ca, cert, key []byte) (*tls.Config, error)
- type Auth
- type Config
- type StatusTypedClient
- type TypedClient
- func (c TypedClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (c TypedClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (c TypedClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (c TypedClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
- func (c TypedClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (c TypedClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (c TypedClient) RESTMapper() meta.RESTMapper
- func (c TypedClient) Scheme() *runtime.Scheme
- func (c TypedClient) Status() client.StatusWriter
- func (c TypedClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- func (c TypedClient) Watch(ctx context.Context, obj client.ObjectList, opts ...client.ListOption) (watch.Interface, error)
- type WebsocketClient
Constants ¶
const (
DefaultWebSocketHandshakeTimeout = 45 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func ConfigAsTransport ¶
func ConfigAuthAsProxy ¶
func NewProxyTransport ¶
func NewProxyTransport(server *url.URL, tp http.RoundTripper) http.RoundTripper
NewProxyTransport return a transport that handle requests like it happens in the agent pod.
func NewRestDecoder ¶
func NewRestDecoder(r io.ReadCloser, newitemfunc func() client.Object) *restDecoder
func NewReverseProxy ¶
func NewReverseProxy(addr *url.URL, tp http.RoundTripper) *httputil.ReverseProxy
NewReverseProxy return a reverse proxy that proxy requests to the agent.
func TLSClientConfig ¶ added in v1.24.1
Types ¶
type StatusTypedClient ¶
type StatusTypedClient struct {
// contains filtered or unexported fields
}
func (*StatusTypedClient) Patch ¶
func (c *StatusTypedClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
func (*StatusTypedClient) Update ¶
func (c *StatusTypedClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
type TypedClient ¶
type TypedClient struct { BaseAddr *url.URL RuntimeScheme *runtime.Scheme HTTPClient *http.Client // contains filtered or unexported fields }
func NewTypedClient ¶
func NewTypedClient(addr *url.URL, tp http.RoundTripper, scheme *runtime.Scheme) *TypedClient
func (TypedClient) Create ¶
func (c TypedClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
Create saves the object obj in the Kubernetes cluster.
func (TypedClient) Delete ¶
func (c TypedClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
Delete deletes the given obj from Kubernetes cluster.
func (TypedClient) DeleteAllOf ¶
func (c TypedClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf deletes all objects of the given type matching the given options.
func (TypedClient) Get ¶
Get retrieves an obj for the given object key from the Kubernetes Cluster. obj must be a struct pointer so that obj can be updated with the response returned by the Server.
func (TypedClient) List ¶
func (c TypedClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List retrieves list of objects for a given namespace and list options. On a successful call, Items field in the list will be populated with the result returned from the server.
func (TypedClient) Patch ¶
func (c TypedClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
Patch patches the given obj in the Kubernetes cluster. obj must be a struct pointer so that obj can be updated with the content returned by the Server.
func (TypedClient) RESTMapper ¶
func (c TypedClient) RESTMapper() meta.RESTMapper
func (TypedClient) Scheme ¶
func (c TypedClient) Scheme() *runtime.Scheme
func (TypedClient) Status ¶
func (c TypedClient) Status() client.StatusWriter
func (TypedClient) Update ¶
func (c TypedClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
Update updates the given obj in the Kubernetes cluster. obj must be a struct pointer so that obj can be updated with the content returned by the Server.
func (TypedClient) Watch ¶
func (c TypedClient) Watch(ctx context.Context, obj client.ObjectList, opts ...client.ListOption) (watch.Interface, error)
不知道如何正确使用 watch.Interface,参考k8s源码:
https://github.com/kubernetes/kubernetes/blob/release-1.20/pkg/volume/csi/csi_attacher.go#L444-L487
或者:
watcher, err := cli.Watch(ctx, objctList) if err != nil { return fmt.Errorf("watch error:%v", err) } defer watcher.Stop() for { select { case event, ok := <-watcher.ResultChan(): if !ok { log.Warningf("watch channel had been closed") break } switch event.Type { case watch.Added, watch.Modified: ... case watch.Deleted: ... case watch.Error: log.Warningf("received watch error: %v", event) } case <-ctx.Done(): log.Warningf("watch channel closed") break } }
type WebsocketClient ¶
func NewWebsocketClient ¶
func NewWebsocketClient(options *Config) *WebsocketClient