client

package
v0.9.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: AGPL-3.0 Imports: 26 Imported by: 1

Documentation

Overview

Package client is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var NotImplemented = errors.New("NotImplemented")

Functions

func GetMapKeyFromRequest

func GetMapKeyFromRequest(req *http.Request) string

func SetMockClient

func SetMockClient(cli Client, err error)

func UnsetMockClient

func UnsetMockClient()

Types

type Client

type Client interface {
	// GetRole return the replication role(like primary/secondary) of the target replica
	GetRole(ctx context.Context) (string, error)

	// user management funcs
	CreateUser(ctx context.Context, userName, password, roleName string) error
	DeleteUser(ctx context.Context, userName string) error
	DescribeUser(ctx context.Context, userName string) (map[string]any, error)
	GrantUserRole(ctx context.Context, userName, roleName string) error
	RevokeUserRole(ctx context.Context, userName, roleName string) error
	ListUsers(ctx context.Context) ([]map[string]any, error)
	ListSystemAccounts(ctx context.Context) ([]map[string]any, error)

	// JoinMember sends a join member operation request to Lorry, located on the target pod that is about to join.
	JoinMember(ctx context.Context) error

	// LeaveMember sends a Leave member operation request to Lorry, located on the target pod that is about to leave.
	LeaveMember(ctx context.Context) error

	Switchover(ctx context.Context, primary, candidate string, force bool) error
}

func GetMockClient

func GetMockClient() Client

func NewClient

func NewClient(pod corev1.Pod) (Client, error)

type HTTPClient

type HTTPClient struct {
	Client *http.Client
	URL    string

	CacheTTL         time.Duration
	ReconcileTimeout time.Duration
	RequestTimeout   time.Duration
	// contains filtered or unexported fields
}

func NewHTTPClientWithPod

func NewHTTPClientWithPod(pod *corev1.Pod) (*HTTPClient, error)

func NewHTTPClientWithURL

func NewHTTPClientWithURL(url string) (*HTTPClient, error)

func (*HTTPClient) CreateUser

func (cli *HTTPClient) CreateUser(ctx context.Context, userName, password, roleName string) error

func (*HTTPClient) DeleteUser

func (cli *HTTPClient) DeleteUser(ctx context.Context, userName string) error

func (*HTTPClient) DescribeUser

func (cli *HTTPClient) DescribeUser(ctx context.Context, userName string) (map[string]any, error)

func (*HTTPClient) GetRole

func (cli *HTTPClient) GetRole(ctx context.Context) (string, error)

func (*HTTPClient) GrantUserRole

func (cli *HTTPClient) GrantUserRole(ctx context.Context, userName, roleName string) error

func (*HTTPClient) InvokeComponent

func (cli *HTTPClient) InvokeComponent(ctxWithReconcileTimeout context.Context, url, method string, body io.Reader, ch chan *OperationResult)

func (*HTTPClient) InvokeComponentInRoutine

func (cli *HTTPClient) InvokeComponentInRoutine(ctxWithReconcileTimeout context.Context, url, method string, body io.Reader) (*http.Response, error)

func (*HTTPClient) JoinMember

func (cli *HTTPClient) JoinMember(ctx context.Context) error

JoinMember sends a join member operation request to Lorry, located on the target pod that is about to join.

func (*HTTPClient) LeaveMember

func (cli *HTTPClient) LeaveMember(ctx context.Context) error

LeaveMember sends a Leave member operation request to Lorry, located on the target pod that is about to leave.

func (*HTTPClient) ListSystemAccounts

func (cli *HTTPClient) ListSystemAccounts(ctx context.Context) ([]map[string]any, error)

ListSystemAccounts lists all system accounts created

func (*HTTPClient) ListUsers

func (cli *HTTPClient) ListUsers(ctx context.Context) ([]map[string]any, error)

ListUsers lists all normal users created

func (*HTTPClient) Request

func (cli *HTTPClient) Request(ctx context.Context, operation, method string, req map[string]any) (map[string]any, error)

func (*HTTPClient) RevokeUserRole

func (cli *HTTPClient) RevokeUserRole(ctx context.Context, userName, roleName string) error

func (*HTTPClient) Switchover

func (cli *HTTPClient) Switchover(ctx context.Context, primary, candidate string, force bool) error

type K8sExecClient

type K8sExecClient struct {
	cmdexec.StreamOptions
	Executor cmdexec.RemoteExecutor

	RequestTimeout time.Duration
	// contains filtered or unexported fields
}

K8sExecClient is a mock client for operation, mainly used to hide curl command details.

func NewK8sExecClientWithPod

func NewK8sExecClientWithPod(restConfig *rest.Config, pod *corev1.Pod) (*K8sExecClient, error)

NewK8sExecClientWithPod create a new OperationHTTPClient with lorry container

func (*K8sExecClient) CreateUser

func (cli *K8sExecClient) CreateUser(ctx context.Context, userName, password, roleName string) error

func (*K8sExecClient) DeleteUser

func (cli *K8sExecClient) DeleteUser(ctx context.Context, userName string) error

func (*K8sExecClient) DescribeUser

func (cli *K8sExecClient) DescribeUser(ctx context.Context, userName string) (map[string]any, error)

func (*K8sExecClient) GetRole

func (cli *K8sExecClient) GetRole(ctx context.Context) (string, error)

func (*K8sExecClient) GrantUserRole

func (cli *K8sExecClient) GrantUserRole(ctx context.Context, userName, roleName string) error

