util

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientComponentFrom

func ClientComponentFrom(ctx context.Context) (string, bool)

ClientComponentFrom returns the value of the client component key on the ctx

func CreateKubeConfigFile added in v0.3.0

func CreateKubeConfigFile(kubeClientConfig *rest.Config, kubeconfigPath string) error

func Err

func Err(err error, w http.ResponseWriter, req *http.Request)

Err write err to response writer

func FileExists

func FileExists(filename string) (bool, error)

FileExists checks if specified file exists.

func IsSupportedCertMode

func IsSupportedCertMode(certMode string) bool

IsSupportedCertMode check cert mode is supported or not

func IsSupportedLBMode

func IsSupportedLBMode(lbMode string) bool

IsSupportedLBMode check lb mode is supported or not

func KeyFunc

func KeyFunc(comp, resource, ns, name string) (string, error)

KeyFunc combine comp resource ns name into a key

func LoadKubeConfig added in v0.3.0

func LoadKubeConfig(kubeconfig string) (*clientcmdapi.Config, error)

func LoadKubeletRestClientConfig

func LoadKubeletRestClientConfig(healthyServer *url.URL) (*rest.Config, error)

LoadKubeletRestClientConfig load *rest.Config for accessing healthyServer

func LoadRESTClientConfig added in v0.3.0

func LoadRESTClientConfig(kubeconfig string) (*rest.Config, error)

func NewDualReadCloser

func NewDualReadCloser(rc io.ReadCloser, isRespBody bool) (io.ReadCloser, io.ReadCloser)

NewDualReadCloser create an dualReadCloser object

func ReqCanCacheFrom

func ReqCanCacheFrom(ctx context.Context) (bool, bool)

ReqCanCacheFrom returns the value of the request can cache key on the ctx

func ReqContentTypeFrom

func ReqContentTypeFrom(ctx context.Context) (string, bool)

ReqContentTypeFrom returns the value of the request content type key on the ctx

func ReqInfoString

func ReqInfoString(info *apirequest.RequestInfo) string

ReqInfoString formats a string for request info

func ReqString

func ReqString(req *http.Request) string

ReqString formats a string for request

func RespContentTypeFrom

func RespContentTypeFrom(ctx context.Context) (string, bool)

RespContentTypeFrom returns the value of the response content type key on the ctx

func SplitKey

func SplitKey(key string) (comp, resource, ns, name string)

SplitKey split key into comp, resource, ns, name

func WithClientComponent

func WithClientComponent(parent context.Context, component string) context.Context

WithClientComponent returns a copy of parent in which the client component value is set

func WithReqCanCache

func WithReqCanCache(parent context.Context, canCache bool) context.Context

WithReqCanCache returns a copy of parent in which the request can cache value is set

func WithReqContentType

func WithReqContentType(parent context.Context, contentType string) context.Context

WithReqContentType returns a copy of parent in which the response content type value is set

func WithRespContentType

func WithRespContentType(parent context.Context, contentType string) context.Context

WithRespContentType returns a copy of parent in which the request content type value is set

func WithValue

func WithValue(parent context.Context, key interface{}, val interface{}) context.Context

WithValue returns a copy of parent in which the value associated with key is val.

func WriteObject

func WriteObject(statusCode int, obj runtime.Object, w http.ResponseWriter, req *http.Request)

WriteObject write object to response writer

Types

type DialFunc

type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)

DialFunc is a shorthand for signature of net.DialContext.

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer opens connections through Dial and tracks them.

func NewDialer

func NewDialer(name string) *Dialer

NewDialer creates a new Dialer instance.

If dial is not nil, it will be used to create new underlying connections. Otherwise net.DialContext is used.

func (*Dialer) Close

func (d *Dialer) Close(address string)

Close forcibly closes all tracked connections that specified by address.

Note: new connections may get created before Close returns.

func (*Dialer) CloseAll

func (d *Dialer) CloseAll()

CloseAll forcibly closes all tracked connections.

Note: new connections may get created before CloseAll returns.

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial creates a new tracked connection.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext creates a new tracked connection.

func (*Dialer) Name

func (d *Dialer) Name() string

Name returns the name of dialer

type ProxyKeyType

type ProxyKeyType int

ProxyKeyType represents the key in proxy request context

const (
	// ProxyReqContentType represents request content type context key
	ProxyReqContentType ProxyKeyType = iota
	// ProxyRespContentType represents response content type context key
	ProxyRespContentType
	// ProxyClientComponent represents client component context key
	ProxyClientComponent
	// ProxyReqCanCache represents request can cache context key
	ProxyReqCanCache
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL