service

package
v2.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// test
	VerbGetTest    = "get_test"
	VerbCreateTest = "create_test"
	VerbEditTest   = "edit_test"
	VerbDeleteTest = "delete_test"
	VerbRunTest    = "run_test"
)
View Source
const DefaultScanningTimeout = 60 * 60

Variables

This section is empty.

Functions

func ConvertToDBScanningModule

func ConvertToDBScanningModule(args *Scanning) *commonmodels.Scanning

func CreateScanningModule

func CreateScanningModule(username string, args *Scanning, log *zap.SugaredLogger) error

func CreateScanningTask

func CreateScanningTask(id string, req []*ScanningRepoInfo, notificationID, username string, log *zap.SugaredLogger) (int64, error)

CreateScanningTask uses notificationID if the task is triggered by webhook, otherwise it should be empty

func CreateScanningTaskV2

func CreateScanningTaskV2(id, username, account, userID string, req *CreateScanningTaskReq, notificationID string, log *zap.SugaredLogger) (int64, error)

CreateScanningTaskV2 uses notificationID if the task is triggered by webhook, otherwise it should be empty

func CreateTesting

func CreateTesting(username string, testing *commonmodels.Testing, log *zap.SugaredLogger) error

func DeleteScanningModuleByID

func DeleteScanningModuleByID(id string, log *zap.SugaredLogger) error

func GetHTMLTestReport

func GetHTMLTestReport(pipelineName, pipelineType, taskIDStr, testName string, log *zap.SugaredLogger) (string, error)

func GetRaw

func GetRaw(name, productName string, log *zap.SugaredLogger) (*commonmodels.Testing, error)

GetRaw find the testing module with secret env not masked

func GetTestLocalTestSuite

func GetTestLocalTestSuite(testName string, log *zap.SugaredLogger) (*commonmodels.TestSuite, error)

func GetTestTask

func GetTestTask(testName string) (*commonmodels.TestTaskStat, error)

func GetTestTaskDetail

func GetTestTaskDetail(projectKey, testName string, taskID int64, log *zap.SugaredLogger) (*task.Task, error)

func GetTestTaskReportDetail

func GetTestTaskReportDetail(projectKey, testName string, taskID int64, log *zap.SugaredLogger) ([]*commonmodels.TestSuite, error)

func GetTesting

func GetTesting(name, productName string, log *zap.SugaredLogger) (*commonmodels.Testing, error)

func GetWorkflowV4HTMLTestReport

func GetWorkflowV4HTMLTestReport(workflowName, jobName string, taskID int64, log *zap.SugaredLogger) (string, error)

func HandleCronjob

func HandleCronjob(testing *commonmodels.Testing, log *zap.SugaredLogger) error

func ListAllWorkflows

func ListAllWorkflows(testName string, log *zap.SugaredLogger) ([]*commonmodels.Workflow, error)

func ListCronjob

func ListCronjob(name, jobType string) ([]*commonmodels.Cronjob, error)

func ListTestStat

func ListTestStat(log *zap.SugaredLogger) ([]*commonmodels.TestTaskStat, error)

func OpenAPICreateScanningModule

func OpenAPICreateScanningModule(username string, args *OpenAPICreateScanningReq, log *zap.SugaredLogger) error

func OpenAPICreateScanningTask

func OpenAPICreateScanningTask(username, account, userID string, args *OpenAPICreateScanningTaskReq, log *zap.SugaredLogger) (int64, error)

func OpenAPICreateTestTask

func OpenAPICreateTestTask(userName, account, userID string, args *OpenAPICreateTestTaskReq, logger *zap.SugaredLogger) (int64, error)

func UpdateScanningModule

func UpdateScanningModule(id, username string, args *Scanning, log *zap.SugaredLogger) error

func UpdateTesting

func UpdateTesting(username string, testing *commonmodels.Testing, log *zap.SugaredLogger) error

Types

type CreateScanningTaskReq

type CreateScanningTaskReq struct {
	KeyVals []*commonmodels.KeyVal `json:"key_vals"`
	Repos   []*ScanningRepoInfo    `json:"repos"`
}

