Skip to content

Commit

Permalink
Merge pull request #5 from AudaxHealthInc/linting
Browse files Browse the repository at this point in the history
Linting
  • Loading branch information
buger committed Aug 20, 2014
2 parents d9367e5 + 9328aec commit a0536bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"gopkg.in/yaml.v1"
"gopkg.in/yaml.v1"
"io/ioutil"
"log"
"os"
Expand Down
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"os"
"os/exec"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"sort"
)

type Tag struct {
Expand Down Expand Up @@ -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
Expand All @@ -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,
})
Expand All @@ -84,10 +85,10 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap
}
}
}

sort.Sort(SortByTagValue(matched))

return
return
}

func formatMatchedInstance(inst StrMap) string {
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a0536bd

Please sign in to comment.