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

Method Run

commands/status/command.go:34–297  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34func (c *Command) Run() error {
35 c.awsClient = c.globalFlags.GetAWSClient()
36
37 appName := ""
38 clusterName := ""
39
40 // app configuration
41 configFilePath, err := c.globalFlags.GetConfigFile()
42 if err != nil {
43 return console.ExitWithError(err)
44 }
45 if utils.FileExists(configFilePath) {
46 configData, err := ioutil.ReadFile(configFilePath)
47 if err != nil {
48 return console.ExitWithErrorString("Failed to read configuration file [%s]: %s", configFilePath, err.Error())
49 }
50 conf, err := config.Load(configData, conv.S(c.globalFlags.ConfigFileFormat), core.DefaultAppName(configFilePath))
51 if err != nil {
52 return console.ExitWithError(err)
53 }
54
55 appName = conv.S(conf.Name)
56 clusterName = conv.S(conf.ClusterName)
57 }
58
59 // app/cluster name from CLI will override configuration file
60 if !utils.IsBlank(conv.S(c.commandFlags.AppName)) {
61 appName = conv.S(c.commandFlags.AppName)
62 }
63 if !utils.IsBlank(conv.S(c.commandFlags.ClusterName)) {
64 clusterName = conv.S(c.commandFlags.ClusterName)
65 }
66
67 if utils.IsBlank(appName) {
68 return console.ExitWithErrorString("App name is required.")
69 }
70 if utils.IsBlank(clusterName) {
71 return console.ExitWithErrorString("Cluster name is required.")
72 }
73
74 console.Info("Application")
75 console.DetailWithResource("Name", appName)
76 console.DetailWithResource("Cluster", clusterName)
77
78 // AWS networking
79 regionName, vpcID, err := c.globalFlags.GetAWSRegionAndVPCID()
80 if err != nil {
81 return console.ExitWithError(err)
82 }
83 subnetIDs, err := c.awsClient.EC2().ListVPCSubnets(vpcID)
84 if err != nil {
85 return console.ExitWithErrorString("Failed to list subnets for VPC [%s]: %s", vpcID, err.Error())
86 }
87
88 // AWS env
89 console.Info("AWS")
90 console.DetailWithResource("Region", regionName)
91 console.DetailWithResource("VPC", vpcID)

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

GetAWSClientMethod · 0.80
GetConfigFileMethod · 0.80
ErrorMethod · 0.80
GetAWSRegionAndVPCIDMethod · 0.80
ListVPCSubnetsMethod · 0.80
EC2Method · 0.80
RetrieveClusterMethod · 0.80
ECSMethod · 0.80
RetrieveServiceMethod · 0.80
ListServiceTaskARNsMethod · 0.80
RetrieveTasksMethod · 0.80

Tested by

no test coverage detected