-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
format.go
69 lines (60 loc) · 1.79 KB
/
format.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package ecspresso
import (
"fmt"
"strings"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
aasTypes "github.com/aws/aws-sdk-go-v2/service/applicationautoscaling/types"
logsTypes "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"
"github.com/aws/aws-sdk-go-v2/service/ecs/types"
)
var EventTimeFormat = "2006/01/02 15:04:05"
func formatDeployment(dp types.Deployment) string {
return fmt.Sprintf(
"%8s %s desired:%d pending:%d running:%d %s(%s)",
aws.ToString(dp.Status),
arnToName(aws.ToString(dp.TaskDefinition)),
dp.DesiredCount, dp.PendingCount, dp.RunningCount,
dp.RolloutState, aws.ToString(dp.RolloutStateReason),
)
}
func formatTaskSet(ts types.TaskSet) string {
return fmt.Sprintf(
"%8s %s desired:%d pending:%d running:%d %s",
aws.ToString(ts.Status),
arnToName(aws.ToString(ts.TaskDefinition)),
ts.ComputedDesiredCount, ts.PendingCount, ts.RunningCount,
ts.StabilityStatus,
)
}
func formatEvent(e types.ServiceEvent) string {
return fmt.Sprintf("%s %s",
e.CreatedAt.In(time.Local).Format(EventTimeFormat),
*e.Message,
)
}
func formatLogEvent(e logsTypes.OutputLogEvent) string {
t := time.Unix((*e.Timestamp / int64(1000)), 0)
return fmt.Sprintf("%s %s",
t.In(time.Local).Format(EventTimeFormat),
*e.Message,
)
}
func formatScalableTarget(t aasTypes.ScalableTarget) string {
return strings.Join([]string{
fmt.Sprintf(
spcIndent+"Capacity min:%d max:%d",
*t.MinCapacity,
*t.MaxCapacity,
),
fmt.Sprintf(
spcIndent+"Suspended in:%t out:%t scheduled:%t",
*t.SuspendedState.DynamicScalingInSuspended,
*t.SuspendedState.DynamicScalingOutSuspended,
*t.SuspendedState.ScheduledScalingSuspended,
),
}, "\n")
}
func formatScalingPolicy(p aasTypes.ScalingPolicy) string {
return fmt.Sprintf(" Policy name:%s type:%s", *p.PolicyName, p.PolicyType)
}