portal

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	StatusSucceeded = "Succeeded"
	StatusFailed    = "Failed"
	StatusTimeout   = "Timeout"
	StatusCancelled = "Cancelled"
	StatusRunning   = "Running"
)
View Source
const (
	QualityGateTypeAutotests = "autotests"
	QualityGateTypeManual    = "manual"
)

Variables

View Source
var (
	ErrUnauthorized        = errors.New("unauthorized: please run 'krci auth login'")
	ErrNotFound            = errors.New("resource not found")
	ErrHTTPSRequired       = errors.New("portal URL must use HTTPS")
	ErrUpstreamUnavailable = errors.New("upstream service unavailable")

	// ErrDeploymentNotFound is returned when a CDPipeline (deployment)
	// look-up fails. Wraps ErrNotFound so callers using errors.Is for
	// generic not-found handling still match.
	ErrDeploymentNotFound = fmt.Errorf("deployment %w", ErrNotFound)

	// ErrEnvNotFound is returned when a Stage (env) lookup within a known
	// deployment fails. Wraps ErrNotFound similarly.
	ErrEnvNotFound = fmt.Errorf("environment %w", ErrNotFound)
)

Sentinel errors for portal API failures.

Functions

func FetchOIDCConfig added in v0.5.0

func FetchOIDCConfig(portalURL string) (string, error)

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

func IsFailureStatus(status string) bool

Types

type ArgoHealthStatus added in v0.12.0

type ArgoHealthStatus string

ArgoHealthStatus is one of ArgoCD's documented health-status values for an Application's `status.health.status` field. The CLI surfaces these in lowercase across `env get` and `project deployments`; renderers use the constants below to dispatch coloring without raw-string switches.

const (
	ArgoHealthHealthy     ArgoHealthStatus = "healthy"
	ArgoHealthDegraded    ArgoHealthStatus = "degraded"
	ArgoHealthMissing     ArgoHealthStatus = "missing"
	ArgoHealthProgressing ArgoHealthStatus = "progressing"
	ArgoHealthSuspended   ArgoHealthStatus = "suspended"
	ArgoHealthUnknown     ArgoHealthStatus = "unknown"
)

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 DeploymentByProjectService added in v0.12.0

type DeploymentByProjectService struct {
	// contains filtered or unexported fields
}

DeploymentByProjectService backs `krci project deployments <project>`. It fans out three concurrent k8s.list calls (Applications scoped to the project, Stages, CDPipelines) then joins them client-side.

func NewDeploymentByProjectService added in v0.12.0

func NewDeploymentByProjectService(
	client *restapi.ClientWithResponses,
	clusterName, namespace string,
) *DeploymentByProjectService

NewDeploymentByProjectService creates a service for the given cluster and namespace.

func (*DeploymentByProjectService) List added in v0.12.0

List returns one row per (deployment, env) pair where project is registered in the matching CDPipeline's spec.applications. Rows for stages without a matching Application carry deployed=false plus null dynamic fields (still surfacing static cluster/namespace/triggerType from the Stage so the user sees the full footprint). Stages and CDPipelines are fetched unscoped because the project-membership filter lives in CDPipeline.spec.applications, which has no equivalent label on Stage; the join is performed client-side.

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

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 EnvDetail added in v0.12.0

type EnvDetail struct {
	Deployment     string              `json:"deployment"`
	Env            string              `json:"env"`
	Status         string              `json:"status"`
	Description    *string             `json:"description"`
	Order          int                 `json:"order"`
	Infrastructure Infrastructure      `json:"infrastructure"`
	QualityGates   []QualityGateDetail `json:"qualityGates"`
	Projects       []EnvProject        `json:"projects"`
}

EnvDetail is the response for `krci env get <deployment> <env>`.

type EnvListFilters added in v0.12.0

type EnvListFilters struct {
	// Deployment is the parent CDPipeline name to filter by, or "" for all.
	Deployment string
	// Cluster is the post-mapping cluster filter, or "" for all.
	Cluster string
}

EnvListFilters bounds an `env list` query.

type EnvListPayload added in v0.12.0

type EnvListPayload struct {
	Stages []EnvSummary `json:"stages"`
}

EnvListPayload is the envelope `data` block for `krci env list`.

type EnvProject added in v0.12.0

