Skip to content

Commit

Permalink
trim leading and trailing whitespace of all command line arguments (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
maplebed authored Jun 25, 2019
1 parent 051a4ec commit 8d79b87
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ func handleBuild(traceID, teamName, apiHost, dataset string) {
// command line eg: buildevents build $TRAVIS_BUILD_ID $BUILD_START success

name := "build " + traceID
startTime := os.Args[3]
buildStatus := os.Args[4]
startTime := strings.TrimSpace(os.Args[3])
buildStatus := strings.TrimSpace(os.Args[4])

secondsSinceEpoch, _ := strconv.ParseInt(strings.TrimSpace(startTime), 10, 64)
secondsSinceEpoch, _ := strconv.ParseInt(startTime, 10, 64)

startUnix := time.Unix(secondsSinceEpoch, 0)
sendTraceRoot(name, traceID, buildStatus, startUnix, time.Since(startUnix))
Expand Down Expand Up @@ -124,10 +124,10 @@ func printTraceURL(traceID, teamName, apiHost, dataset string, startUnix int64)
func handleStep() error {
// command line eg: buildevents step $TRAVIS_BUILD_ID $STAGE_SPAN_ID $STAGE_START script

parentSpanID := os.Args[2]
stepSpanID := os.Args[3]
startTime := os.Args[4]
name := os.Args[5]
parentSpanID := strings.TrimSpace(os.Args[2])
stepSpanID := strings.TrimSpace(os.Args[3])
startTime := strings.TrimSpace(os.Args[4])
name := strings.TrimSpace(os.Args[5])

secondsSinceEpoch, _ := strconv.ParseInt(strings.TrimSpace(startTime), 10, 64)

Expand All @@ -146,8 +146,8 @@ func handleCmd() error {
// command line eg: buildevents cmd $TRAVIS_BUILD_ID $STAGE_SPAN_ID go-test -- go test github.com/honeycombio/hound/...

// TODO include in readme warning about really needing positional argumenst to be correct
parentSpanID := os.Args[3]
name := os.Args[4]
parentSpanID := strings.TrimSpace(os.Args[3])
name := strings.TrimSpace(os.Args[4])
// arg[5] is the "--"

spanBytes := make([]byte, 16)
Expand Down Expand Up @@ -260,7 +260,7 @@ func main() {
}

// respond to ./buildevents --version
if os.Args[1] == "--version" {
if strings.TrimSpace(os.Args[1]) == "--version" {
fmt.Println(Version)
os.Exit(0)
}
Expand Down Expand Up @@ -292,8 +292,8 @@ func main() {
}
libhoney.AddField("meta.version", Version)

spanType := os.Args[1]
traceID := os.Args[2]
spanType := strings.TrimSpace(os.Args[1])
traceID := strings.TrimSpace(os.Args[2])

if ciProvider != "" {
libhoney.AddField("ci_provider", ciProvider)
Expand Down

0 comments on commit 8d79b87

Please sign in to comment.