qiniu

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ArtifactsDirName is the name of directory defined in prow to store test artifacts
	ArtifactsDirName = "artifacts"

	//PostSubmitCoverProfile represents the default output coverage file generated in prow environment
	PostSubmitCoverProfile = "filtered.cov"

	//ChangedProfileName represents the default changed coverage profile based on files changed in Pull Request
	ChangedProfileName = "changed-file-profile.cov"
)

Variables

This section is empty.

Functions

func FindBaseProfileFromQiniu

func FindBaseProfileFromQiniu(qc Client, prowJobName, covProfileName string) ([]byte, error)

FindBaseProfileFromQiniu finds the coverage profile file from the latest healthy build stored in given gcs directory

func MockPrivateDomainUrl added in v1.2.2

func MockPrivateDomainUrl(router *httprouter.Router, count int)

MockPrivateDomainUrl mocks bucket domain /key, /timeout, /retry API. count controls the mocks qiniu server to error before 'count' times request.

func MockRouterAPI

func MockRouterAPI(router *httprouter.Router, profile string, count int)

MockRouterAPI mocks qiniu /v2/list API. You need to provide a expected profile content. count controls the mocks qiniu server to error before 'count' times request.

func MockRouterListAllAPI added in v1.2.2

func MockRouterListAllAPI(router *httprouter.Router, count int)

MockRouterListAllAPI mocks qiniu /list API. count controls the mocks qiniu server to error before 'count' times request.

Types

type Artifacts

type Artifacts interface {
	ProfilePath() string
	CreateChangedProfile() *os.File
	GetChangedProfileName() string
}

Artifacts is the interface of the rule to store test artifacts in prow

type Client

type Client interface {
	QiniuObjectHandle(key string) ObjectHandle
	ReadObject(key string) ([]byte, error)
	ListAll(ctx context.Context, prefix string, delimiter string) ([]string, error)
	GetAccessURL(key string, timeout time.Duration) string
	GetArtifactDetails(key string) (*LogHistoryTemplate, error)
	ListSubDirs(prefix string) ([]string, error)
}

Client is the interface contains the operation with qiniu cloud

type Config

type Config struct {
	Bucket    string `json:"bucket"`
	AccessKey string `json:"accessKey"`
	SecretKey string `json:"secretKey"`

	// domain used to download files from qiniu cloud
	Domain string `json:"domain"`
}

Config store the credentials to connect with qiniu cloud

type LogHistoryTemplate

type LogHistoryTemplate struct {
	BucketName string
	KeyPath    string
	Items      []logHistoryItem
}

LogHistoryTemplate is the template of the log history

type ObjectHandle

type ObjectHandle interface {
	NewReader(ctx context.Context) (io.ReadCloser, error)
	NewRangeReader(ctx context.Context, offset, length int64) (io.ReadCloser, error)
}

ObjectHandle is the interface contains the operations on an object in a qiniu cloud bucket

type ProfileArtifacts added in v1.2.2

type ProfileArtifacts struct {
	Directory          string
	ProfileName        string
	ChangedProfileName string // create temporary to save changed file related coverage profile
}

ProfileArtifacts presents the rule to store test artifacts in prow

func (*ProfileArtifacts) CreateChangedProfile added in v1.2.2

func (a *ProfileArtifacts) CreateChangedProfile() *os.File

CreateChangedProfile creates a profile in order to store the most related files based on Github Pull Request

func (*ProfileArtifacts) GetChangedProfileName added in v1.2.2

func (a *ProfileArtifacts) GetChangedProfileName() string

GetChangedProfileName get ChangedProfileName of the ProfileArtifacts

func (*ProfileArtifacts) ProfilePath added in v1.2.2

func (a *ProfileArtifacts) ProfilePath() string

ProfilePath returns a full path for profile

type QnClient added in v1.2.2

type QnClient struct {
	BucketManager *storage.BucketManager
	// contains filtered or unexported fields
}

QnClient for the operation with qiniu cloud

func MockQiniuServer

func MockQiniuServer(config *Config) (client *QnClient, router *httprouter.Router, serverURL string, teardown func())

MockQiniuServer simulate qiniu cloud for testing

func NewClient

func NewClient(cfg *Config) *QnClient

NewClient creates a new QnClient to work with qiniu cloud

func (*QnClient) GetAccessURL added in v1.2.2

func (q *QnClient) GetAccessURL(key string, timeout time.Duration) string

GetAccessURL return a url which can access artifact directly in qiniu

func (*QnClient) GetArtifactDetails added in v1.2.2

func (q *QnClient) GetArtifactDetails(key string) (*LogHistoryTemplate, error)

GetArtifactDetails lists all artifacts available for the given job source

func (*QnClient) ListAll added in v1.2.2

func (q *QnClient) ListAll(ctx context.Context, prefix string, delimiter string) ([]string, error)

ListAll to list all the files with contains the expected prefix

func (*QnClient) ListSubDirs added in v1.2.2

func (q *QnClient) ListSubDirs(prefix string) ([]string, error)

ListSubDirs list all the sub directions of the prefix string in qiniu client

func (*QnClient) QiniuObjectHandle added in v1.2.2

func (q *QnClient) QiniuObjectHandle(key string) ObjectHandle

QiniuObjectHandle construct a object hanle to access file in qiniu

func (*QnClient) ReadObject added in v1.2.2

func (q *QnClient) ReadObject(key string) ([]byte, error)

ReadObject to read all the content of key

type QnObjectHandle added in v1.2.2

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

QnObjectHandle provides operations on an object in a qiniu cloud bucket

func (*QnObjectHandle) NewRangeReader added in v1.2.2

func (o *QnObjectHandle) NewRangeReader(ctx context.Context, offset, length int64) (io.ReadCloser, error)

NewRangeReader reads parts of an object, reading at most length bytes starting from the given offset. If length is negative, the object is read until the end.

func (*QnObjectHandle) NewReader added in v1.2.2

func (o *QnObjectHandle) NewReader(ctx context.Context) (io.ReadCloser, error)

NewReader creates a reader to read the contents of the object. ErrObjectNotExist will be returned if the object is not found. The caller must call Close on the returned Reader when done reading.

Jump to

Keyboard shortcuts

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