Skip to content

Commit 3523a64

Browse files
committed
feat(deployments): Add messages limit on deployments list
1 parent e00a870 commit 3523a64

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

pkg/koyeb/deployments_describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (r *DescribeDeploymentReply) Fields() []map[string]string {
7878
"id": renderer.FormatDeploymentID(r.mapper, item.GetId(), r.full),
7979
"service": renderer.FormatServiceSlug(r.mapper, item.GetServiceId(), r.full),
8080
"status": formatDeploymentStatus(item.GetStatus()),
81-
"messages": formatDeploymentMessages(item.GetMessages()),
81+
"messages": formatDeploymentMessages(item.GetMessages(), 0),
8282
"regions": renderRegions(item.Definition.Regions),
8383
"created_at": renderer.FormatTime(item.GetCreatedAt()),
8484
"updated_at": renderer.FormatTime(item.GetUpdatedAt()),

pkg/koyeb/deployments_get.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package koyeb
22

33
import (
4+
"fmt"
45
"strings"
56

67
"github.com/koyeb/koyeb-api-client-go/api/v1/koyeb"
@@ -54,7 +55,7 @@ func (r *GetDeploymentReply) Fields() []map[string]string {
5455
"id": renderer.FormatDeploymentID(r.mapper, item.GetId(), r.full),
5556
"service": renderer.FormatServiceSlug(r.mapper, item.GetServiceId(), r.full),
5657
"status": formatDeploymentStatus(item.GetStatus()),
57-
"messages": formatDeploymentMessages(item.GetMessages()),
58+
"messages": formatDeploymentMessages(item.GetMessages(), 0),
5859
"regions": renderRegions(item.Definition.Regions),
5960
"created_at": renderer.FormatTime(item.GetCreatedAt()),
6061
}
@@ -67,8 +68,12 @@ func formatDeploymentStatus(ds koyeb.DeploymentStatus) string {
6768
return string(ds)
6869
}
6970

70-
func formatDeploymentMessages(messages []string) string {
71-
return strings.Join(messages, " ")
71+
func formatDeploymentMessages(messages []string, max int) string {
72+
concat := strings.Join(messages, " ")
73+
if max == 0 || len(concat) < max {
74+
return concat
75+
}
76+
return fmt.Sprint(concat[:max], "...")
7277
}
7378

7479
func renderRegions(regions *[]string) string {

pkg/koyeb/deployments_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (r *ListDeploymentsReply) Fields() []map[string]string {
7272
"id": renderer.FormatDeploymentID(r.mapper, item.GetId(), r.full),
7373
"service": renderer.FormatServiceSlug(r.mapper, item.GetServiceId(), r.full),
7474
"status": formatDeploymentStatus(item.GetStatus()),
75-
"messages": formatDeploymentMessages(item.GetMessages()),
75+
"messages": formatDeploymentMessages(item.GetMessages(), 80),
7676
"regions": renderRegions(item.Definition.Regions),
7777
"created_at": renderer.FormatTime(item.GetCreatedAt()),
7878
}

0 commit comments

Comments
 (0)