type CreateTaskResp

type CreateTaskResp struct {
	PipelineName string `json:"pipeline_name"`
	TaskID       int64  `json:"task_id"`
}

func CreateTestTask

func CreateTestTask(args *commonmodels.TestTaskArgs, log *zap.SugaredLogger) (*CreateTaskResp, error)

func CreateTestTaskV2

func CreateTestTaskV2(args *commonmodels.TestTaskArgs, username, account, userID string, log *zap.SugaredLogger) (*CreateTaskResp, error)

CreateTestTaskV2 creates a test task, but with the new custom workflow engine

type GetTestArtifactInfoResp

type GetTestArtifactInfoResp struct {
	FileNames          []string `json:"file_names"`
	NotHistoryFileFlag bool     `json:"not_history_file_flag"`
}

func GetTestArtifactInfo

func GetTestArtifactInfo(pipelineName, dir string, taskID int64, log *zap.SugaredLogger) (*GetTestArtifactInfoResp, error)

func GetWorkflowV4TestArtifactInfo

func GetWorkflowV4TestArtifactInfo(workflowName, jobName string, taskID int64, log *zap.SugaredLogger) (*GetTestArtifactInfoResp, error)

type ListScanningRespItem

type ListScanningRespItem struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"name"`
	Statistics *ScanningStatistic     `json:"statistics"`
	CreatedAt  int64                  `json:"created_at"`
	UpdatedAt  int64                  `json:"updated_at"`
	Repos      []*types.Repository    `json:"repos"`
	ClusterID  string                 `json:"cluster_id"`
	Envs       []*commonmodels.KeyVal `json:"key_vals"`
}

func ListScanningModule

func ListScanningModule(projectName string, log *zap.SugaredLogger) ([]*ListScanningRespItem, int64, error)

type ListScanningTaskResp

type ListScanningTaskResp struct {
	ScanInfo   *ScanningInfo       `json:"scan_info"`
	ScanTasks  []*ScanningTaskResp `json:"scan_tasks"`
	TotalTasks int64               `json:"total_tasks"`
}

func ListScanningTask

func ListScanningTask(id string, pageNum, pageSize int, log *zap.SugaredLogger) (*ListScanningTaskResp, error)

type OpenAPICreateScanningReq

type OpenAPICreateScanningReq struct {
	Name        string                    `json:"name"`
	ProjectName string                    `json:"project_key"`
	Description string                    `json:"description"`
	ScannerType string                    `json:"scanner_type"`
	ImageName   string                    `json:"image_name"`
	RepoInfo    []*types.OpenAPIRepoInput `json:"repo_info"`
	SonarSystem string                    `json:"sonar_system"`
	// FIMXE: currently only one sonar system is required, so we just fill in the default sonar ID.
	Addons            []*commonmodels.Item          `json:"addons"`
	PrelaunchScript   string                        `json:"prelaunch_script"`
	SonarParameter    string                        `json:"sonar_parameter"`
	Script            string                        `json:"script"`
	EnableQualityGate bool                          `json:"enable_quality_gate"`
	AdvancedSetting   *types.OpenAPIAdvancedSetting `json:"advanced_settings"`
}

TODO: change the logic of create scanning

func (*OpenAPICreateScanningReq) Validate

func (req *OpenAPICreateScanningReq) Validate() (bool, error)

type OpenAPICreateScanningTaskReq

type OpenAPICreateScanningTaskReq struct {
	ProjectName string
	ScanName    string
	ScanRepos   []*ScanningRepoInfo    `json:"scan_repos"`
	ScanKVs     []*commonmodels.KeyVal `json:"scan_kvs"`
}

func (*OpenAPICreateScanningTaskReq) Validate

func (s *OpenAPICreateScanningTaskReq) Validate() (bool, error)

type OpenAPICreateScanningTaskResp

type OpenAPICreateScanningTaskResp struct {
	TaskID int64 `json:"task_id"`
}

type OpenAPICreateTestTaskReq

type OpenAPICreateTestTaskReq struct {
	ProjectName string `json:"project_key"`
	TestName    string `json:"test_name"`
}

func (*OpenAPICreateTestTaskReq) Validate

func (t *OpenAPICreateTestTaskReq) Validate() (bool, error)

type OpenAPICreateTestTaskResp

type OpenAPICreateTestTaskResp struct {
	TaskID int64 `json:"task_id"`
}

type OpenAPIScanRepoBrief

type OpenAPIScanRepoBrief struct {
	RepoOwner    string `json:"repo_owner"`
	Source       string `json:"source"`
	Address      string `json:"address"`
	Branch       string `json:"branch"`
	RemoteName   string `json:"remote_name"`
	RepoName     string `json:"repo_name"`
	Hidden       bool   `json:"hidden"`
	CheckoutPath string `json:"checkout_path"`
	SubModules   bool   `json:"submodules"`
}

type OpenAPIScanTaskDetail

type OpenAPIScanTaskDetail struct {
	ScanName   string                  `json:"scan_name"`
	Creator    string                  `json:"creator"`
	TaskID     int64                   `json:"task_id"`
	Status     string                  `json:"status"`
	CreateTime int64                   `json:"create_time"`
	EndTime    int64                   `json:"end_time"`
	ResultLink string                  `json:"result_link"`
	RepoInfo   []*OpenAPIScanRepoBrief `json:"repo_info"`
}

func OpenAPIGetScanningTaskDetail

func OpenAPIGetScanningTaskDetail(taskID int64, productName, scanName string, logger *zap.SugaredLogger) (*OpenAPIScanTaskDetail, error)

type OpenAPITestCase

type OpenAPITestCase struct {
	Name    string                `json:"name"`
	Time    float64               `json:"time"`
	Failure *commonmodels.Failure `json:"failure"`
	Error   *commonmodels.Error   `json:"error"`
}

type OpenAPITestReport

type OpenAPITestReport struct {
	TestTotal    int                `json:"test_total"`
	FailureTotal int                `json:"failure_total"`
	SuccessTotal int                `json:"success_total"`
	SkipedTotal  int                `json:"skiped_total"`
	ErrorTotal   int                `json:"error_total"`
	Time         float64            `json:"time"`
	TestCases    []*OpenAPITestCase `json:"test_cases"`
}

type OpenAPITestTaskDetail

type OpenAPITestTaskDetail struct {
	TestName   string             `json:"test_name"`
	TaskID     int64              `json:"task_id"`
	Creator    string             `json:"creator"`
	CreateTime int64              `json:"create_time"`
	StartTime  int64              `json:"start_time"`
	EndTime    int64              `json:"end_time"`
	Status     string             `json:"status"`
	TestReport *OpenAPITestReport `json:"test_report"`
}

func OpenAPIGetTestTaskResult

func OpenAPIGetTestTaskResult(taskID int64, productName, testName string, logger *zap.SugaredLogger) (*OpenAPITestTaskDetail, error)

type Scanning

type Scanning struct {
	ID            string               `json:"id"`
	Name          string               `json:"name"`
	ProjectName   string               `json:"project_name"`
	Description   string               `json:"description"`
	ScannerType   string               `json:"scanner_type"`
	EnableScanner bool                 `json:"enable_scanner"`
	ImageID       string               `json:"image_id"`
	SonarID       string               `json:"sonar_id"`
	Installs      []*commonmodels.Item `json:"installs"`
	Repos         []*types.Repository  `json:"repos"`
	// Parameter is for sonarQube type only
	Parameter string `json:"parameter"`
	// Envs is the user defined key/values
	Envs             []*commonmodels.KeyVal                `json:"envs"`
	Script           string                                `json:"script"`
	AdvancedSetting  *commonmodels.ScanningAdvancedSetting `json:"advanced_settings"`
	CheckQualityGate bool                                  `json:"check_quality_gate"`
	Outputs          []*commonmodels.Output                `json:"outputs"`
	NotifyCtls       []*commonmodels.NotifyCtl             `json:"notify_ctls"`
	// template IDs
	TemplateID string `json:"template_id"`
}

func ConvertDBScanningModule

func ConvertDBScanningModule(scanning *commonmodels.Scanning) *Scanning

func GetScanningModuleByID

func GetScanningModuleByID(id string, log *zap.SugaredLogger) (*Scanning, error)

type ScanningInfo

type ScanningInfo struct {
	Editor    string `json:"editor"`
	UpdatedAt int64  `json:"updated_at"`
}

type ScanningRepoInfo

type ScanningRepoInfo struct {
	CodehostID    int    `json:"codehost_id"`
	Source        string `json:"source"`
	RepoOwner     string `json:"repo_owner"`
	RepoNamespace string `json:"repo_namespace"`
	RepoName      string `json:"repo_name"`
	PR            int    `json:"pr"`
	PRs           []int  `json:"prs"`
	Branch        string `json:"branch"`
	Tag           string `json:"tag"`
}

type ScanningStatistic

type ScanningStatistic struct {
	TimesRun       int64 `json:"times_run"`
	AverageRuntime int64 `json:"run_time_average"`
}

type ScanningTaskDetail

type ScanningTaskDetail struct {
	Creator    string              `json:"creator"`
	Status     string              `json:"status"`
	CreateTime int64               `json:"create_time"`
	EndTime    int64               `json:"end_time"`
	RepoInfo   []*types.Repository `json:"repo_info"`
	ResultLink string              `json:"result_link,omitempty"`
}

func GetScanningTaskInfo

func GetScanningTaskInfo(scanningID string, taskID int64, log *zap.SugaredLogger) (*ScanningTaskDetail, error)

type ScanningTaskResp

type ScanningTaskResp struct {
	ScanID    int64  `json:"scan_id"`
	Status    string `json:"status"`
	RunTime   int64  `json:"run_time"`
	Creator   string `json:"creator"`
	CreatedAt int64  `json:"created_at"`
}

type TestTaskList

type TestTaskList struct {
	Total int                       `json:"total"`
	Tasks []*commonrepo.TaskPreview `json:"tasks"`
}

func ListTestTask

func ListTestTask(testName, projectKey string, pageNum, pageSize int, log *zap.SugaredLogger) (*TestTaskList, error)

type TestingDetail

type TestingDetail struct {
	Name        string                 `json:"name"`
	Envs        []*commonmodels.KeyVal `json:"envs"`
	Repos       []*types.Repository    `json:"repos"`
	Desc        string                 `json:"desc"`
	ProductName string                 `json:"product_name"`
}

func ListTestingDetails

func ListTestingDetails(productName string, log *zap.SugaredLogger) ([]*TestingDetail, error)

type TestingOpt

type TestingOpt struct {
	Name        string                     `bson:"name"                   json:"name"`
	ProductName string                     `bson:"product_name"           json:"product_name"`
	Desc        string                     `bson:"desc"                   json:"desc"`
	UpdateTime  int64                      `bson:"update_time"            json:"update_time"`
	UpdateBy    string                     `bson:"update_by"              json:"update_by"`
	TestCaseNum int                        `bson:"-"                      json:"test_case_num,omitempty"`
	ExecuteNum  int                        `bson:"-"                      json:"execute_num,omitempty"`
	PassRate    float64                    `bson:"-"                      json:"pass_rate,omitempty"`
	AvgDuration float64                    `bson:"-"                      json:"avg_duration,omitempty"`
	Workflows   []*commonmodels.Workflow   `bson:"-"                      json:"workflows,omitempty"`
	Schedules   *commonmodels.ScheduleCtrl `bson:"-"                      json:"schedules,omitempty"`
	Repos       []*types.Repository        `bson:"repos"                  json:"repos"`
	KeyVals     []*commonmodels.KeyVal     `bson:"key_vals"               json:"key_vals"`
	ClusterID   string                     `bson:"cluster_id"             json:"cluster_id"`
	Verbs       []string                   `bson:"-"                      json:"verbs,omitempty"`
}

func ListTesting

func ListTesting(uid string, log *zap.SugaredLogger) ([]*TestingOpt, error)

func ListTestingOpt

func ListTestingOpt(productNames []string, testType string, log *zap.SugaredLogger) ([]*TestingOpt, error)

Jump to

Keyboard shortcuts

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