Documentation ¶
Overview ¶
Package clients contains wrappers for client side bindings for APIs used by Buildbucket. These interfaces also provide mocks for API calls in tests.
Index ¶
- Variables
- func CreateRawPrpcClient(ctx context.Context, host, project string) (client *prpc.Client, err error)
- func GetBackendHost(target string, globalCfg *pb.SettingsCfg) (hostname string, err error)
- func IsTaskBackendLite(target string, globalCfg *pb.SettingsCfg) (bool, error)
- func NewPubsubClient(ctx context.Context, cloudProject, luciProject string) (*pubsub.Client, error)
- func SetupTestPubsub(ctx context.Context, cloudProject string) (context.Context, *pstest.Server, *pubsub.Client, error)
- func ValidatePubSubTopicName(topic string) (string, string, error)
- func WithBqClient(ctx context.Context, client BqClient) context.Context
- type BackendClient
- func (c *BackendClient) CancelTasks(ctx context.Context, in *pb.CancelTasksRequest, opts ...grpc.CallOption) (*pb.CancelTasksResponse, error)
- func (c *BackendClient) FetchTasks(ctx context.Context, in *pb.FetchTasksRequest, opts ...grpc.CallOption) (*pb.FetchTasksResponse, error)
- func (c *BackendClient) RunTask(ctx context.Context, in *pb.RunTaskRequest, opts ...grpc.CallOption) (*pb.RunTaskResponse, error)
- func (c *BackendClient) ValidateConfigs(ctx context.Context, in *pb.ValidateConfigsRequest, opts ...grpc.CallOption) (*pb.ValidateConfigsResponse, error)
- type BqClient
- type MockSwarmingClient
- func (m *MockSwarmingClient) CancelTask(ctx context.Context, req *apipb.TaskCancelRequest) (*apipb.CancelResponse, error)
- func (m *MockSwarmingClient) CreateTask(ctx context.Context, createTaskReq *apipb.NewTaskRequest) (*apipb.TaskRequestMetadataResponse, error)
- func (m *MockSwarmingClient) EXPECT() *MockSwarmingClientMockRecorder
- func (m *MockSwarmingClient) GetTaskResult(ctx context.Context, taskID string) (*apipb.TaskResultResponse, error)
- type MockSwarmingClientMockRecorder
- type MockTaskBackendClient
- func (m *MockTaskBackendClient) CancelTasks(ctx context.Context, in *buildbucketpb.CancelTasksRequest, ...) (*buildbucketpb.CancelTasksResponse, error)
- func (m *MockTaskBackendClient) EXPECT() *MockTaskBackendClientMockRecorder
- func (m *MockTaskBackendClient) FetchTasks(ctx context.Context, in *buildbucketpb.FetchTasksRequest, ...) (*buildbucketpb.FetchTasksResponse, error)
- func (m *MockTaskBackendClient) RunTask(ctx context.Context, in *buildbucketpb.RunTaskRequest, opts ...grpc.CallOption) (*buildbucketpb.RunTaskResponse, error)
- func (m *MockTaskBackendClient) ValidateConfigs(ctx context.Context, in *buildbucketpb.ValidateConfigsRequest, ...) (*buildbucketpb.ValidateConfigsResponse, error)
- type MockTaskBackendClientMockRecorder
- func (mr *MockTaskBackendClientMockRecorder) CancelTasks(ctx, in interface{}, opts ...interface{}) *gomock.Call
- func (mr *MockTaskBackendClientMockRecorder) FetchTasks(ctx, in interface{}, opts ...interface{}) *gomock.Call
- func (mr *MockTaskBackendClientMockRecorder) RunTask(ctx, in interface{}, opts ...interface{}) *gomock.Call
- func (mr *MockTaskBackendClientMockRecorder) ValidateConfigs(ctx, in interface{}, opts ...interface{}) *gomock.Call
- type MockTaskCreator
- type MockTaskCreatorMockRecorder
- type SwarmingClient
- type TaskBackendClient
- type TaskCreator
- type TaskCreatorClient
Constants ¶
This section is empty.
Variables ¶
var ErrTaskBackendLite = errors.New("cannot create a TaskBackend client for a TaskBackendLite server")
var MockSwarmingClientKey = "used in tests only for setting the mock SwarmingClient"
var MockTaskBackendClientKey = contextKey("used in tests only for setting the mock SwarmingClient")
var MockTaskCreatorKey = contextKey("used in tests only for setting the mock TaskCreator")
Functions ¶
func CreateRawPrpcClient ¶
func CreateRawPrpcClient(ctx context.Context, host, project string) (client *prpc.Client, err error)
CreateRawPrpcClient creates a raw PRPC client for use with the specified host. Buildbucket will invoke the client's service with a Project-scoped identity.
func GetBackendHost ¶
func GetBackendHost(target string, globalCfg *pb.SettingsCfg) (hostname string, err error)
GetBackendHost returns the backend's hostname from service config.
func IsTaskBackendLite ¶
func IsTaskBackendLite(target string, globalCfg *pb.SettingsCfg) (bool, error)
IsTaskBackendLite returns whether the backend is a TaskBackendLite.
func NewPubsubClient ¶
NewPubsubClient creates a pubsub client with the authority of a given luciProject or the current service if luciProject is empty.
func SetupTestPubsub ¶
func SetupTestPubsub(ctx context.Context, cloudProject string) (context.Context, *pstest.Server, *pubsub.Client, error)
SetupTestPubsub creates a new fake Pub/Sub server and the client connection to the server. It also adds the client into the context.
func ValidatePubSubTopicName ¶
ValidatePubSubTopicName validates the format of topic, extract the cloud project and topic id, and return them.
Types ¶
type BackendClient ¶
type BackendClient struct {
// contains filtered or unexported fields
}
BackendClient is the client to communicate with TaskBackend. It wraps a pb.TaskBackendClient.
func NewBackendClient ¶
func NewBackendClient(ctx context.Context, project, target string, globalCfg *pb.SettingsCfg) (*BackendClient, error)
NewBackendClient creates a client to communicate with a full-featured TaskBackend server.
func (*BackendClient) CancelTasks ¶
func (c *BackendClient) CancelTasks(ctx context.Context, in *pb.CancelTasksRequest, opts ...grpc.CallOption) (*pb.CancelTasksResponse, error)
CancelTasks sends a cancel request to the backend
func (*BackendClient) FetchTasks ¶
func (c *BackendClient) FetchTasks(ctx context.Context, in *pb.FetchTasksRequest, opts ...grpc.CallOption) (*pb.FetchTasksResponse, error)
FetchTasks returns the requested tasks.
func (*BackendClient) RunTask ¶
func (c *BackendClient) RunTask(ctx context.Context, in *pb.RunTaskRequest, opts ...grpc.CallOption) (*pb.RunTaskResponse, error)
RunTask returns for the requested task.
func (*BackendClient) ValidateConfigs ¶
func (c *BackendClient) ValidateConfigs(ctx context.Context, in *pb.ValidateConfigsRequest, opts ...grpc.CallOption) (*pb.ValidateConfigsResponse, error)
ValidateConfigs returns validation errors (if any).
type BqClient ¶
type BqClient interface { // Insert a row into a BigQuery table Insert(ctx context.Context, dataset string, table string, row *lucibq.Row) error }
func GetBqClient ¶
GetBqClient returns the bigquery Client installed in the current context. Panics if there isn't one.
type MockSwarmingClient ¶
type MockSwarmingClient struct {
// contains filtered or unexported fields
}
MockSwarmingClient is a mock of SwarmingClient interface.
func NewMockSwarmingClient ¶
func NewMockSwarmingClient(ctrl *gomock.Controller) *MockSwarmingClient
NewMockSwarmingClient creates a new mock instance.
func (*MockSwarmingClient) CancelTask ¶
func (m *MockSwarmingClient) CancelTask(ctx context.Context, req *apipb.TaskCancelRequest) (*apipb.CancelResponse, error)
CancelTask mocks base method.
func (*MockSwarmingClient) CreateTask ¶
func (m *MockSwarmingClient) CreateTask(ctx context.Context, createTaskReq *apipb.NewTaskRequest) (*apipb.TaskRequestMetadataResponse, error)
CreateTask mocks base method.
func (*MockSwarmingClient) EXPECT ¶
func (m *MockSwarmingClient) EXPECT() *MockSwarmingClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSwarmingClient) GetTaskResult ¶
func (m *MockSwarmingClient) GetTaskResult(ctx context.Context, taskID string) (*apipb.TaskResultResponse, error)
GetTaskResult mocks base method.
type MockSwarmingClientMockRecorder ¶
type MockSwarmingClientMockRecorder struct {
// contains filtered or unexported fields
}
MockSwarmingClientMockRecorder is the mock recorder for MockSwarmingClient.
func (*MockSwarmingClientMockRecorder) CancelTask ¶
func (mr *MockSwarmingClientMockRecorder) CancelTask(ctx, req interface{}) *gomock.Call
CancelTask indicates an expected call of CancelTask.
func (*MockSwarmingClientMockRecorder) CreateTask ¶
func (mr *MockSwarmingClientMockRecorder) CreateTask(ctx, createTaskReq interface{}) *gomock.Call
CreateTask indicates an expected call of CreateTask.
func (*MockSwarmingClientMockRecorder) GetTaskResult ¶
func (mr *MockSwarmingClientMockRecorder) GetTaskResult(ctx, taskID interface{}) *gomock.Call
GetTaskResult indicates an expected call of GetTaskResult.
type MockTaskBackendClient ¶
type MockTaskBackendClient struct {
// contains filtered or unexported fields
}
MockTaskBackendClient is a mock of TaskBackendClient interface.
func NewMockTaskBackendClient ¶
func NewMockTaskBackendClient(ctrl *gomock.Controller) *MockTaskBackendClient
NewMockTaskBackendClient creates a new mock instance.
func (*MockTaskBackendClient) CancelTasks ¶
func (m *MockTaskBackendClient) CancelTasks(ctx context.Context, in *buildbucketpb.CancelTasksRequest, opts ...grpc.CallOption) (*buildbucketpb.CancelTasksResponse, error)
CancelTasks mocks base method.
func (*MockTaskBackendClient) EXPECT ¶
func (m *MockTaskBackendClient) EXPECT() *MockTaskBackendClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskBackendClient) FetchTasks ¶
func (m *MockTaskBackendClient) FetchTasks(ctx context.Context, in *buildbucketpb.FetchTasksRequest, opts ...grpc.CallOption) (*buildbucketpb.FetchTasksResponse, error)
FetchTasks mocks base method.
func (*MockTaskBackendClient) RunTask ¶
func (m *MockTaskBackendClient) RunTask(ctx context.Context, in *buildbucketpb.RunTaskRequest, opts ...grpc.CallOption) (*buildbucketpb.RunTaskResponse, error)
RunTask mocks base method.
func (*MockTaskBackendClient) ValidateConfigs ¶
func (m *MockTaskBackendClient) ValidateConfigs(ctx context.Context, in *buildbucketpb.ValidateConfigsRequest, opts ...grpc.CallOption) (*buildbucketpb.ValidateConfigsResponse, error)
ValidateConfigs mocks base method.
type MockTaskBackendClientMockRecorder ¶
type MockTaskBackendClientMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskBackendClientMockRecorder is the mock recorder for MockTaskBackendClient.
func (*MockTaskBackendClientMockRecorder) CancelTasks ¶
func (mr *MockTaskBackendClientMockRecorder) CancelTasks(ctx, in interface{}, opts ...interface{}) *gomock.Call
CancelTasks indicates an expected call of CancelTasks.
func (*MockTaskBackendClientMockRecorder) FetchTasks ¶
func (mr *MockTaskBackendClientMockRecorder) FetchTasks(ctx, in interface{}, opts ...interface{}) *gomock.Call
FetchTasks indicates an expected call of FetchTasks.
func (*MockTaskBackendClientMockRecorder) RunTask ¶
func (mr *MockTaskBackendClientMockRecorder) RunTask(ctx, in interface{}, opts ...interface{}) *gomock.Call
RunTask indicates an expected call of RunTask.
func (*MockTaskBackendClientMockRecorder) ValidateConfigs ¶
func (mr *MockTaskBackendClientMockRecorder) ValidateConfigs(ctx, in interface{}, opts ...interface{}) *gomock.Call
ValidateConfigs indicates an expected call of ValidateConfigs.
type MockTaskCreator ¶
type MockTaskCreator struct {
// contains filtered or unexported fields
}
MockTaskCreator is a mock of TaskCreator interface.
func NewMockTaskCreator ¶
func NewMockTaskCreator(ctrl *gomock.Controller) *MockTaskCreator
NewMockTaskCreator creates a new mock instance.
func (*MockTaskCreator) EXPECT ¶
func (m *MockTaskCreator) EXPECT() *MockTaskCreatorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskCreator) RunTask ¶
func (m *MockTaskCreator) RunTask(ctx context.Context, in *buildbucketpb.RunTaskRequest, opts ...grpc.CallOption) (*buildbucketpb.RunTaskResponse, error)
RunTask mocks base method.
type MockTaskCreatorMockRecorder ¶
type MockTaskCreatorMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskCreatorMockRecorder is the mock recorder for MockTaskCreator.
func (*MockTaskCreatorMockRecorder) RunTask ¶
func (mr *MockTaskCreatorMockRecorder) RunTask(ctx, in interface{}, opts ...interface{}) *gomock.Call
RunTask indicates an expected call of RunTask.
type SwarmingClient ¶
type SwarmingClient interface { CreateTask(ctx context.Context, createTaskReq *apipb.NewTaskRequest) (*apipb.TaskRequestMetadataResponse, error) GetTaskResult(ctx context.Context, taskID string) (*apipb.TaskResultResponse, error) CancelTask(ctx context.Context, req *apipb.TaskCancelRequest) (*apipb.CancelResponse, error) }
SwarmingClient is a Swarming API wrapper for buildbucket-specific usage.
In prod, a SwarmingClient for interacting with the Swarming service will be used. Tests should use a fake implementation.
func NewSwarmingClient ¶
NewSwarmingClient returns a new SwarmingClient to interact with Swarming APIs.
type TaskBackendClient ¶
type TaskBackendClient interface { CancelTasks(ctx context.Context, in *pb.CancelTasksRequest, opts ...grpc.CallOption) (*pb.CancelTasksResponse, error) RunTask(ctx context.Context, in *pb.RunTaskRequest, opts ...grpc.CallOption) (*pb.RunTaskResponse, error) FetchTasks(ctx context.Context, in *pb.FetchTasksRequest, opts ...grpc.CallOption) (*pb.FetchTasksResponse, error) ValidateConfigs(ctx context.Context, in *pb.ValidateConfigsRequest, opts ...grpc.CallOption) (*pb.ValidateConfigsResponse, error) }
TaskBackendClient represents a full-featured TaskBackend.
type TaskCreator ¶
type TaskCreator interface {
RunTask(ctx context.Context, in *pb.RunTaskRequest, opts ...grpc.CallOption) (*pb.RunTaskResponse, error)
}
TaskCreator is the abstraction for TaskBackend or TaskBackendLite services which expose the RunTask API.
func NewTaskCreator ¶
func NewTaskCreator(ctx context.Context, project, target string, globalCfg *pb.SettingsCfg, isLite bool) (TaskCreator, error)
NewTaskCreator creates a client to communicate with the backend which implements RunTask API.
type TaskCreatorClient ¶
type TaskCreatorClient struct {
// contains filtered or unexported fields
}
TaskCreatorClient is the implementation of TaskCreator and will be used in real Prod env.
func (*TaskCreatorClient) RunTask ¶
func (c *TaskCreatorClient) RunTask(ctx context.Context, in *pb.RunTaskRequest, opts ...grpc.CallOption) (*pb.RunTaskResponse, error)
RunTask returns for the requested task.