type EnvProject struct {
	Name           string   `json:"name"`
	Status         *string  `json:"status"`
	Sync           *string  `json:"sync"`
	Version        *string  `json:"version"`
	ImageTag       *string  `json:"imageTag"`
	ImageDigest    *string  `json:"imageDigest"`
	IngressURLs    []string `json:"ingressUrls"`
	ArgocdURL      *string  `json:"argocdUrl"`
	DeployedAt     *string  `json:"deployedAt"`
	ValuesOverride *bool    `json:"valuesOverride"`
}

EnvProject is one row in EnvDetail.Projects.

type EnvService added in v0.12.0

type EnvService struct {
	// contains filtered or unexported fields
}

EnvService surfaces KRCI Stages as user-facing "environments".

func NewEnvService added in v0.12.0

func NewEnvService(client *restapi.ClientWithResponses, clusterName, namespace string) *EnvService

NewEnvService creates an EnvService for the given cluster and namespace.

func (*EnvService) Get added in v0.12.0

func (s *EnvService) Get(ctx context.Context, deployment, env string) (*EnvDetail, error)

Get returns the full detail of one stage. Fans out three k8s calls in parallel: list Stages (to resolve env-name → metadata.name), get parent CDPipeline (to enumerate registered apps), list Applications scoped to the (pipeline, stage) pair. The Application label `app.edp.epam.com/stage` carries `stage.spec.name` (the short identifier "dev"/"stage"/"prod"), not the compound resource name.

func (*EnvService) List added in v0.12.0

List returns every KRCI Stage in the configured namespace, optionally filtered by parent deployment and/or cluster. The returned slice is always non-nil so callers can JSON-marshal it as `[]` rather than `null`.

type EnvSummary added in v0.12.0

type EnvSummary struct {
	Deployment  string `json:"deployment"`
	Env         string `json:"env"`
	Cluster     string `json:"cluster"`
	Namespace   string `json:"namespace"`
	TriggerType string `json:"triggerType"`
	Status      string `json:"status"`
	Order       int    `json:"order"`
}

EnvSummary is one row in `krci env list`. The JSON envelope emits this slice under the wire-key "stages" (see EnvListPayload.Stages) to match the upstream Stage K8s resource; the Go-side name "EnvSummary" reflects the CLI's user-facing "environment" abstraction.

type Infrastructure added in v0.12.0

type Infrastructure struct {
	Cluster        string  `json:"cluster"`
	Namespace      string  `json:"namespace"`
	TriggerType    string  `json:"triggerType"`
	DeployPipeline string  `json:"deployPipeline"`
	CleanPipeline  *string `json:"cleanPipeline"`
}

Infrastructure carries the technical placement of an environment.

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

type PipelineRunGetOptions struct {
	IncludeLogs   bool
	IncludeReason bool
}

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

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

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 ProjectDeploymentRow added in v0.12.0

type ProjectDeploymentRow struct {
	Deployment  string   `json:"deployment"`
	Env         string   `json:"env"`
	Deployed    bool     `json:"deployed"`
	Status      *string  `json:"status"`
	Sync        *string  `json:"sync"`
	Version     *string  `json:"version"`
	ImageTag    *string  `json:"imageTag"`
	ImageDigest *string  `json:"imageDigest"`
	Cluster     string   `json:"cluster"`
	Namespace   string   `json:"namespace"`
	TriggerType string   `json:"triggerType"`
	DeployedAt  *string  `json:"deployedAt"`
	IngressURLs []string `json:"ingressUrls"`
	ArgocdURL   *string  `json:"argocdUrl"`
}

ProjectDeploymentRow is one row in `krci project deployments <project>`.

type ProjectDeploymentsPayload added in v0.12.0

type ProjectDeploymentsPayload struct {
	Project string                 `json:"project"`
	Rows    []ProjectDeploymentRow `json:"rows"`
}

ProjectDeploymentsPayload is the envelope `data` block for `krci project deployments <project>`.

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.

func (*ProjectService) Get added in v0.3.0

func (s *ProjectService) Get(ctx context.Context, name string) (*Project, error)

Get returns a single Codebase by name.

func (*ProjectService) List added in v0.3.0

func (s *ProjectService) List(ctx context.Context) ([]Project, error)

List returns all Codebases in the configured namespace.

type QualityGate added in v0.3.0

type QualityGate struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

QualityGate represents a quality gate step within a Stage.

type QualityGateDetail added in v0.12.0