func (*K8sExecClient) JoinMember

func (cli *K8sExecClient) JoinMember(ctx context.Context) error

JoinMember sends a join member operation request to Lorry, located on the target pod that is about to join.

func (*K8sExecClient) LeaveMember

func (cli *K8sExecClient) LeaveMember(ctx context.Context) error

LeaveMember sends a Leave member operation request to Lorry, located on the target pod that is about to leave.

func (*K8sExecClient) ListSystemAccounts

func (cli *K8sExecClient) ListSystemAccounts(ctx context.Context) ([]map[string]any, error)

ListSystemAccounts lists all system accounts created

func (*K8sExecClient) ListUsers

func (cli *K8sExecClient) ListUsers(ctx context.Context) ([]map[string]any, error)

ListUsers lists all normal users created

func (*K8sExecClient) Request

func (cli *K8sExecClient) Request(ctx context.Context, operation, method string, req map[string]any) (map[string]any, error)

Request execs lorry operation, this is a blocking operation and use pod EXEC subresource to send a http request to the lorry pod

func (*K8sExecClient) RevokeUserRole

func (cli *K8sExecClient) RevokeUserRole(ctx context.Context, userName, roleName string) error

func (*K8sExecClient) Switchover

func (cli *K8sExecClient) Switchover(ctx context.Context, primary, candidate string, force bool) error

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) CreateUser

func (m *MockClient) CreateUser(arg0 context.Context, arg1, arg2, arg3 string) error

CreateUser mocks base method.

func (*MockClient) DeleteUser

func (m *MockClient) DeleteUser(arg0 context.Context, arg1 string) error

DeleteUser mocks base method.

func (*MockClient) DescribeUser

func (m *MockClient) DescribeUser(arg0 context.Context, arg1 string) (map[string]interface{}, error)

DescribeUser mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) GetRole

func (m *MockClient) GetRole(arg0 context.Context) (string, error)

GetRole mocks base method.

func (*MockClient) GrantUserRole

func (m *MockClient) GrantUserRole(arg0 context.Context, arg1, arg2 string) error

GrantUserRole mocks base method.

func (*MockClient) JoinMember

func (m *MockClient) JoinMember(arg0 context.Context) error

JoinMember mocks base method.

func (*MockClient) LeaveMember

func (m *MockClient) LeaveMember(arg0 context.Context) error

LeaveMember mocks base method.

func (*MockClient) ListSystemAccounts

func (m *MockClient) ListSystemAccounts(arg0 context.Context) ([]map[string]interface{}, error)

ListSystemAccounts mocks base method.

func (*MockClient) ListUsers

func (m *MockClient) ListUsers(arg0 context.Context) ([]map[string]interface{}, error)

ListUsers mocks base method.

func (*MockClient) RevokeUserRole

func (m *MockClient) RevokeUserRole(arg0 context.Context, arg1, arg2 string) error

RevokeUserRole mocks base method.

func (*MockClient) Switchover

func (m *MockClient) Switchover(arg0 context.Context, arg1, arg2 string, arg3 bool) error

Switchover mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) CreateUser

func (mr *MockClientMockRecorder) CreateUser(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

CreateUser indicates an expected call of CreateUser.

func (*MockClientMockRecorder) DeleteUser

func (mr *MockClientMockRecorder) DeleteUser(arg0, arg1 interface{}) *gomock.Call

DeleteUser indicates an expected call of DeleteUser.

func (*MockClientMockRecorder) DescribeUser

func (mr *MockClientMockRecorder) DescribeUser(arg0, arg1 interface{}) *gomock.Call

DescribeUser indicates an expected call of DescribeUser.

func (*MockClientMockRecorder) GetRole

func (mr *MockClientMockRecorder) GetRole(arg0 interface{}) *gomock.Call

GetRole indicates an expected call of GetRole.

func (*MockClientMockRecorder) GrantUserRole

func (mr *MockClientMockRecorder) GrantUserRole(arg0, arg1, arg2 interface{}) *gomock.Call

GrantUserRole indicates an expected call of GrantUserRole.

func (*MockClientMockRecorder) JoinMember

func (mr *MockClientMockRecorder) JoinMember(arg0 interface{}) *gomock.Call

JoinMember indicates an expected call of JoinMember.

func (*MockClientMockRecorder) LeaveMember

func (mr *MockClientMockRecorder) LeaveMember(arg0 interface{}) *gomock.Call

LeaveMember indicates an expected call of LeaveMember.

func (*MockClientMockRecorder) ListSystemAccounts

func (mr *MockClientMockRecorder) ListSystemAccounts(arg0 interface{}) *gomock.Call

ListSystemAccounts indicates an expected call of ListSystemAccounts.

func (*MockClientMockRecorder) ListUsers

func (mr *MockClientMockRecorder) ListUsers(arg0 interface{}) *gomock.Call

ListUsers indicates an expected call of ListUsers.

func (*MockClientMockRecorder) RevokeUserRole

func (mr *MockClientMockRecorder) RevokeUserRole(arg0, arg1, arg2 interface{}) *gomock.Call

RevokeUserRole indicates an expected call of RevokeUserRole.

func (*MockClientMockRecorder) Switchover

func (mr *MockClientMockRecorder) Switchover(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Switchover indicates an expected call of Switchover.

type OperationResult

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

type Requester

type Requester interface {
	Request(ctx context.Context, operation, method string, req map[string]any) (map[string]any, error)
}

Jump to

Keyboard shortcuts

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