dbclient

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package dbclient defines operations about database

Index

Constants

View Source
const (
	PageNo         = "pageNo"
	PageSize       = "pageSize"
	ExtraEndpoint  = "extra_cs_endpoint"
	ExtraAccessKey = "extra_cs_ak"
	ExtraSecretKey = "extra_cs_sk"
	ExtraBucket    = "extra_cs_bucket"

	HTTP = "HTTP"
)
View Source
const BULK_INSERT_CHUNK_SIZE = 3000
View Source
const DistinctAssetIDFromAccess = `` /* 191-byte string literal not displayed */
View Source
const SelectFoundRows = `
SELECT FOUND_ROWS()
`

Variables

This section is empty.

Functions

func CheckVersionConflict

func CheckVersionConflict(orgID uint64, assetID string, major, minor, patch uint64) (result [][3]uint64, ok bool, err error)

CheckVersionConflict checks out all versions of the major, determines if there is a version number conflict. ok is true means no conflict.

func Close

func Close() error

func CreateApiTest

func CreateApiTest(at *ApiTest) (int64, error)

CreateApiTest 创建apiTest信息

func CreateOrUpdateAPIAssetVersionSpec

func CreateOrUpdateAPIAssetVersionSpec(spec *APIAssetVersionSpecsModel) error

func CreateTestEnv

func CreateTestEnv(env *APITestEnv) (int64, error)

CreateTestEnv 创建测试环境变量信息

func DeleteAPIAssetByOrgAssetID

func DeleteAPIAssetByOrgAssetID(orgID uint64, assetID string, cascade bool) error

DeleteAPIAssetByOrgAssetID deletes the APIAsset and APIAssetVersion record for giving assetID

func DeleteAPIAssetVersion

func DeleteAPIAssetVersion(orgID uint64, assetID string, versionID uint64, cascade bool) error

DeleteAPIAssetVersion deletes a APIAssetVersion record

func DeleteApiTest

func DeleteApiTest(apiID int64) error

DeleteApiTest 删除apiTest信息

func DeleteTestEnv

func DeleteTestEnv(envID int64) error

DeleteTestEnv 删除测试环境变量信息

func FirstOrCreateInstantiation

func FirstOrCreateInstantiation(model *apistructs.InstantiationModel, params map[string]interface{}) error

func GenSemVer

func GenSemVer(orgID uint64, assetID, swaggerVersion string, major, minor, patch *uint64) error

GenSemVer generate the semantics version

func GetMyClient

func GetMyClient(req *apistructs.GetClientReq, orgManager bool) (*apistructs.ClientModel, error)

GetMyClient select a Client details

func InsertTPRecords

func InsertTPRecords(rs ...*TPRecordDO) error

func ListAPIsByTestCaseIDs

func ListAPIsByTestCaseIDs(projectID uint64, tcIDs []uint64) (map[uint64][]*ApiTest, error)

func ListAccess

func ListAccess(req *apistructs.ListAccessReq, responsibleAssetIDs []string) (uint64, []*apistructs.ListAccessObj, error)

func ListMyClients

func ListMyClients(req *apistructs.ListMyClientsReq, orgManager bool) (total uint64, models []*apistructs.ClientModel, err error)

func OneInstantiation

func OneInstantiation(model *apistructs.InstantiationModel, params map[string]interface{}) error

func Open

func Open() error

func QueryAPILatestVersion

func QueryAPILatestVersion(orgID uint64, assetID string) (*apistructs.APIAssetVersionsModel, error)

func QuerySpecsFromVersions

func QuerySpecsFromVersions(orgID uint64, assetID string, versionIDs []string, m map[uint64]*apistructs.PagingAPIAssetVersionRspObj) error

func QueryVersionLatestSpec

func QueryVersionLatestSpec(orgID, versionID uint64) (*apistructs.APIAssetVersionSpecsModel, error)

func Set added in v1.3.0

func Set(ng *dbengine.DBEngine)

func Sq

func Sq() *gorm.DB

func UpdateApiTest

func UpdateApiTest(at *ApiTest) (int64, error)

UpdateApiTest 更新apiTest信息

func UpdateApiTestResults

func UpdateApiTestResults(at *ApiTest) (int64, error)

UpdateApiTestResults 更新apiTest结果信息:status,api_response,assert_result

func UpdateInstantiation

func UpdateInstantiation(req *apistructs.UpdateInstantiationReq) error

func UpdateTestEnv

func UpdateTestEnv(env *APITestEnv) error

UpdateTestEnv 更新测试环境变量信息

Types

type APIAssetVersionSpecsModel

type APIAssetVersionSpecsModel apistructs.APIAssetVersionSpecsModel

APIAssetVersionSpec is dice_api_asset_version_specs model

func (APIAssetVersionSpecsModel) TableName

func (m APIAssetVersionSpecsModel) TableName() string

type APIAssetsModel

type APIAssetsModel apistructs.APIAssetsModel

APIAsset is dice_api_assets model

func GetAPIAsset

func GetAPIAsset(req *apistructs.GetAPIAssetReq) (*APIAssetsModel, error)