type QualityGateDetail struct {
	Type         string  `json:"type"`
	StepName     string  `json:"stepName"`
	AutotestName *string `json:"autotestName"`
	BranchName   *string `json:"branchName"`
}

QualityGateDetail extends QualityGate with autotest + branch metadata surfaced in `krci env get`.

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 SCAComponent added in v0.10.0

type SCAComponent struct {
	UUID          string      `json:"uuid"`
	Name          string      `json:"name"`
	Version       string      `json:"version"`
	LatestVersion string      `json:"latestVersion,omitempty"`
	Outdated      bool        `json:"outdated,omitempty"`
	Group         string      `json:"group,omitempty"`
	License       string      `json:"license,omitempty"`
	IsInternal    bool        `json:"isInternal,omitempty"`
	RiskScore     float32     `json:"riskScore,omitempty"`
	Metrics       *SCAMetrics `json:"metrics,omitempty"`
}

SCAComponent is one row in `krci sca components`.

type SCAComponentList added in v0.10.0

type SCAComponentList struct {
	Status     SCAStatus      `json:"status"`
	Items      []SCAComponent `json:"items"`
	TotalCount int            `json:"totalCount"`
	Truncated  bool           `json:"truncated"`
}

SCAComponentList is the response for `krci sca components <codebase>`. Truncated signals that items and totalCount reflect an incomplete view because the Portal could not examine every dependency before paginating.

type SCAComponentsParams added in v0.10.0

type SCAComponentsParams struct {
	Codebase     string
	Branch       string
	Page         int
	PageSize     int
	OnlyOutdated bool
	OnlyDirect   bool
	Severity     []string
}

SCAComponentsParams carries the CLI-validated inputs for `krci sca components`. Severity holds the canonical upper-case Dep-Track severity set to filter by; empty slice means no filter.

type SCAFinding added in v0.10.0

type SCAFinding struct {
	Component     SCAFindingComponent     `json:"component"`
	Vulnerability SCAFindingVulnerability `json:"vulnerability"`
	Analysis      SCAFindingAnalysis      `json:"analysis"`
	Attribution   SCAFindingAttribution   `json:"attribution,omitempty"`
}

SCAFinding is one row in `krci sca findings`.

type SCAFindingAnalysis added in v0.10.0

type SCAFindingAnalysis struct {
	State        string `json:"state"`
	IsSuppressed bool   `json:"isSuppressed"`
}

SCAFindingAnalysis is the analysis side of one finding row.

type SCAFindingAttribution added in v0.10.0

type SCAFindingAttribution struct {
	AnalyzerIdentity string `json:"analyzerIdentity,omitempty"`
	AttributedOn     int64  `json:"attributedOn,omitempty"`
}

SCAFindingAttribution is the attribution side of one finding row.

type SCAFindingComponent added in v0.10.0

type SCAFindingComponent struct {
	UUID    string `json:"uuid"`
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
	Group   string `json:"group,omitempty"`
}

SCAFindingComponent is the component side of one finding row.

type SCAFindingList added in v0.10.0

type SCAFindingList struct {
	Status    SCAStatus    `json:"status"`
	Items     []SCAFinding `json:"items"`
	Truncated bool         `json:"truncated"`
}

SCAFindingList is the response for `krci sca findings <codebase>`.

type SCAFindingVulnerability added in v0.10.0

type SCAFindingVulnerability struct {
	VulnID          string  `json:"vulnId"`
	Source          string  `json:"source"`
	Severity        string  `json:"severity"`
	CvssV3BaseScore float32 `json:"cvssV3BaseScore,omitempty"`
	CvssV2BaseScore float32 `json:"cvssV2BaseScore,omitempty"`
}

SCAFindingVulnerability is the vulnerability side of one finding row.

type SCAFindingsParams added in v0.10.0

type SCAFindingsParams struct {
	Codebase          string
	Branch            string
	IncludeSuppressed bool
	Source            string
}

SCAFindingsParams carries the CLI-validated inputs for `krci sca findings`.

type SCAListParams added in v0.10.0

type SCAListParams struct {
	Page            int
	PageSize        int
	Search          string
	IncludeInactive bool
	IncludeChildren bool
}

SCAListParams carries the CLI-validated inputs for `krci sca list`.

type SCAMetrics added in v0.10.0

