Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
run: |
go get -v -t -d ./...

- name: Go Vet
run: go vet ./...

- name: Go Test
run: |
go run main.go --version
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters:
presets:
- bugs
8 changes: 6 additions & 2 deletions cmd/createbookmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ func CreateBookmark(signals chan os.Signal, ready chan bool) int {
}).Info("created bookmark excluded item")
}

b, _ := json.MarshalIndent(response.Msg.Bookmark.Properties, "", " ")
log.Info(string(b))
b, err := json.MarshalIndent(response.Msg.Bookmark.Properties, "", " ")
if err != nil {
log.Infof("Error rendering bookmark: %v", err)
} else {
log.Info(string(b))
}

return 0
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/getbookmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ func GetBookmark(signals chan os.Signal, ready chan bool) int {
}).Info("found bookmark excluded item")
}

b, _ := json.MarshalIndent(response.Msg.Bookmark.Properties, "", " ")
log.Info(string(b))
b, err := json.MarshalIndent(response.Msg.Bookmark.Properties, "", " ")
if err != nil {
log.Infof("Error rendering bookmark: %v", err)
} else {
log.Info(string(b))
}

return 0
}
Expand Down
9 changes: 7 additions & 2 deletions cmd/getchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ func GetChange(signals chan os.Signal, ready chan bool) int {

switch viper.GetString("format") {
case "json":
b, _ := json.MarshalIndent(response.Msg.Change, "", " ")
fmt.Println(string(b))
b, err := json.MarshalIndent(response.Msg.Change, "", " ")
if err != nil {
log.Errorf("Error rendering bookmark: %v", err)
return 1
} else {
fmt.Println(string(b))
}
case "markdown":
changeUrl := fmt.Sprintf("%v/changes/%v", viper.GetString("frontend"), changeUuid.String())
if response.Msg.Change.Metadata.NumAffectedApps != 0 || response.Msg.Change.Metadata.NumAffectedItems != 0 {
Expand Down
3 changes: 3 additions & 0 deletions cmd/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func Request(signals chan os.Signal, ready chan bool) int {
HTTPClient: NewAuthenticatedClient(ctx, otelhttp.DefaultClient),
}

// nolint: bodyclose // nhooyr.io/websocket reads the body internally
c, _, err := websocket.Dial(ctx, gatewayUrl, options)
if err != nil {
log.WithContext(ctx).WithFields(lf).WithError(err).Error("Failed to connect to overmind API")
Expand Down Expand Up @@ -197,6 +198,8 @@ responses:
statusFields["query"] = queryUuid

switch status.Status {
case sdp.QueryStatus_UNSPECIFIED:
statusFields["unexpected_status"] = true
case sdp.QueryStatus_STARTED:
activeQueries[*queryUuid] = true
case sdp.QueryStatus_FINISHED:
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func ensureToken(ctx context.Context, requiredScopes []string, signals chan os.S

// Start the webserver
log.WithContext(ctx).Trace("Starting webserver to listen for callback, press Ctrl+C to cancel")
srv := &http.Server{Addr: ":7837"}
srv := &http.Server{Addr: ":7837", ReadHeaderTimeout: 30 * time.Second}
http.HandleFunc("/oauth/callback", handler)

go func() {
Expand Down Expand Up @@ -192,18 +192,18 @@ func getChangeUuid(ctx context.Context, expectedStatus sdp.ChangeStatus, errNotF
if viper.GetString("uuid") != "" {
changeUuid, err = uuid.Parse(viper.GetString("uuid"))
if err != nil {
return uuid.Nil, fmt.Errorf("invalid --uuid value '%v', error: %v", viper.GetString("uuid"), err)
return uuid.Nil, fmt.Errorf("invalid --uuid value '%v', error: %w", viper.GetString("uuid"), err)
}
}

if viper.GetString("change") != "" {
changeUrl, err := url.ParseRequestURI(viper.GetString("change"))
if err != nil {
return uuid.Nil, fmt.Errorf("invalid --change value '%v', error: %v", viper.GetString("change"), err)
return uuid.Nil, fmt.Errorf("invalid --change value '%v', error: %w", viper.GetString("change"), err)
}
changeUuid, err = uuid.Parse(path.Base(changeUrl.Path))
if err != nil {
return uuid.Nil, fmt.Errorf("invalid --change value '%v', couldn't parse: %v", viper.GetString("change"), err)
return uuid.Nil, fmt.Errorf("invalid --change value '%v', couldn't parse: %w", viper.GetString("change"), err)
}
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/submitplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func SubmitPlan(signals chan os.Signal, ready chan bool) int {
}

log.WithContext(ctx).WithFields(lf).WithField("item_count", len(queries)).Info("identifying items")
// nolint: bodyclose // nhooyr.io/websocket reads the body internally
c, _, err := websocket.Dial(ctx, viper.GetString("gateway-url"), options)
if err != nil {
log.WithContext(ctx).WithFields(lf).WithError(err).Error("Failed to connect to overmind API")
Expand Down Expand Up @@ -399,6 +400,8 @@ func SubmitPlan(signals chan os.Signal, ready chan bool) int {
statusFields["query"] = queryUuid

switch status.Status {
case sdp.QueryStatus_UNSPECIFIED:
statusFields["unexpected_status"] = true
case sdp.QueryStatus_STARTED:
activeQueries[*queryUuid] = true
case sdp.QueryStatus_FINISHED:
Expand Down
1 change: 1 addition & 0 deletions tracing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func InitTracer(opts ...otlptracehttp.Option) error {
return nil
}

// nolint: contextcheck // deliberate use of local context to avoid getting tangled up in any existing timeouts or cancels
func ShutdownTracer() {
// Flush buffered events before the program terminates.
defer sentry.Flush(5 * time.Second)
Expand Down