func (APIAssetsModel) TableName

func (APIAssetsModel) TableName() string

type APITestEnv

type APITestEnv struct {
	ID        int64     `xorm:"pk autoincr" json:"id"`
	CreatedAt time.Time `xorm:"created" json:"createdAt"`
	UpdatedAt time.Time `xorm:"updated" json:"updatedAt"`

	EnvID   int64  `xorm:"env_id" json:"envID"`
	EnvType string `xorm:"env_type" json:"envType"`
	Name    string `xorm:"name" json:"name"`
	Domain  string `xorm:"domain" json:"domain"`
	Header  string `xorm:"header" json:"header"`
	Global  string `xorm:"global" json:"global"`
}

APITestEnv 存储API测试环境变量

func GetTestEnv

func GetTestEnv(envID int64) (*APITestEnv, error)

GetTestEnv 根据envID获取测试环境变量信息

func GetTestEnvListByEnvID

func GetTestEnvListByEnvID(envID int64, envType string) ([]APITestEnv, error)

GetTestEnvListByEnvID 根据envID获取测试环境变量信息

func (APITestEnv) TableName

func (APITestEnv) TableName() string

TableName APITestEnv对应的数据库表dice_api_test_env

type ApiTest

type ApiTest struct {
	ID        int64     `xorm:"pk autoincr" json:"id"`
	CreatedAt time.Time `xorm:"created" json:"createdAt"`
	UpdatedAt time.Time `xorm:"updated" json:"updatedAt"`

	UsecaseID    int64  `xorm:"usecase_id" json:"usecaseID"`
	UsecaseOrder int64  `xorm:"usecase_order" json:"usecaseOrder"`
	ProjectID    int64  `xorm:"project_id" json:"projectID"`
	PipelineID   int64  `xorm:"pipeline_id" json:"pipelineID"`
	Status       string `xorm:"status" json:"status"`
	ApiInfo      string `xorm:"text" json:"apiInfo"`
	ApiRequest   string `xorm:"longtext" json:"apiRequest"`
	ApiResponse  string `xorm:"longtext" json:"apiResponse"`
	AssertResult string `xorm:"text" json:"assertResult"`
}

ApiTest 存储pmp上接口测试相关的信息,对应数据库表dice_api_test

func GetApiTest

func GetApiTest(apiID int64) (*ApiTest, error)

GetApiTest 根据apiID获取apiTest信息

func GetApiTestListByUsecaseID

func GetApiTestListByUsecaseID(usecaseID int64) ([]ApiTest, error)

GetApiTestListByUsecaseID 根据usecaseID获取apiTest列表

func (ApiTest) TableName

func (ApiTest) TableName() string

TableName DiceApiTest对应的数据库表dice_api_test

type DBClient

type DBClient struct {
	*dbengine.DBEngine
}
var DB *DBClient

func (*DBClient) BulkInsert

func (db *DBClient) BulkInsert(objects interface{}, excludeColumns ...string) error

func (*DBClient) Sq

func (db *DBClient) Sq() *gorm.DB

func (*DBClient) Transaction

func (db *DBClient) Transaction(f func(tx *gorm.DB) error) error

Transaction Execute Transaction

func (*DBClient) Tx

func (db *DBClient) Tx() *TX

type KV

type KV map[string]interface{}

type Paging

type Paging struct {
	Total    int64       `json:"total"`
	PageNo   int         `json:"pageNo"`
	PageSize int         `json:"pageSize"`
	List     interface{} `json:"list"`
}

func FindTPRecordPagingByAppID

func FindTPRecordPagingByAppID(req apistructs.TestRecordPagingRequest) (*Paging, error)

func NewPaging

func NewPaging(pageNo, pageSize int) *Paging

type Pipeline

type Pipeline struct {
	Version string   `json:"version"`
	Stages  []*Stage `json:"stages,omitempty"`

	Envs map[string]string `json:"envs,omitempty"`

	Resources []Resource `json:"resources,omitempty"`

	ResourceTypes []ResourceType `json:"resource_types,omitempty"`

	Triggers []Trigger `json:"triggers,omitempty"`
}

type QASonar

type QASonar struct {
	ID        int64     `xorm:"pk autoincr" json:"id"`
	CreatedAt time.Time `xorm:"created" json:"createdAt"`
	UpdatedAt time.Time `xorm:"updated" json:"updatedAt"`

	ApplicationID    int64  `xorm:"app_id" json:"applicationId"`
	ProjectID        int64  `xorm:"project_id" json:"projectId" validate:"required"`
	BuildID          int64  `xorm:"build_id" json:"buildId"`
	LogID            string `xorm:"log_id" json:"logId"`
	ApplicationName  string `xorm:"app_name" json:"applicationName"`
	OperatorID       string `xorm:"operator_id" json:"operatorId" validate:"required"`
	CommitID         string `xorm:"commit_id" json:"commitId"`
	Branch           string `xorm:"branch" json:"branch" validate:"required"`
	GitRepo          string `xorm:"git_repo" json:"gitRepo" validate:"required"`
	Key              string `xorm:"not null VARCHAR(255)" json:"key,omitempty"`
	Bugs             string `xorm:"longtext" json:"bugs,omitempty"`
	CodeSmells       string `xorm:"longtext" json:"code_smells,omitempty"`
	Vulnerabilities  string `xorm:"longtext" json:"vulnerabilities,omitempty"`
	Coverage         string `xorm:"longtext" json:"coverage,omitempty"`
	Duplications     string `xorm:"longtext" json:"duplications,omitempty"`
	IssuesStatistics string `xorm:"text" json:"issues_statistics,omitempty"`
}

