service

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PERPAGE = 100
	PAGE    = 1
)
View Source
const DefaultScanningTimeout = 60 * 60

Variables

This section is empty.

Functions

func CancelScanningTask added in v1.9.9

func CancelScanningTask(userName, scanningID string, taskID int64, typeString config.PipelineType, requestID string, log *zap.SugaredLogger) error

func ConvertToDBScanningModule added in v1.9.9

func ConvertToDBScanningModule(args *Scanning) *commonmodels.Scanning

func CreateScanningModule added in v1.9.9

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

func CreateScanningTask added in v1.9.9

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 CreateTesting added in v1.2.0

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

func DeleteScanningModuleByID added in v1.9.9

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

func GetHTMLTestReport added in v1.2.0

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(serviceName string, log *zap.SugaredLogger) (*commonmodels.TestSuite, error)

func GetTestTask

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

func GetTesting added in v1.2.0

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

func GetWorkflowV4HTMLTestReport added in v1.9.9

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 added in v1.2.0

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

func OpenAPICreateScanningModule added in v1.9.9

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

func OpenAPICreateScanningTask added in v1.9.9

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

func OpenAPICreateTestTask added in v1.9.9

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

func UpdateScanningModule added in v1.9.9

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

func UpdateTesting added in v1.2.0

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

Types

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)

type GetTestArtifactInfoResp added in v1.9.9

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 added in v1.9.9

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

type ListScanningRespItem added in v1.9.9

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"`
}

func ListScanningModule added in v1.9.9

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

type ListScanningTaskResp added in v1.9.9

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

func ListScanningTask added in v1.9.9

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

type OpenAPICreateScanningReq added in v1.9.9

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"`
	// 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"`
}

func (*OpenAPICreateScanningReq) Validate added in v1.9.9

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

type OpenAPICreateScanningTaskReq added in v1.9.9

type OpenAPICreateScanningTaskReq struct {
	ProjectName string
	ScanName    string
	ScanRepos   []*ScanningRepoInfo `json:"scan_repos"`
}

func (*OpenAPICreateScanningTaskReq) Validate added in v1.9.9

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

type OpenAPICreateScanningTaskResp added in v1.9.9

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

type OpenAPICreateTestTaskReq added in v1.9.9

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

func (*OpenAPICreateTestTaskReq) Validate added in v1.9.9

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

type OpenAPICreateTestTaskResp added in v1.9.9

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

type OpenAPIScanRepoBrief added in v1.9.9

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 added in v1.9.9

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 added in v1.9.9

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

type OpenAPITestCase added in v1.9.9

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

type OpenAPITestReport added in v1.9.9

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 added in v1.9.9

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 added in v1.9.9

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

type Scanning added in v1.9.9

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"`
	ImageID     string               `json:"image_id"`
	SonarID     string               `json:"sonar_id"`
	Installs    []*commonmodels.Item `json:"installs"`
	Repos       []*types.Repository  `json:"repos"`
	PreScript   string               `json:"pre_script"`
	// Parameter is for sonarQube type only
	Parameter string `json:"parameter"`
	// Script is for other type only
	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"`
}

func ConvertDBScanningModule added in v1.9.9

func ConvertDBScanningModule(scanning *commonmodels.Scanning) *Scanning

func GetScanningModuleByID added in v1.9.9

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

type ScanningInfo added in v1.9.9

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

type ScanningRepoInfo added in v1.9.9

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 added in v1.9.9

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

type ScanningTaskDetail added in v1.9.9

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 added in v1.9.9

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

type ScanningTaskResp added in v1.9.9

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 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"`
}

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