clients

package
v0.0.0-...-e7509a3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package clients contains all clients or client wrappers used by Luci-config.

Index

Constants

This section is empty.

Variables

View Source
var MockGitilesClientKey = "mock gitiles clients key for testing only"

Functions

func NewGitilesClient

func NewGitilesClient(ctx context.Context, host, luciProject string) (gitilespb.GitilesClient, error)

NewGitilesClient returns a Gitiles client with the authority of the given luciProject or the current service if luciProject is empty.

func WithGsClient

func WithGsClient(ctx context.Context, client GsClient) context.Context

WithGsClient returns a new context with the given GsClient.

Types

type GsClient

type GsClient interface {
	// UploadIfMissing upload data with attrs to the bucket-to-object path if it
	// does not exist. Return true, if the upload operation is made this time.
	UploadIfMissing(ctx context.Context, bucket, object string, data []byte, attrsModifyFn func(*storage.ObjectAttrs)) (bool, error)
	// Read reads data from the give bucket-to-object path.
	// If decompressive is true, it will read with decompressive transcoding:
	// https://cloud.google.com/storage/docs/transcoding#decompressive_transcoding
	Read(ctx context.Context, bucket, object string, decompressive bool) ([]byte, error)
	// Touch updates the custom time of the object to the current timestamp.
	//
	// Returns storage.ErrObjectNotExist if object is not found.
	Touch(ctx context.Context, bucket, object string) error
	// SignedURL is used to generate a signed url for a given GCS object.
	SignedURL(bucket, object string, opts *storage.SignedURLOptions) (string, error)
	// Delete deletes the give object.
	Delete(ctx context.Context, bucket, object string) error
}

GsClient is an interface for interacting with Cloud Storage.

func GetGsClient

func GetGsClient(ctx context.Context) GsClient

GetGsClient returns the GsClient installed in the current context.

func NewGsProdClient

func NewGsProdClient(ctx context.Context) (GsClient, error)

NewGsProdClient create a prodClient.

type MockGsClient

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

MockGsClient is a mock of GsClient interface.

func NewMockGsClient

func NewMockGsClient(ctrl *gomock.Controller) *MockGsClient

NewMockGsClient creates a new mock instance.

func (*MockGsClient) Delete

func (m *MockGsClient) Delete(ctx context.Context, bucket, object string) error

Delete mocks base method.

func (*MockGsClient) EXPECT

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

func (*MockGsClient) Read

func (m *MockGsClient) Read(ctx context.Context, bucket, object string, decompressive bool) ([]byte, error)

Read mocks base method.

func (*MockGsClient) SignedURL

func (m *MockGsClient) SignedURL(bucket, object string, opts *storage.SignedURLOptions) (string, error)

SignedURL mocks base method.

func (*MockGsClient) Touch

func (m *MockGsClient) Touch(ctx context.Context, bucket, object string) error

Touch mocks base method.

func (*MockGsClient) UploadIfMissing

func (m *MockGsClient) UploadIfMissing(ctx context.Context, bucket, object string, data []byte, attrsModifyFn func(*storage.ObjectAttrs)) (bool, error)

UploadIfMissing mocks base method.

type MockGsClientMockRecorder

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

MockGsClientMockRecorder is the mock recorder for MockGsClient.

func (*MockGsClientMockRecorder) Delete

func (mr *MockGsClientMockRecorder) Delete(ctx, bucket, object interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockGsClientMockRecorder) Read

func (mr *MockGsClientMockRecorder) Read(ctx, bucket, object, decompressive interface{}) *gomock.Call

Read indicates an expected call of Read.

func (*MockGsClientMockRecorder) SignedURL

func (mr *MockGsClientMockRecorder) SignedURL(bucket, object, opts interface{}) *gomock.Call

SignedURL indicates an expected call of SignedURL.

func (*MockGsClientMockRecorder) Touch

func (mr *MockGsClientMockRecorder) Touch(ctx, bucket, object interface{}) *gomock.Call

Touch indicates an expected call of Touch.

func (*MockGsClientMockRecorder) UploadIfMissing

func (mr *MockGsClientMockRecorder) UploadIfMissing(ctx, bucket, object, data, attrsModifyFn interface{}) *gomock.Call

UploadIfMissing indicates an expected call of UploadIfMissing.

Jump to

Keyboard shortcuts

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