Documentation
¶
Overview ¶
Package dbclient defines operations about database
Index ¶
- Constants
- func CheckVersionConflict(orgID uint64, assetID string, major, minor, patch uint64) (result [][3]uint64, ok bool, err error)
- func Close() error
- func CreateApiTest(at *ApiTest) (int64, error)
- func CreateOrUpdateAPIAssetVersionSpec(spec *APIAssetVersionSpecsModel) error
- func CreateTestEnv(env *APITestEnv) (int64, error)
- func DeleteAPIAssetByOrgAssetID(orgID uint64, assetID string, cascade bool) error
- func DeleteAPIAssetVersion(orgID uint64, assetID string, versionID uint64, cascade bool) error
- func DeleteApiTest(apiID int64) error
- func DeleteTestEnv(envID int64) error
- func FirstOrCreateInstantiation(model *apistructs.InstantiationModel, params map[string]interface{}) error
- func GenSemVer(orgID uint64, assetID, swaggerVersion string, major, minor, patch *uint64) error
- func GetAPIAssetVersion(req *apistructs.GetAPIAssetVersionReq) (*apistructs.APIAssetVersionsModel, error)
- func GetContract(req *apistructs.GetContractReq) (*apistructs.ContractModel, error)
- func GetMyClient(req *apistructs.GetClientReq, orgManager bool) (*apistructs.ClientModel, error)
- func InsertTPRecords(rs ...*TPRecordDO) error
- func ListAPIsByTestCaseIDs(projectID uint64, tcIDs []uint64) (map[uint64][]*ApiTest, error)
- func ListAccess(req *apistructs.ListAccessReq, responsibleAssetIDs []string) (uint64, []*apistructs.ListAccessObj, error)
- func ListContractRecords(req *apistructs.ListContractRecordsReq) ([]*apistructs.ContractRecordModel, error)
- func ListContracts(req *apistructs.ListContractsReq) (uint64, []*apistructs.ContractModelAdvance, error)
- func ListMyClients(req *apistructs.ListMyClientsReq, orgManager bool) (total uint64, models []*apistructs.ClientModel, err error)
- func ListSwaggerVersionClients(req *apistructs.ListSwaggerVersionClientsReq) ([]*apistructs.ListSwaggerVersionClientOjb, error)
- func OneInstantiation(model *apistructs.InstantiationModel, params map[string]interface{}) error
- func Open() error
- func PagingAPIAssetVersions(req *apistructs.PagingAPIAssetVersionsReq) (uint64, []*apistructs.APIAssetVersionsModel, error)
- func QueryAPILatestVersion(orgID uint64, assetID string) (*apistructs.APIAssetVersionsModel, error)
- func QuerySpecsFromVersions(orgID uint64, assetID string, versionIDs []string, ...) error
- func QueryVersionLatestSpec(orgID, versionID uint64) (*apistructs.APIAssetVersionSpecsModel, error)
- func Set(ng *dbengine.DBEngine)
- func Sq() *gorm.DB
- func UpdateApiTest(at *ApiTest) (int64, error)
- func UpdateApiTestResults(at *ApiTest) (int64, error)
- func UpdateInstantiation(req *apistructs.UpdateInstantiationReq) error
- func UpdateTestEnv(env *APITestEnv) error
- type APIAssetVersionSpecsModel
- type APIAssetsModel
- type APITestEnv
- type ApiTest
- type DBClient
- type KV
- type Paging
- type Pipeline
- type QASonar
- type Resource
- type ResourceType
- type Schedule
- type Stage
- type TPRecordDO
- func (tp *TPRecordDO) EraseSensitiveInfo()
- func (tp *TPRecordDO) GenSubject() string
- func (tp *TPRecordDO) GetExtraInfo(key string) string
- func (tp *TPRecordDO) GetRecordName() string
- func (tp *TPRecordDO) SetCols(cols interface{}) (*TPRecordDO, error)
- func (tp *TPRecordDO) SetTPType(tpType apistructs.TestType) *TPRecordDO
- func (TPRecordDO) TableName() string
- type TX
- type Tasks
- type Trigger
Constants ¶
const ( PageNo = "pageNo" PageSize = "pageSize" ExtraEndpoint = "extra_cs_endpoint" ExtraAccessKey = "extra_cs_ak" ExtraSecretKey = "extra_cs_sk" ExtraBucket = "extra_cs_bucket" HTTP = "HTTP" )
const BULK_INSERT_CHUNK_SIZE = 3000
const DistinctAssetIDFromAccess = `` /* 191-byte string literal not displayed */
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 CreateOrUpdateAPIAssetVersionSpec ¶
func CreateOrUpdateAPIAssetVersionSpec(spec *APIAssetVersionSpecsModel) error
func DeleteAPIAssetByOrgAssetID ¶
DeleteAPIAssetByOrgAssetID deletes the APIAsset and APIAssetVersion record for giving assetID
func DeleteAPIAssetVersion ¶
DeleteAPIAssetVersion deletes a APIAssetVersion record
func FirstOrCreateInstantiation ¶
func FirstOrCreateInstantiation(model *apistructs.InstantiationModel, params map[string]interface{}) error
func GetAPIAssetVersion ¶
func GetAPIAssetVersion(req *apistructs.GetAPIAssetVersionReq) (*apistructs.APIAssetVersionsModel, error)
func GetContract ¶
func GetContract(req *apistructs.GetContractReq) (*apistructs.ContractModel, error)
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 ListAccess ¶
func ListAccess(req *apistructs.ListAccessReq, responsibleAssetIDs []string) (uint64, []*apistructs.ListAccessObj, error)
func ListContractRecords ¶
func ListContractRecords(req *apistructs.ListContractRecordsReq) ([]*apistructs.ContractRecordModel, error)
func ListContracts ¶
func ListContracts(req *apistructs.ListContractsReq) (uint64, []*apistructs.ContractModelAdvance, error)
func ListMyClients ¶
func ListMyClients(req *apistructs.ListMyClientsReq, orgManager bool) (total uint64, models []*apistructs.ClientModel, err error)
func ListSwaggerVersionClients ¶
func ListSwaggerVersionClients(req *apistructs.ListSwaggerVersionClientsReq) ([]*apistructs.ListSwaggerVersionClientOjb, error)
func OneInstantiation ¶
func OneInstantiation(model *apistructs.InstantiationModel, params map[string]interface{}) error
func PagingAPIAssetVersions ¶
func PagingAPIAssetVersions(req *apistructs.PagingAPIAssetVersionsReq) (uint64, []*apistructs.APIAssetVersionsModel, 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 UpdateApiTestResults ¶
UpdateApiTestResults 更新apiTest结果信息:status,api_response,assert_result
func UpdateInstantiation ¶
func UpdateInstantiation(req *apistructs.UpdateInstantiationReq) error
Types ¶
type APIAssetVersionSpecsModel ¶
type APIAssetVersionSpecsModel apistructs.APIAssetVersionSpecsModel
APIAssetVersionSpec is dice_api_asset_version_specs model
func GetAPIAssetVersionSpec ¶
func GetAPIAssetVersionSpec(req *apistructs.GetAPIAssetVersionReq) (*APIAssetVersionSpecsModel, error)
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 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 GetApiTestListByUsecaseID ¶
GetApiTestListByUsecaseID 根据usecaseID获取apiTest列表
type DBClient ¶
var DB *DBClient
func (*DBClient) BulkInsert ¶
func (*DBClient) Transaction ¶
Transaction Execute Transaction
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)
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 ¶
type ResourceType ¶
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