client

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 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, statement 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, memberName string) error

	Switchover(ctx context.Context, primary, candidate string, force bool) error
	Lock(ctx context.Context) error
	Unlock(ctx context.Context) error
	PostProvision(ctx context.Context, componentNames, podNames, podIPs, podHostNames, podHostIPs string) error
	PreTerminate(ctx context.Context) error

	// local rebuild slave
	Rebuild(ctx context.Context) error
	DataDump(ctx context.Context) error
	DataLoad(ctx context.Context) 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, statement string) error

func (*HTTPClient) DataDump added in v0.9.0

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

func (*HTTPClient) DataLoad added in v0.9.0

func (cli *HTTPClient) DataLoad(ctx context.Context) 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, memberName string) 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) Lock added in v0.8.2

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

Lock sends a set readonly request to Lorry.

func (*HTTPClient) PostProvision added in v0.8.2

func (cli *HTTPClient) PostProvision(ctx context.Context, componentNames, podNames, podIPs, podHostNames, podHostIPs string) error

PostProvision sends a component post provision request to Lorry.

func (*HTTPClient) PreTerminate added in v0.8.2

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

PreTerminate sends a pre terminate request to Lorry.

func (*HTTPClient) Rebuild added in v0.9.0

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

Rebuild sends a slave rebuild request to Lorry.

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

func (*HTTPClient) Unlock added in v0.8.2

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

Unlock sends a set readwrite request to Lorry.

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, statement string) error

func (*K8sExecClient) DataDump added in v0.9.0

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

func (*K8sExecClient) DataLoad added in v0.9.0

func (cli *K8sExecClient) DataLoad(ctx context.Context) 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, memberName string) 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) Lock added in v0.8.2

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

Lock sends a set readonly request to Lorry.

func (*K8sExecClient) PostProvision added in v0.8.2

func (cli *K8sExecClient) PostProvision(ctx context.Context, componentNames, podNames, podIPs, podHostNames, podHostIPs string) error

PostProvision sends a component post provision request to Lorry.

func (*K8sExecClient) PreTerminate added in v0.8.2

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

PreTerminate sends a pre terminate request to Lorry.

func (*K8sExecClient) Rebuild added in v0.9.0

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

Rebuild sends a slave rebuild request to Lorry.

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

func (*K8sExecClient) Unlock added in v0.8.2

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

Unlock sends a set readwrite request to Lorry.

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, arg4 string) error

CreateUser mocks base method.

func (*MockClient) DataDump added in v0.9.0

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

DataDump mocks base method.

func (*MockClient) DataLoad added in v0.9.0

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

DataLoad 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, arg1 string) 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) Lock added in v0.8.2

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

Lock mocks base method.

func (*MockClient) PostProvision added in v0.8.2

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

PostProvision mocks base method.

func (*MockClient) PreTerminate added in v0.8.2

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

PreTerminate mocks base method.

func (*MockClient) Rebuild added in v0.9.0

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

Rebuild 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.

func (*MockClient) Unlock added in v0.8.2

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

Unlock 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, arg4 interface{}) *gomock.Call

CreateUser indicates an expected call of CreateUser.

func (*MockClientMockRecorder) DataDump added in v0.9.0

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

DataDump indicates an expected call of DataDump.

func (*MockClientMockRecorder) DataLoad added in v0.9.0

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

DataLoad indicates an expected call of DataLoad.

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, arg1 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) Lock added in v0.8.2

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

Lock indicates an expected call of Lock.

func (*MockClientMockRecorder) PostProvision added in v0.8.2

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

PostProvision indicates an expected call of PostProvision.

func (*MockClientMockRecorder) PreTerminate added in v0.8.2

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

PreTerminate indicates an expected call of PreTerminate.

func (*MockClientMockRecorder) Rebuild added in v0.9.0

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

Rebuild indicates an expected call of Rebuild.

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.

func (*MockClientMockRecorder) Unlock added in v0.8.2

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

Unlock indicates an expected call of Unlock.

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