sonar

package
v2.2.0-20240131 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SonarWorkDirKey = "sonar.working.directory"
	CETaskIDKey     = "ceTaskId"
)

Variables

This section is empty.

Functions

func GetSonarAddressWithProjectKey

func GetSonarAddressWithProjectKey(baseAddr, projectKey string) (string, error)

GetSonarAddressWithProjectKey return the corresponding project address according to projectKey If the projectKey is empty or an error occurs, the original baseAddr is returned

func GetSonarCETaskID

func GetSonarCETaskID(content string) string

func GetSonarProjectKeyFromConfig

func GetSonarProjectKeyFromConfig(config string) string

func GetSonarWorkDir

func GetSonarWorkDir(content string) string

func PrintSonarConditionTables

func PrintSonarConditionTables(conditions []Condition)

Types

type CETask

type CETask struct {
	ID             string       `json:"id"`
	Type           string       `json:"type"`
	ComponentID    string       `json:"componentId"`
	ComponentKey   string       `json:"componentKey"`
	AnalysisID     string       `json:"analysisId"`
	Status         CETaskStatus `json:"status"`
	SubmitterLogin string       `json:"submitterLogin"`
	WarningCount   int          `json:"warningCount"`
}

type CETaskInfo

type CETaskInfo struct {
	Task CETask `json:"task"`
}

type CETaskStatus

type CETaskStatus string
const (
	CETaskPending    CETaskStatus = "PENDING"
	CETaskInProgress CETaskStatus = "IN_PROGRESS"
	CETaskSuccess    CETaskStatus = "SUCCESS"
	CETaskFailed     CETaskStatus = "FAILED"
	CETaskCanceled   CETaskStatus = "CANCELED"
)

type Client

type Client struct {
	*httpclient.Client
	// contains filtered or unexported fields
}

func NewSonarClient

func NewSonarClient(host, token string) *Client

func (*Client) GetCETaskInfo

func (c *Client) GetCETaskInfo(taskID string) (*CETaskInfo, error)

func (*Client) GetQualityGateInfo

func (c *Client) GetQualityGateInfo(analysisID string) (*ProjectInfo, error)

func (*Client) WaitForCETaskTobeDone

func (c *Client) WaitForCETaskTobeDone(taskID string, timeout time.Duration) (string, error)

type Condition

type Condition struct {
	Status         QualityGateStatus `json:"status"`
	MetricKey      string            `json:"metricKey"`
	Comparator     string            `json:"comparator"`
	PeriodIndex    int               `json:"periodIndex"`
	ErrorThreshold string            `json:"errorThreshold"`
	ActualValue    string            `json:"actualValue"`
}

type ProjectInfo

type ProjectInfo struct {
	ProjectStatus ProjectStatus
}

type ProjectStatus

type ProjectStatus struct {
	Status     QualityGateStatus `json:"status"`
	Conditions []Condition       `json:"conditions"`
}

type QualityGateStatus

type QualityGateStatus string
const (
	QualityGateError QualityGateStatus = "ERROR"
	QualityGateOK    QualityGateStatus = "OK"
	QualityGateWarn  QualityGateStatus = "WARN"
	QualityGateNone  QualityGateStatus = "None"
)

Jump to

Keyboard shortcuts

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