Skip to content

Commit

Permalink
chore(lint): Format with goimports, enforce go mod tidy (salesforce#247)
Browse files Browse the repository at this point in the history
* chore(lint): Format with goimports

* chore(lint): Install goimports to avoid go.sum requirement

* chore(lint): Enforce goimports formatting and go mod tidy

* chore(ci): Remove Travis CI file, GHA used now
  • Loading branch information
kskewes-sf authored Dec 22, 2022
1 parent fdfea71 commit 2bfe114
Show file tree
Hide file tree
Showing 71 changed files with 189 additions and 142 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
go-version-file: go.mod

- name: Format with goimports
# TODO: Enforce when possible.
run: |
if [ "$(go run golang.org/x/tools/cmd/goimports -l --format-only . | wc -l)" -gt 0 ];
go install golang.org/x/tools/cmd/goimports@latest
if [ "$(goimports -l --format-only . | wc -l)" -gt 0 ];
then
go run golang.org/x/tools/cmd/goimports -l --format-only .
exit 0
goimports -l --format-only .
exit 1
fi
- name: Run go vet
Expand All @@ -42,10 +42,9 @@ jobs:
go test -v -race ./...
- name: Run go mod tidy
# TODO: Enforce when possible.
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum || true
git diff --exit-code -- go.mod go.sum
- name: Run go build
run: go build ./pkg/sloop/main.go
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion pkg/sloop/common/db_utilities_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package common

import (
"testing"

"github.com/dgraph-io/badger/v2"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"github.com/stretchr/testify/assert"
"testing"
)

var commonPrefix = "/commonprefix/001546405200/"
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/common/partition_utilities.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package common

import (
"sort"

"github.com/dgraph-io/badger/v2"
"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"sort"
)

type SloopKey struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/common/utilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package common

import (
"fmt"
"github.com/stretchr/testify/assert"
"path"
"testing"

"github.com/stretchr/testify/assert"
)

var files = []string{"webfiles/index.html", "webfiles/debug.html", "webfiles/filter.js", "webfiles/sloop.cs"}
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/ingress/fileplayback.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
package ingress

import (
"io/ioutil"

"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"io/ioutil"
)

func PlayFile(outChan chan typed.KubeWatchResult, filename string) error {
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/ingress/filerecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
package ingress

import (
"io/ioutil"
"sync"

"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"io/ioutil"
"sync"
)

type FileRecorder struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/ingress/kubeclient_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package ingress

import (
"testing"

"github.com/stretchr/testify/assert"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"testing"
)

func TestGetKubernetesContext(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/kubeextractor/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ package kubeextractor
import (
"encoding/json"
"fmt"
"github.com/golang/glog"
"strings"
"time"

"github.com/golang/glog"
)

// Example Event
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/kubeextractor/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
package kubeextractor

import (
"github.com/stretchr/testify/assert"
"testing"
"time"

"github.com/stretchr/testify/assert"
)

func Test_ExtractInvolvedObject_OutputCorrect(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/kubeextractor/kubeextractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
package kubeextractor

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func Test_ExtractMetadata_OutputCorrect(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/sloop/kubeextractor/nodededupe.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package kubeextractor

import (
"fmt"

"github.com/Jeffail/gabs/v2"
"github.com/pkg/errors"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/kubeextractor/nodededupe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ package kubeextractor
import (
"bytes"
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"text/template"

"github.com/stretchr/testify/assert"
)

const nodeTemplate = `{
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ package main

import (
"flag"
"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/server"
"os"
"runtime/pprof"

"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/server"
)

var cpuprofile = flag.String("cpuprofile", "", "write profile to file")
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/processing/eventcount.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
package processing

import (
"math"
"time"

"github.com/golang/glog"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/pkg/errors"
Expand All @@ -16,8 +19,6 @@ import (
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"math"
"time"
)

// TODO: We are only looking for the previous event in the current partiton, but we need to look back in cases where we cross the boundary
Expand Down
7 changes: 4 additions & 3 deletions pkg/sloop/processing/eventcount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ package processing

import (
"fmt"
"strings"
"testing"
"time"

"github.com/dgraph-io/badger/v2"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/timestamp"
Expand All @@ -17,9 +21,6 @@ import (
"github.com/salesforce/sloop/pkg/sloop/store/untyped"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"github.com/stretchr/testify/assert"
"strings"
"testing"
"time"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/processing/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
package processing

import (
"sync"
"time"

"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/salesforce/sloop/pkg/sloop/kubeextractor"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"sync"
"time"
)

type Runner struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/processing/resourcesummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
package processing

import (
"time"

"github.com/dgraph-io/badger/v2"
"github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
"github.com/salesforce/sloop/pkg/sloop/kubeextractor"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"time"
)

// TODO: Split this up and add unit tests
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/processing/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package processing

import (
"time"

"github.com/dgraph-io/badger/v2"
"github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
Expand All @@ -19,7 +21,6 @@ import (
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"time"
)

func getLastKubeWatchResult(tables typed.Tables, txn badgerwrap.Txn, ts *timestamp.Timestamp, kind string, namespace string, name string) (*typed.KubeWatchResult, error) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/processing/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
package processing

import (
"testing"
"time"

"github.com/dgraph-io/badger/v2"
"github.com/golang/protobuf/ptypes"
"github.com/salesforce/sloop/pkg/sloop/kubeextractor"
Expand All @@ -16,8 +19,6 @@ import (
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"github.com/salesforce/sloop/pkg/sloop/test/assertex"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

var someKind = "Pod"
Expand Down
3 changes: 2 additions & 1 deletion pkg/sloop/processing/watchactivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
package processing

import (
"time"

"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
"github.com/salesforce/sloop/pkg/sloop/kubeextractor"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"time"
)

func updateWatchActivityTable(tables typed.Tables, txn badgerwrap.Txn, watchRec *typed.KubeWatchResult, metadata *kubeextractor.KubeMetadata) error {
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/queries/eventquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ package queries
import (
"encoding/json"
"fmt"
"net/url"
"time"

"github.com/salesforce/sloop/pkg/sloop/kubeextractor"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"net/url"
"time"
)

type EventsData struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/queries/eventquery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
package queries

import (
"testing"
"time"

"github.com/dgraph-io/badger/v2"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"github.com/salesforce/sloop/pkg/sloop/test/assertex"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

const someRequestId = "someReqId"
Expand Down
5 changes: 3 additions & 2 deletions pkg/sloop/queries/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ package queries

import (
"fmt"
"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"net/url"
"time"

"github.com/golang/glog"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
)

// Takes in arguments from the web page, runs the query, and returns json
Expand Down
7 changes: 4 additions & 3 deletions pkg/sloop/queries/queryd3heatmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ package queries
import (
"encoding/json"
"fmt"
"net/url"
"sort"
"time"

"github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
"github.com/salesforce/sloop/pkg/sloop/kubeextractor"
"github.com/salesforce/sloop/pkg/sloop/store/typed"
"github.com/salesforce/sloop/pkg/sloop/store/untyped"
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
"net/url"
"sort"
"time"
)

const EmptyPartition = ""
Expand Down
Loading

0 comments on commit 2bfe114

Please sign in to comment.