QASonar 存储sonar分析的结果,对应数据库表qa_sonar

func FindLatestSonarByAppID

func FindLatestSonarByAppID(appID int64) (*QASonar, error)

func (QASonar) TableName

func (QASonar) TableName() string

TableName QASonar对应的数据库表qa_sonar

type Resource

type Resource struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Source KV     `json:"source"`
}

type ResourceType

type ResourceType struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Source KV     `json:"source"`
}

type Schedule

type Schedule struct {
	Cron string `json:"cron"`
}

type Stage

type Stage struct {
	Name  string  `json:"name,omitempty"`
	Tasks []Tasks `json:"tasks,omitempty"`
}

type TPRecordDO

type TPRecordDO struct {
	ID        uint64    `xorm:"pk autoincr 'id'" json:"id"`
	CreatedAt time.Time `xorm:"created" json:"createdAt"`
	UpdatedAt time.Time `xorm:"updated" json:"updatedAt"`

	ApplicationID   int64                    `xorm:"app_id" json:"applicationId"`
	ProjectID       int64                    `xorm:"project_id" json:"projectId" validate:"required"`
	BuildID         int64                    `xorm:"build_id" json:"buildId"`
	Name            string                   `xorm:"name" json:"name" validate:"required"`
	UUID            string                   `xorm:"uuid" json:"uuid"`
	ApplicationName string                   `xorm:"app_name" json:"applicationName"`
	Output          string                   `xorm:"output" json:"output"`
	Desc            string                   `xorm:"desc" json:"desc"`
	OperatorID      string                   `xorm:"operator_id" json:"operatorId"`
	OperatorName    string                   `xorm:"operator_name" json:"operatorName"`
	CommitID        string                   `xorm:"commit_id" json:"commitId"`
	Branch          string                   `xorm:"branch" json:"branch" validate:"required"`
	GitRepo         string                   `xorm:"git_repo" json:"gitRepo" validate:"required"`
	CaseDir         string                   `xorm:"case_dir" json:"caseDir"`
	Application     string                   `xorm:"-" json:"application"`
	Avatar          string                   `xorm:"-" json:"avatar,omitempty"`
	TType           apistructs.TestType      `xorm:"type" json:"type" validate:"required"`
	Totals          *apistructs.TestTotals   `xorm:"totals json" json:"totals"`
	ParserType      types.TestParserType     `xorm:"parser_type" json:"parserType"`
	Extra           map[string]string        `xorm:"varchar(1024) 'extra'" json:"extra,omitempty"`
	Envs            map[string]string        `xorm:"varchar(1024) 'envs'" json:"envs"`
	Workspace       apistructs.DiceWorkspace `xorm:"workspace" json:"workspace" validate:"required"`
	Suites          []*apistructs.TestSuite  `xorm:"longtext 'suites'" json:"suites"`
}

func FindTPRecord

func FindTPRecord(tp *TPRecordDO) (*TPRecordDO, error)

func FindTPRecordByCommitId

func FindTPRecordByCommitId(commitID string) (*TPRecordDO, error)

func FindTPRecordById

func FindTPRecordById(id uint64) (*TPRecordDO, error)

func InsertTPRecord

func InsertTPRecord(r *TPRecordDO) (*TPRecordDO, error)

func NewTPRecordDO

func NewTPRecordDO() *TPRecordDO

func (*TPRecordDO) EraseSensitiveInfo

func (tp *TPRecordDO) EraseSensitiveInfo()

func (*TPRecordDO) GenSubject

func (tp *TPRecordDO) GenSubject() string

func (*TPRecordDO) GetExtraInfo

func (tp *TPRecordDO) GetExtraInfo(key string) string

func (*TPRecordDO) GetRecordName

func (tp *TPRecordDO) GetRecordName() string

func (*TPRecordDO) SetCols

func (tp *TPRecordDO) SetCols(cols interface{}) (*TPRecordDO, error)

func (*TPRecordDO) SetTPType

func (tp *TPRecordDO) SetTPType(tpType apistructs.TestType) *TPRecordDO

func (TPRecordDO) TableName

func (TPRecordDO) TableName() string

type TX

type TX struct {
	*gorm.DB
}

func Tx

func Tx() *TX

func (*TX) Sq

func (tx *TX) Sq() *gorm.DB

type Tasks

type Tasks KV

type Trigger

type Trigger struct {
	Schedule Schedule `json:"schedule"`
}

Jump to

Keyboard shortcuts

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