MCPcopy Create free account
hub / github.com/coldbrewcloud/coldbrew-cli / Run

Method Run

commands/clusterstatus/command.go:36–233  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36func (c *Command) Run() error {
37 c.awsClient = c.globalFlags.GetAWSClient()
38
39 // AWS networking
40 regionName, vpcID, subnetIDs, err := c.getAWSInfo()
41 if err != nil {
42 return console.ExitWithError(err)
43 }
44
45 // cluster name
46 clusterName := strings.TrimSpace(conv.S(c.clusterNameArg))
47 if !core.ClusterNameRE.MatchString(clusterName) {
48 return console.ExitWithError(core.NewErrorExtraInfo(
49 fmt.Errorf("Invalid cluster name [%s]", clusterName), "https://github.com/coldbrewcloud/coldbrew-cli/wiki/Configuration-File#cluster"))
50 }
51
52 console.Info("Cluster")
53 console.DetailWithResource("Name", clusterName)
54
55 // AWS env
56 console.Info("AWS")
57 console.DetailWithResource("Region", regionName)
58 console.DetailWithResource("VPC", vpcID)
59 console.DetailWithResource("Subnets", strings.Join(subnetIDs, " "))
60
61 // ECS
62 console.Info("ECS")
63 showECSClusterDetails := false
64
65 // ecs cluster
66 ecsClusterName := core.DefaultECSClusterName(clusterName)
67 ecsCluster, err := c.awsClient.ECS().RetrieveCluster(ecsClusterName)
68 if err != nil {
69 return console.ExitWithErrorString("Failed to retrieve ECS Cluster [%s]: %s", ecsClusterName, err.Error())
70 }
71 if ecsCluster == nil || conv.S(ecsCluster.Status) == "INACTIVE" {
72 console.DetailWithResourceNote("ECS Cluster", ecsClusterName, "(not found)", true)
73 ecsCluster = nil
74 } else {
75 console.DetailWithResource("ECS Cluster", ecsClusterName)
76 showECSClusterDetails = true
77 }
78
79 // ecs service role
80 ecsServiceRoleName := core.DefaultECSServiceRoleName(clusterName)
81 ecsServiceRole, err := c.awsClient.IAM().RetrieveRole(ecsServiceRoleName)
82 if err != nil {
83 return console.ExitWithErrorString("Failed to retrieve IAM Role [%s]: %s", ecsServiceRoleName, err.Error())
84 }
85 if ecsServiceRole == nil {
86 console.DetailWithResourceNote("IAM Role for ECS Services", ecsServiceRoleName, "(not found)", true)
87 } else {
88 console.DetailWithResource("IAM Role for ECS Services", ecsServiceRoleName)
89 }
90
91 // ecs cluster details
92 if showECSClusterDetails {
93 console.DetailWithResource("ECS Services", conv.I64S(conv.I64(ecsCluster.ActiveServicesCount)))

Callers

nothing calls this directly

Implementers 8

Commandcommands/clusterstatus/command.go
Commandcommands/deploy/command.go
Commandcommands/clusterdelete/command.go
Commandcommands/delete/command.go
Commandcommands/clustercreate/command.go
Commandcommands/create/command.go
Commandcommands/clusterscale/command.go
Commandcommands/status/command.go

Calls 15

getAWSInfoMethod · 0.95
GetAWSClientMethod · 0.80
RetrieveClusterMethod · 0.80
ECSMethod · 0.80
ErrorMethod · 0.80
RetrieveRoleMethod · 0.80
IAMMethod · 0.80
AutoScalingMethod · 0.80
EC2Method · 0.80

Tested by

no test coverage detected