diff --git a/aws.go b/aws.go index a80ae5f..bc65cf6 100644 --- a/aws.go +++ b/aws.go @@ -21,7 +21,7 @@ func getEC2Instances(config map[string]string) (instances Instances) { config["region"] = "us-east-1" } - auth := aws.Auth{config["access_key"], config["secret_key"]} + auth := aws.Auth{AccessKey: config["access_key"], SecretKey: config["secret_key"]} e := ec2.New(auth, aws.Regions[config["region"]]) resp, err := e.Instances(nil, nil) diff --git a/config.go b/config.go index 56193ae..64152a7 100644 --- a/config.go +++ b/config.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "gopkg.in/yaml.v1" + "gopkg.in/yaml.v1" "io/ioutil" "log" "os" diff --git a/main.go b/main.go index 640f5b1..aaccf82 100644 --- a/main.go +++ b/main.go @@ -6,10 +6,10 @@ import ( "os" "os/exec" "regexp" + "sort" "strconv" "strings" "sync" - "sort" ) type Tag struct { @@ -58,9 +58,10 @@ func getInstances(config Config) (clouds CloudInstances) { } type SortByTagValue []StrMap + func (a SortByTagValue) Len() int { return len(a) } func (a SortByTagValue) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a SortByTagValue) Less(i, j int) bool { return a[i]["tag_value"] < a[j]["tag_value"]} +func (a SortByTagValue) Less(i, j int) bool { return a[i]["tag_value"] < a[j]["tag_value"] } func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap) { // Fuzzy matching, like SublimeText @@ -74,7 +75,7 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap if rHost.MatchString(cloud + tag.Value) { matched = append(matched, StrMap{ "cloud": cloud, - "addr": addr, + "addr": addr, "tag_name": tag.Name, "tag_value": tag.Value, }) @@ -84,10 +85,10 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap } } } - + sort.Sort(SortByTagValue(matched)) - return + return } func formatMatchedInstance(inst StrMap) string { @@ -104,7 +105,7 @@ func main() { match := getMatchedInstances(instances, hostname) - var matched_instance map[string]string + var matched_instance map[string]string if len(match) == 0 { fmt.Println("Can't find cloud instance, trying to connect anyway") @@ -137,7 +138,7 @@ func main() { fmt.Println("Connecting to instance:") fmt.Println(formatMatchedInstance(matched_instance)) } - + if len(args) == 0 { args = append(args, joinHostname(user, hostname)) } else {