()
| 34 | } |
| 35 | |
| 36 | func (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))) |
nothing calls this directly
no test coverage detected