type SCAMetrics struct {
	Critical             int `json:"critical"`
	High                 int `json:"high"`
	Medium               int `json:"medium"`
	Low                  int `json:"low"`
	Unassigned           int `json:"unassigned"`
	Vulnerabilities      int `json:"vulnerabilities"`
	Components           int `json:"components,omitempty"`
	VulnerableComponents int `json:"vulnerableComponents,omitempty"`
}

SCAMetrics carries the vulnerability-count rollup for a project or component.

type SCAProject added in v0.10.0

type SCAProject struct {
	UUID                      string      `json:"uuid"`
	Name                      string      `json:"name"`
	Version                   string      `json:"version"`
	Classifier                string      `json:"classifier,omitempty"`
	Active                    bool        `json:"active,omitempty"`
	IsLatest                  bool        `json:"isLatest,omitempty"`
	LastBomImport             int64       `json:"lastBomImport,omitempty"`
	LastBomImportFormat       string      `json:"lastBomImportFormat,omitempty"`
	LastVulnerabilityAnalysis int64       `json:"lastVulnerabilityAnalysis,omitempty"`
	RiskScore                 float32     `json:"riskScore,omitempty"`
	Metrics                   *SCAMetrics `json:"metrics,omitempty"`
}

SCAProject is one row in `krci sca list` / the `project` member of `krci sca get`.

type SCAProjectDetail added in v0.10.0

type SCAProjectDetail struct {
	Status  SCAStatus   `json:"status"`
	Project *SCAProject `json:"project,omitempty"`
	Metrics *SCAMetrics `json:"metrics,omitempty"`
}

SCAProjectDetail is the response for `krci sca get <codebase>`. When Status is NONE, Project and Metrics are nil.

type SCAProjectList added in v0.10.0

type SCAProjectList struct {
	Items      []SCAProject `json:"items"`
	TotalCount int          `json:"totalCount"`
}

SCAProjectList is the response for `krci sca list`.

type SCAService added in v0.10.0

type SCAService struct {
	// contains filtered or unexported fields
}

SCAService wraps the generated restapi ScaList/ScaGet/ScaComponents/ScaFindings methods and returns decoupled domain structs.

func NewSCAService added in v0.10.0

func NewSCAService(client *restapi.ClientWithResponses) *SCAService

NewSCAService creates an SCAService over the generated portal client.

func (*SCAService) Components added in v0.10.0

func (s *SCAService) Components(ctx context.Context, params SCAComponentsParams) (*SCAComponentList, error)

Components returns the paginated dependency list for a codebase/branch pair.

func (*SCAService) Findings added in v0.10.0

func (s *SCAService) Findings(ctx context.Context, params SCAFindingsParams) (*SCAFindingList, error)

Findings returns the vulnerability findings for a codebase/branch pair. The Portal caps the server-side result at 1000 rows; when exceeded, Truncated is true.

func (*SCAService) Get added in v0.10.0

func (s *SCAService) Get(ctx context.Context, codebase, branch string) (*SCAProjectDetail, error)

Get returns the Dep-Track project overview for a codebase/branch pair. When no project is bound for the pair, Status is SCAStatusNone and Project / Metrics are nil.

func (*SCAService) List added in v0.10.0

func (s *SCAService) List(ctx context.Context, params SCAListParams) (*SCAProjectList, error)

List returns the paginated Dep-Track project listing.

type SCAStatus added in v0.10.0

type SCAStatus string

SCAStatus is the Dep-Track binding state for a (codebase, branch) pair. OK means a Dep-Track project exists; NONE means the codebase has no Dep-Track project for the requested branch — clients emit an empty payload and exit 0 in that case.

const (
	SCAStatusOK   SCAStatus = "OK"
	SCAStatusNone SCAStatus = "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

type SonarListParams struct {
	Page       int
	PageSize   int
	SearchTerm string
}

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

type SonarScope struct {
	PullRequest string
	Branch      string
}

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

Issues calls `GET /rest/v1/sonar/issues`.

func (*SonarService) List added in v0.8.0

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.

type TaskRunInfo added in v0.4.0

type TaskRunInfo struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Duration   string `json:"duration,omitempty"`
	FailedStep string `json:"failedStep,omitempty"`
	ExitCode   int    `json:"exitCode,omitempty"`
	Message    string `json:"message,omitempty"`
	Logs       string `json:"logs,omitempty"`
}

Directories

Path Synopsis
Package restapi provides primitives to interact with the openapi HTTP API.
Package restapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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