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