Skip to content
Merged
24 changes: 16 additions & 8 deletions cli/cmd/project/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package project

import (
"fmt"
"strings"
"time"

"github.com/rilldata/rill/cli/pkg/cmdutil"
Expand Down Expand Up @@ -170,10 +171,11 @@ func StatusCmd(ch *cmdutil.Helper) *cobra.Command {
}

type resourceTableRow struct {
Type string `header:"type"`
Name string `header:"name"`
Status string `header:"status"`
Error string `header:"error"`
Type string `header:"type"`
Name string `header:"name"`
Status string `header:"status"`
Error string `header:"error"`
Warning string `header:"warning"`
}

func newResourceTableRow(r *runtimev1.Resource) *resourceTableRow {
Expand All @@ -182,11 +184,17 @@ func newResourceTableRow(r *runtimev1.Resource) *resourceTableRow {
truncErr = truncErr[:80] + "..."
}

truncWarn := strings.Join(r.Meta.ReconcileWarnings, "; ")
if len(truncWarn) > 80 {
truncWarn = truncWarn[:80] + "..."
}

return &resourceTableRow{
Type: runtime.PrettifyResourceKind(r.Meta.Name.Kind),
Name: r.Meta.Name.Name,
Status: runtime.PrettifyReconcileStatus(r.Meta.ReconcileStatus),
Error: truncErr,
Type: runtime.PrettifyResourceKind(r.Meta.Name.Kind),
Name: r.Meta.Name.Name,
Status: runtime.PrettifyReconcileStatus(r.Meta.ReconcileStatus),
Error: truncErr,
Warning: truncWarn,
}
}

Expand Down
42 changes: 23 additions & 19 deletions cli/cmd/sudo/project/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ func SearchCmd(ch *cmdutil.Helper) *cobra.Command {
}

type projectStatusTableRow struct {
Org string `header:"org"`
Project string `header:"project"`
DeploymentStatus string `header:"deployment"`
IdleCount int `header:"idle"`
PendingCount int `header:"pending"`
RunningCount int `header:"running"`
ReconcileErrorsCount int `header:"reconcile errors"`
ParseErrorsCount int `header:"parse errors"`
ParseWarningsCount int `header:"parse warnings"`
Org string `header:"org"`
Project string `header:"project"`
DeploymentStatus string `header:"deployment"`
IdleCount int `header:"idle"`
PendingCount int `header:"pending"`
RunningCount int `header:"running"`
ReconcileErrorsCount int `header:"reconcile errors"`
ReconcileWarningsCount int `header:"reconcile warnings"`
ParseErrorsCount int `header:"parse errors"`
ParseWarningsCount int `header:"parse warnings"`
}

func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, project string) (*projectStatusTableRow, error) {
Expand Down Expand Up @@ -179,7 +180,7 @@ func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, projec
var parser *runtimev1.Resource
var parseErrorsCount, parseWarningsCount int
var idleCount int
var reconcileErrorsCount int
var reconcileErrorsCount, reconcileWarningsCount int
var pendingCount int
var runningCount int

Expand All @@ -196,6 +197,8 @@ func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, projec
idleCount++
if r.Meta.GetReconcileError() != "" {
reconcileErrorsCount++
} else if len(r.Meta.ReconcileWarnings) > 0 {
reconcileWarningsCount++
}
case runtimev1.ReconcileStatus_RECONCILE_STATUS_PENDING:
pendingCount++
Expand Down Expand Up @@ -226,15 +229,16 @@ func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, projec
}

return &projectStatusTableRow{
Org: org,
Project: project,
DeploymentStatus: "OK",
IdleCount: idleCount,
PendingCount: pendingCount,
RunningCount: runningCount,
ReconcileErrorsCount: reconcileErrorsCount,
ParseErrorsCount: parseErrorsCount,
ParseWarningsCount: parseWarningsCount,
Org: org,
Project: project,
DeploymentStatus: "OK",
IdleCount: idleCount,
PendingCount: pendingCount,
RunningCount: runningCount,
ReconcileErrorsCount: reconcileErrorsCount,
ReconcileWarningsCount: reconcileWarningsCount,
ParseErrorsCount: parseErrorsCount,
ParseWarningsCount: parseWarningsCount,
}, nil
}

Expand Down
14 changes: 10 additions & 4 deletions cli/cmd/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ type ValidationResult struct {
}

type ValidationSummary struct {
TotalResources int `json:"total_resources"`
ParseErrors int `json:"parse_errors"`
ParseWarnings int `json:"parse_warnings"`
ReconcileErrors int `json:"reconcile_errors"`
TotalResources int `json:"total_resources"`
ParseErrors int `json:"parse_errors"`
ParseWarnings int `json:"parse_warnings"`
ReconcileErrors int `json:"reconcile_errors"`
ReconcileWarnings int `json:"reconcile_warnings"`
}

// ParseError represents a parse error (serializable version of runtimev1.ParseError)
Expand All @@ -45,6 +46,7 @@ type ResourceStatus struct {
Name string `json:"name" header:"name"`
Status string `json:"status" header:"status"`
Error string `json:"error" header:"error"`
Warning string `json:"warning" header:"warning"`
FilePath string `json:"file_path" header:"file_path"`
Timeout bool `json:"timeout" header:"timeout"`
}
Expand Down Expand Up @@ -220,6 +222,10 @@ func buildValidationResult(resources []*runtimev1.Resource) *ValidationResult {
resourceStatus.Timeout = true
}
}
if len(r.Meta.ReconcileWarnings) > 0 {
result.Summary.ReconcileWarnings++
resourceStatus.Warning = strings.Join(r.Meta.ReconcileWarnings, "; ")
}

result.Resources = append(result.Resources, resourceStatus)
}
Expand Down
Loading
Loading