bucket_services

package
v0.0.0-...-f4b31ea Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var DefaultPageSize = 10

Functions

This section is empty.

Types

type BucketConnector

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

BucketConnector is an object for connecting the GCS bucket storage.

func (*BucketConnector) GetBuilds

func (b *BucketConnector) GetBuilds(ctx context.Context, board string, milestone int32) ([]string, error)

GetBuilds returns all build versions from the bucket by given board and milestone.

string board the board name we want to use as a filter. string milestone the milestone we want to use as a filter.

func (*BucketConnector) GetMilestones

func (b *BucketConnector) GetMilestones(ctx context.Context, board string) ([]string, error)

GetMilestones returns all milestones from the bucket by given board.

string board the board name we want to use as a filter.

func (*BucketConnector) GetTestPlan

GetTestPlan get the test plan's content from the given filename.

func (*BucketConnector) IsBucketInAsia

func (b *BucketConnector) IsBucketInAsia(ctx context.Context) (bool, error)

IsBucketInAsia returns boolean. Check the given bucket is in asia.

func (*BucketConnector) ListTestplans

func (b *BucketConnector) ListTestplans(ctx context.Context) ([]string, error)

ListTestplans list all testplan json in partner bucket under a `testplans` folder

func (*BucketConnector) UploadLog

func (b *BucketConnector) UploadLog(ctx context.Context, gsFilename, localFilePath string) (string, error)

UploadLog upload the log from the local to bucket.

type IBucketClient

type IBucketClient interface {
	// GetAttrs get the bucket attributes
	GetAttrs(ctx context.Context) (*storage.BucketAttrs, error)

	// QueryObjects query objects from the bucket
	QueryObjects(ctx context.Context, q *storage.Query) iObjectIterator

	// ReadObject read the object content by the given name
	ReadObject(ctx context.Context, name string) (io.ReadCloser, error)

	// WriteObject writes a object to the bucket
	WriteObject(ctx context.Context, name string) io.WriteCloser

	// GetBucketName get the current bucket name
	GetBucketName() string

	// Close clean up
	Close() error
}

type IBucketServices

type IBucketServices interface {
	// IsBucketInAsia returns boolean. Check the given bucket is in asia.
	IsBucketInAsia(ctx context.Context) (bool, error)

	// GetMilestones returns all milestones from the bucket by given board.
	GetMilestones(ctx context.Context, board string) ([]string, error)

	// GetBuilds returns all build versions from the bucket by given board and milestone.
	GetBuilds(ctx context.Context, board string, milestone int32) ([]string, error)

	// ListTestplans list all testplan json in partner bucket under a `testplans` folder
	ListTestplans(ctx context.Context) ([]string, error)

	// GetTestPlan get the test plan's content from the given filename.
	GetTestPlan(context.Context, string) (*test_platform.Request_TestPlan, error)

	// UploadLog upload the log to bucket.
	UploadLog(context.Context, string, string) (string, error)
}

IBucketServices is the interface that provide the services It should not contain any `Business Logic` here, because it is to mock the interface for testing.

func New

func New(ctx context.Context, bucketName string) (IBucketServices, error)

New sets up the storage client and returns a BucketConnector. The service account is set in the global environment.

string bucketName config which bucket we want to connect with in later functions.

type MockBucketServices

type MockBucketServices struct {
	mock.Mock
}

MockBucketServices This object is only for testing

Object should provide the same functions that `IBucketServices` interfaces provide. TODO: I will write a generator for the interface later to generate this file

func (*MockBucketServices) GetBuilds

func (m *MockBucketServices) GetBuilds(ctx context.Context, board string, milestone int32) ([]string, error)

GetBuilds Mock the function instead of calling an API.

func (*MockBucketServices) GetMilestones

func (m *MockBucketServices) GetMilestones(ctx context.Context, board string) ([]string, error)

GetMilestones Mock the function instead of calling an API.

func (*MockBucketServices) GetTestPlan

GetTestPlan get the test plan's content from the given filename.

func (*MockBucketServices) IsBucketInAsia

func (m *MockBucketServices) IsBucketInAsia(ctx context.Context) (bool, error)

IsBucketInAsia Mock the function instead of calling an API.

func (*MockBucketServices) ListTestplans

func (m *MockBucketServices) ListTestplans(ctx context.Context) ([]string, error)

ListTestplans list all testplan json in partner bucket under a `testplans` folder

func (*MockBucketServices) UploadLog

func (m *MockBucketServices) UploadLog(ctx context.Context, name, path string) (string, error)

Jump to

Keyboard shortcuts

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