Documentation
¶
Index ¶
- Constants
- Variables
- func FetchOIDCConfig(portalURL string) (string, error)
- func IsFailureStatus(status string) bool
- type ClusterConfig
- type Deployment
- type DeploymentDetail
- type DeploymentService
- type PipelineRunFilter
- type PipelineRunGetOptions
- type PipelineRunInfo
- type PipelineRunListOptions
- type PipelineRunListResult
- type PipelineRunService
- type Project
- type ProjectService
- type QualityGate
- type QualityGateStatus
- type SonarGate
- type SonarGateCondition
- type SonarGateProjectStatus
- type SonarIssue
- type SonarIssueList
- type SonarIssuesParams
- type SonarListParams
- type SonarPaging
- type SonarProject
- type SonarProjectDetail
- type SonarProjectList
- type SonarScope
- type SonarService
- func (s *SonarService) Gate(ctx context.Context, project string, scope SonarScope) (*SonarGate, error)
- func (s *SonarService) Get(ctx context.Context, project string, scope SonarScope) (*SonarProjectDetail, error)
- func (s *SonarService) Issues(ctx context.Context, params SonarIssuesParams) (*SonarIssueList, error)
- func (s *SonarService) List(ctx context.Context, params SonarListParams) (*SonarProjectList, error)
- type Stage
- type TaskRunInfo
Constants ¶
const ( StatusSucceeded = "Succeeded" StatusFailed = "Failed" StatusTimeout = "Timeout" StatusCancelled = "Cancelled" StatusRunning = "Running" )
const ( QualityGateTypeAutotests = "autotests" QualityGateTypeManual = "manual" )
Variables ¶
var ( ErrNotFound = errors.New("resource not found") ErrHTTPSRequired = errors.New("portal URL must use HTTPS") )
Sentinel errors for portal API failures.
Functions ¶
func FetchOIDCConfig ¶ added in v0.5.0
FetchOIDCConfig calls the public /rest/v1/config/oidc endpoint (no auth) and returns the OIDC issuer URL for pre-login discovery. The portal URL must use HTTPS.
func IsFailureStatus ¶ added in v0.5.0
Types ¶
type ClusterConfig ¶ added in v0.5.0
type ClusterConfig struct {
ClusterName string `json:"clusterName"`
DefaultNamespace string `json:"defaultNamespace"`
}
ClusterConfig holds configuration returned by the authenticated config endpoint.
func FetchClusterConfig ¶ added in v0.5.0
func FetchClusterConfig(portalURL, token string) (*ClusterConfig, error)
FetchClusterConfig calls the authenticated /rest/v1/config endpoint and returns cluster name and default namespace. The portal URL must use HTTPS.
type Deployment ¶ added in v0.3.0
type Deployment struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Applications []string `json:"applications"`
StageNames []string `json:"stages"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Available bool `json:"available"`
}
Deployment represents a KubeRocketCI CDPipeline resource.
type DeploymentDetail ¶ added in v0.3.0
type DeploymentDetail struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Applications []string `json:"applications"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Available bool `json:"available"`
Stages []Stage `json:"stages"`
}
DeploymentDetail represents a CDPipeline with its associated Stages.
type DeploymentService ¶ added in v0.3.0
type DeploymentService struct {
// contains filtered or unexported fields
}
DeploymentService provides access to CDPipeline and Stage resources via the portal REST API.
func NewDeploymentService ¶ added in v0.3.0
func NewDeploymentService(client *restapi.ClientWithResponses, clusterName, namespace string) *DeploymentService
NewDeploymentService creates a DeploymentService for the given cluster and namespace.
func (*DeploymentService) Get ¶ added in v0.3.0
func (s *DeploymentService) Get(ctx context.Context, name string) (*DeploymentDetail, error)
Get returns a single CDPipeline with its Stages sorted by order.
func (*DeploymentService) List ¶ added in v0.3.0
func (s *DeploymentService) List(ctx context.Context) ([]Deployment, error)
List returns all CDPipelines with their stage names ordered by spec.order.
type PipelineRunFilter ¶ added in v0.4.0
type PipelineRunFilter struct {
Project string
PRNumber int
Author string
Branch string
Type string
Status string
}
PipelineRunFilter holds composable filter criteria for listing pipeline runs.
type PipelineRunGetOptions ¶ added in v0.4.0
PipelineRunGetOptions controls expansion for Get.
type PipelineRunInfo ¶ added in v0.4.0
type PipelineRunInfo struct {
Name string `json:"name"`
PortalURL string `json:"portalUrl,omitempty"`
Status string `json:"status"`
Pipeline string `json:"pipeline"`
Project string `json:"project"`
Branch string `json:"branch,omitempty"`
PRNumber string `json:"prNumber,omitempty"`
PRURL string `json:"prUrl,omitempty"`
Author string `json:"author,omitempty"`
Type string `json:"type,omitempty"`
StartTime string `json:"startTime"`
Duration string `json:"duration,omitempty"`
TargetBranch string `json:"targetBranch,omitempty"`
CommitSHA string `json:"commitSha,omitempty"`
}
type PipelineRunListOptions ¶ added in v0.4.0
type PipelineRunListOptions struct {
Filter PipelineRunFilter
IncludeLogs bool
IncludeReason bool
}
PipelineRunListOptions controls filtering and expansion for List.
type PipelineRunListResult ¶ added in v0.4.0
type PipelineRunListResult struct {
PipelineRuns []PipelineRunInfo `json:"pipelineRuns"`
Logs string `json:"logs,omitempty"`
Tasks []TaskRunInfo `json:"tasks,omitempty"`
}
type PipelineRunService ¶ added in v0.4.0
type PipelineRunService struct {
// contains filtered or unexported fields
}
PipelineRunService provides access to pipeline run data via the portal's REST API.
func NewPipelineRunService ¶ added in v0.4.0
func NewPipelineRunService( client *restapi.ClientWithResponses, portalURL, clusterName, namespace string, ) *PipelineRunService
NewPipelineRunService creates a PipelineRunService.
func (*PipelineRunService) Get ¶ added in v0.4.0
func (s *PipelineRunService) Get( ctx context.Context, name string, opts PipelineRunGetOptions, ) (*PipelineRunListResult, error)
Get returns a single pipeline run by name, checking K8s first (the only source for in-flight runs) and falling back to Tekton Results for completed pipelines.
func (*PipelineRunService) List ¶ added in v0.4.0
func (s *PipelineRunService) List( ctx context.Context, opts PipelineRunListOptions, ) (*PipelineRunListResult, error)
List returns both running (from K8s) and completed (from Tekton Results) pipeline runs, merged and deduplicated. Same unified view as the portal UI.
type Project ¶ added in v0.3.0
type Project struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Type string `json:"type"`
Language string `json:"language"`
BuildTool string `json:"buildTool"`
Framework string `json:"framework,omitempty"`
GitServer string `json:"gitServer"`
GitURL string `json:"gitUrl,omitempty"`
Status string `json:"status"`
Available bool `json:"available"`
}
Project represents a KubeRocketCI Codebase resource.
type ProjectService ¶ added in v0.3.0
type ProjectService struct {
// contains filtered or unexported fields
}
ProjectService provides access to Codebase resources via the portal REST API.
func NewProjectService ¶ added in v0.3.0
func NewProjectService(client *restapi.ClientWithResponses, clusterName, namespace string) *ProjectService
NewProjectService creates a ProjectService for the given cluster and namespace.
type QualityGate ¶ added in v0.3.0
QualityGate represents a quality gate step within a Stage.
type QualityGateStatus ¶ added in v0.8.0
type QualityGateStatus string
QualityGateStatus is the SonarQube quality-gate outcome. An unset gate (project never analyzed) maps to QualityGateNone.
const ( QualityGateOK QualityGateStatus = "OK" QualityGateWarn QualityGateStatus = "WARN" QualityGateError QualityGateStatus = "ERROR" QualityGateNone QualityGateStatus = "NONE" )
type SonarGate ¶ added in v0.8.0
type SonarGate struct {
ProjectStatus SonarGateProjectStatus `json:"projectStatus"`
}
SonarGate is the response for `krci sonar gate <project>`.
type SonarGateCondition ¶ added in v0.8.0
type SonarGateCondition struct {
MetricKey string `json:"metricKey"`
Comparator string `json:"comparator,omitempty"`
ErrorThreshold string `json:"errorThreshold,omitempty"`
ActualValue string `json:"actualValue,omitempty"`
Status QualityGateStatus `json:"status"`
}
SonarGateCondition is one row in the gate conditions table.
type SonarGateProjectStatus ¶ added in v0.8.0
type SonarGateProjectStatus struct {
Status QualityGateStatus `json:"status"`
Conditions []SonarGateCondition `json:"conditions"`
IgnoredConditions bool `json:"ignoredConditions,omitempty"`
}
SonarGateProjectStatus carries the overall + per-condition gate state. `Conditions` is always serialized as `[]` (never null) so scripting consumers can always range over it.
type SonarIssue ¶ added in v0.8.0
type SonarIssue struct {
Key string `json:"key"`
Rule string `json:"rule"`
Severity string `json:"severity"`
Type string `json:"type"`
Status string `json:"status"`
Component string `json:"component"`
Project string `json:"project"`
Line int `json:"line,omitempty"`
Message string `json:"message"`
Effort string `json:"effort,omitempty"`
Debt string `json:"debt,omitempty"`
Author string `json:"author,omitempty"`
CreationDate string `json:"creationDate"`
UpdateDate string `json:"updateDate,omitempty"`
Tags []string `json:"tags,omitempty"`
}
SonarIssue is one row in `krci sonar issues <project>`.
type SonarIssueList ¶ added in v0.8.0
type SonarIssueList struct {
Paging SonarPaging `json:"paging"`
Issues []SonarIssue `json:"issues"`
}
SonarIssueList is the response for `krci sonar issues <project>`. SonarQube's raw response duplicates pagination via both `total`/`p`/`ps` and a `paging` object; we only surface the structured `Paging` form.
type SonarIssuesParams ¶ added in v0.8.0
type SonarIssuesParams struct {
ProjectKey string
PullRequest string
Branch string
Types []string
Severities []string
Statuses []string
Resolved *bool
Sort string
Asc *bool
Page int
PageSize int
}
SonarIssuesParams carries the CLI-validated inputs for `krci sonar issues`. Types / Severities / Statuses are the already-validated enum values; the service joins them with commas when building the restapi query string. Resolved and Asc are `*bool`: nil means "let SonarQube apply its default", non-nil forwards the explicit value. PullRequest / Branch follow the same mutex rule as SonarScope.
type SonarListParams ¶ added in v0.8.0
SonarListParams carries the CLI-validated inputs for `krci sonar list`.
type SonarPaging ¶ added in v0.8.0
type SonarPaging struct {
PageIndex int `json:"pageIndex"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
}
SonarPaging is shared across paginated responses.
type SonarProject ¶ added in v0.8.0
type SonarProject struct {
Key string `json:"key"`
Name string `json:"name"`
Visibility string `json:"visibility,omitempty"`
LastAnalysisDate string `json:"lastAnalysisDate,omitempty"`
Revision string `json:"revision,omitempty"`
QualityGateStatus QualityGateStatus `json:"qualityGateStatus,omitempty"`
}
SonarProject is one entry in `krci sonar list`. `Qualifier` is an internal SonarQube discriminator (`TRK` for projects); we don't surface it. `Visibility` / `LastAnalysisDate` / `Revision` are best-effort optional fields — SonarQube's `/api/components/search` (the default non-admin endpoint) omits them, so they are typically absent.
type SonarProjectDetail ¶ added in v0.8.0
type SonarProjectDetail struct {
Key string `json:"key"`
Name string `json:"name"`
Visibility string `json:"visibility"`
LastAnalysisDate string `json:"lastAnalysisDate"`
Revision string `json:"revision"`
QualityGateStatus QualityGateStatus `json:"qualityGateStatus"`
Measures map[string]string `json:"measures"`
}
SonarProjectDetail is the response for `krci sonar get <project>`. All user-facing fields are always present (empty string when unknown) so downstream scripts can safely `jq .data.revision` without a `has` guard. `Qualifier` (SonarQube's internal `TRK` discriminator) is intentionally hidden.
type SonarProjectList ¶ added in v0.8.0
type SonarProjectList struct {
Projects []SonarProject `json:"projects"`
Paging SonarPaging `json:"paging"`
}
SonarProjectList is the response for `krci sonar list`.
type SonarScope ¶ added in v0.9.0
SonarScope narrows a Sonar query to a pull request OR a branch. The two fields are mutually exclusive at the SonarQube API layer; callers validate that invariant before handing the struct to the service.
type SonarService ¶ added in v0.8.0
type SonarService struct {
// contains filtered or unexported fields
}
SonarService wraps the generated restapi SonarList/SonarGet/SonarGate/SonarIssues methods and returns decoupled domain structs.
func NewSonarService ¶ added in v0.8.0
func NewSonarService(client *restapi.ClientWithResponses) *SonarService
NewSonarService creates a SonarService over the generated portal client.
func (*SonarService) Gate ¶ added in v0.8.0
func (s *SonarService) Gate(ctx context.Context, project string, scope SonarScope) (*SonarGate, error)
Gate calls `GET /rest/v1/sonar/gate`.
func (*SonarService) Get ¶ added in v0.8.0
func (s *SonarService) Get(ctx context.Context, project string, scope SonarScope) (*SonarProjectDetail, error)
Get calls `GET /rest/v1/sonar/get`. When a scope is supplied and upstream returns 404, the returned error message distinguishes between "pull request <id> not found" and "branch <name> not found".
func (*SonarService) Issues ¶ added in v0.8.0
func (s *SonarService) Issues(ctx context.Context, params SonarIssuesParams) (*SonarIssueList, error)
Issues calls `GET /rest/v1/sonar/issues`.
func (*SonarService) List ¶ added in v0.8.0
func (s *SonarService) List(ctx context.Context, params SonarListParams) (*SonarProjectList, error)
List calls `GET /rest/v1/sonar/list`.
type Stage ¶ added in v0.3.0
type Stage struct {
Name string `json:"name"`
Order int64 `json:"order"`
TriggerType string `json:"triggerType"`
QualityGates []QualityGate `json:"qualityGates"`
Namespace string `json:"namespace"`
ClusterName string `json:"clusterName,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Available bool `json:"available"`
}
Stage represents a KubeRocketCI Stage resource belonging to a CDPipeline.