...

Package clientpool

import "github.com/chaos-mesh/chaos-mesh/pkg/clientpool"
Overview
Index

Overview ▾

func ExtractTokenAndGetAuthClient

func ExtractTokenAndGetAuthClient(header http.Header) (authorizationv1.AuthorizationV1Interface, error)

ExtractTokenAndGetAuthClient extracts token from http header, and get the authority client of this token

func ExtractTokenAndGetClient

func ExtractTokenAndGetClient(header http.Header) (pkgclient.Client, error)

ExtractTokenAndGetClient extracts token from http header, and get the k8s client of this token

func ExtractTokenFromHeader

func ExtractTokenFromHeader(header http.Header) string

ExtractTokenFromHeader extracts token from http header

type Clients

type Clients interface {
    Client(token string) (pkgclient.Client, error)
    AuthClient(token string) (authorizationv1.AuthorizationV1Interface, error)
    Num() int
    Contains(token string) bool
}

K8sClients is an object of Clients

var K8sClients Clients

func NewClientPool

func NewClientPool(localConfig *rest.Config, scheme *runtime.Scheme, maxClientNum int) (Clients, error)

New creates a new Clients

func NewLocalClient

func NewLocalClient(localConfig *rest.Config, scheme *runtime.Scheme) (Clients, error)

type ClientsPool

Clients is the client pool of k8s client

type ClientsPool struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func (*ClientsPool) AuthClient

func (c *ClientsPool) AuthClient(token string) (authorizationv1.AuthorizationV1Interface, error)

func (*ClientsPool) Client

func (c *ClientsPool) Client(token string) (pkgclient.Client, error)

Client returns a k8s client according to the token

func (*ClientsPool) Contains

func (c *ClientsPool) Contains(token string) bool

Contains return true if have client for the token

func (*ClientsPool) Num

func (c *ClientsPool) Num() int

Num returns the num of clients

type LocalClient

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

func (*LocalClient) AuthClient

func (c *LocalClient) AuthClient(token string) (authorizationv1.AuthorizationV1Interface, error)

func (*LocalClient) Client

func (c *LocalClient) Client(token string) (pkgclient.Client, error)

Client returns the local k8s client

func (*LocalClient) Contains

func (c *LocalClient) Contains(token string) bool

Contains return false for LocalClient

func (*LocalClient) Num

func (c *LocalClient) Num() int

Num returns the num of clients