Skip to content

Commit

Permalink
Merge pull request #262 from werf/feat-improved-generic-progress-status
Browse files Browse the repository at this point in the history
feat: improved Generic progress status
  • Loading branch information
ilya-lesikov authored Jul 15, 2022
2 parents 88374bd + 5f68bca commit b46a5b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/tracker/indicators/indicators.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (indicator *StringEqualConditionIndicator) FormatTableElem(prevIndicator *S

func (indicator *StringEqualConditionIndicator) formatValue(withTargetValue bool) string {
if withTargetValue {
return fmt.Sprintf("%s / %s", indicator.Value, indicator.TargetValue)
return fmt.Sprintf("%s (%s)", indicator.Value, indicator.TargetValue)
} else {
return fmt.Sprintf("%s", indicator.Value)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/tracker/resid/resource_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (r *ResourceID) GroupVersionKindNameString() string {
return strings.Join([]string{r.GroupVersionKindString(), r.Name}, "/")
}

func (r *ResourceID) KindNameString() string {
return strings.Join([]string{r.GroupVersionKind.Kind, r.Name}, "/")
}

func (r *ResourceID) GroupVersionKindNamespaceString() string {
var resultElems []string

Expand Down
14 changes: 8 additions & 6 deletions pkg/trackers/rollout/multitrack/multitrack_display.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ func (mt *multitracker) displayDeploymentsStatusProgress() {
}

func (mt *multitracker) displayGenericsStatusProgress() {
t := utils.NewTable([]float64{.40, .20, .20, .20}...)
t := utils.NewTable([]float64{.43, .14, .43}...)
t.SetWidth(logboek.Context(context.Background()).Streams().ContentWidth() - 1)
t.Header("RESOURCE", "NAMESPACE", "CONDITION", "CURRENT / DESIRED CONDITION")
t.Header("RESOURCE", "NAMESPACE", "CONDITION: CURRENT (DESIRED)")

for _, resource := range mt.GenericResources {
var namespace string
Expand All @@ -589,7 +589,7 @@ func (mt *multitracker) displayGenericsStatusProgress() {

lastStatus := resource.State.LastStatus()
if lastStatus == nil {
resourceCaption := formatGenericResourceCaption(resource.Spec.ResourceID.GroupVersionKindNameString(), resource.Spec.FailMode, false, false, true)
resourceCaption := formatGenericResourceCaption(resource.Spec.ResourceID.KindNameString(), resource.Spec.FailMode, false, false, true)
t.Row(resourceCaption, namespace, "-", "-")
continue
}
Expand All @@ -607,7 +607,7 @@ func (mt *multitracker) displayGenericsStatusProgress() {
showProgress = true
}

resourceCaption := formatGenericResourceCaption(resource.Spec.ResourceID.GroupVersionKindNameString(), resource.Spec.FailMode, lastStatus.IsReady(), lastStatus.IsFailed(), true)
resourceCaption := formatGenericResourceCaption(resource.Spec.ResourceID.KindNameString(), resource.Spec.FailMode, lastStatus.IsReady(), lastStatus.IsFailed(), true)

var lastPrintedStatusIndicator *indicators.StringEqualConditionIndicator
if lastPrintedStatus != nil {
Expand Down Expand Up @@ -638,10 +638,12 @@ func (mt *multitracker) displayGenericsStatusProgress() {
humanConditionPath = "-"
}

condition := fmt.Sprintf("%s: %s", humanConditionPath, currentAndDesiredState)

if lastStatus.IsFailed() && lastStatus.FailureReason() != "" {
t.Row(resourceCaption, namespace, humanConditionPath, currentAndDesiredState, formatResourceError(disableWarningColors, lastStatus.FailureReason()))
t.Row(resourceCaption, namespace, condition, formatResourceError(disableWarningColors, lastStatus.FailureReason()))
} else {
t.Row(resourceCaption, namespace, humanConditionPath, currentAndDesiredState)
t.Row(resourceCaption, namespace, condition)
}

resource.State.SetLastPrintedStatus(lastStatus)
Expand Down

0 comments on commit b46a5b2

Please sign in to comment.