Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Update libraries, add module support, add dialog to suggest CODEOWNERS use #66

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7cfc6aa
Merge pull request #20 from capitalone/prepare-0.25.0
mspiegel Jan 31, 2018
01813b4
Merge pull request #22 from capitalone/dev
jonbodner Feb 6, 2018
1a299de
Merge branch 'dev' into 0.26.0-qa
mspiegel Feb 12, 2018
66ec5b2
Merge pull request #26 from capitalone/0.26.0-qa
mspiegel Feb 12, 2018
7793079
Merge branch 'qa' into 0.26.0-release
mspiegel Feb 13, 2018
81c0c58
Merge branch 'qa' into 0.26.0-release
mspiegel Feb 13, 2018
f1b2a7f
Merge pull request #27 from capitalone/0.26.0-release
mspiegel Feb 13, 2018
1fc08d0
Merge branch 'dev' into 0.27.0-qa
mspiegel Mar 15, 2018
af96831
Merge pull request #33 from capitalone/0.27.0-qa
mspiegel Mar 15, 2018
29fd3e2
Merge pull request #34 from capitalone/qa
mspiegel Mar 17, 2018
08eb91f
Prepare next release
mspiegel May 8, 2018
5212eb3
Merge branch 'dev' into qa-prepare-0.28
mspiegel Jul 25, 2018
7879a4a
Merge pull request #41 from capitalone/qa-prepare-0.28
jonbodner Jul 26, 2018
2e299c2
Merge branch 'qa' into 0.28.0-release
mspiegel Aug 22, 2018
c9032f3
Merge pull request #42 from capitalone/0.28.0-release
mspiegel Aug 31, 2018
1a903ec
Merge pull request #1 from capitalone/master
jonbodner Dec 24, 2018
3b83108
Merge branch 'master' into dev
jonbodner Mar 19, 2020
63004f7
update versions of dependencies. Fix to use latest github APIs.
jonbodner Mar 19, 2020
8c54d25
fix Makefile to use simpler tooling. Update additional dependencies.
jonbodner Mar 19, 2020
31a74fa
Merge pull request #1 from jonbodner/update_2020
Mar 30, 2020
f946191
Add .whitesource configuration file
Mar 30, 2020
48c7449
Merge pull request #2 from jonbodner/whitesource/configure
Mar 30, 2020
8dee5c1
put in placeholder TODOs
Mar 30, 2020
c1ba4e2
Include stackerr (#3)
Apr 1, 2020
c569b3a
Include stackerr as a whitesource test, update more dependencies, fix…
Apr 7, 2020
d17756c
Add codeowner dialog (#17)
Apr 8, 2020
a37f446
remove explicit branding, rely on environment variables (#18)
Apr 8, 2020
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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ checks-out.sqlite
.vscode
report.out
report.xml
*.iml
coverage.html
coverage.out
13 changes: 13 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"scanSettings": {
"configMode": "AUTO",
"configExternalURL": "",
"projectToken" : ""
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure"
},
"issueSettings": {
"minSeverityLevel": "LOW"
}
}
37 changes: 14 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ endif
# Propagate git revision number to version identifier
VERSION:=${VERSION_TAG}+$(shell git rev-parse --short HEAD)

# directories and remove vendor directory
# used for running unit tests
NOVENDOR := $(shell go list -e ./... | grep -v /vendor/)

# files and remove vendor directory, auto generated files, and mock files
# used for static analysis, code linting, and code formatting
NOVENDOR_FILES := $(shell find . -name "*.go" | grep -v /vendor/ | grep -v /mock/ | grep -v "_gen\.go" )

all: build

gen: gen-assets gen-migration
Expand All @@ -25,22 +17,26 @@ gen-assets:
gen-migration:
go generate github.com/capitalone/checks-out/store/migration

build:
build: test
@# static linking sqlite seems to break DNS
go build --ldflags '-X github.com/capitalone/checks-out/version.Version=$(VERSION)' -o checks-out
go test -run ^$$ $(NOVENDOR) > /dev/null

build-debug: test
@# static linking sqlite seems to break DNS
go build --ldflags '-X github.com/capitalone/checks-out/version.Version=$(VERSION)' -gcflags "all=-N -l" -o checks-out

test: vet
@# use redirect instead of tee to preserve exit code
go test -short -p=1 -cover $(NOVENDOR) -v > report.out; \
go test -short -cover -v ./... > report.out; \
code=$$?; \
cat report.out; \
grep -e 'FAIL' report.out; \
exit $${code}
.PHONY: test

test-complete: vet
@# use redirect instead of tee to preserve exit code
GITHUB_TEST_ENABLE=1 go test -short -p=1 -cover $(NOVENDOR) -v > report.out; \
GITHUB_TEST_ENABLE=1 go test -short -cover -v ./... > report.out; \
code=$$?; \
cat report.out; \
grep -e 'FAIL' report.out; \
Expand All @@ -49,24 +45,19 @@ test-complete: vet
.PHONY: test-cover-html

test-cover-html:
echo "mode: count" > coverage-all.out
echo "Packages: $(NOVENDOR)"
echo "VERSION: $(VERSION)"
$(foreach pkg,$(NOVENDOR), \
echo ${pkg}; \
go test -coverprofile=coverage.out -covermode=count ${pkg}; \
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o coverage.html
@echo "VERSION: $(VERSION)"
go test -coverprofile=coverage.out -covermode=count ./...
go tool cover -html=coverage.out -o coverage.html

fmt:
for FILE in $(NOVENDOR_FILES); do go fmt $$FILE; done;
go fmt ./...

vet: get-modules
@echo 'Running go tool vet -shadow'
@for FILE in $(NOVENDOR_FILES); do go tool vet -shadow $$FILE || exit 1; done;
go vet ./...

lint: get-modules
for FILE in $(NOVENDOR_FILES); do golint $$FILE; done;
golint ./...

clean:
rm -f checks-out report.out
Expand Down
2 changes: 1 addition & 1 deletion admin/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"context"
"fmt"

jsonpointer "github.com/mattn/go-jsonpointer"
"github.com/capitalone/checks-out/envvars"
"github.com/capitalone/checks-out/hjson"
"github.com/capitalone/checks-out/model"
"github.com/capitalone/checks-out/remote"
jsonpointer "github.com/mattn/go-jsonpointer"
)

var configFileName = fmt.Sprintf(".%s", envvars.Env.Branding.Name)
Expand Down
17 changes: 10 additions & 7 deletions api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ See the License for the specific language governing permissions and limitations
package api

import (
"errors"
"fmt"
"net/http"
"time"
Expand All @@ -32,22 +31,26 @@ import (
"github.com/capitalone/checks-out/shared/httputil"
"github.com/capitalone/checks-out/store"

"github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"github.com/jonbodner/stackerr"
"github.com/sirupsen/logrus"
)

const (
notAdmin = "user is not an administrator"
noAdminOrg = "GITHUB_ADMIN_ORG environment variable not defined"
)

func unauthorizedError() error {
status := http.StatusUnauthorized
msg := "user is not an administrator"
return exterror.Create(status, errors.New(msg))
return exterror.Create(status, stackerr.New(notAdmin))
}

func adminMissingError() error {
if envvars.Env.Github.AdminOrg == "" {
if envvars.Env.Monitor.Sunlight {
status := http.StatusUnauthorized
msg := "GITHUB_ADMIN_ORG environment variable not defined"
return exterror.Create(status, errors.New(msg))
return exterror.Create(status, stackerr.New(noAdminOrg))
}
return unauthorizedError()
}
Expand Down Expand Up @@ -126,7 +129,7 @@ func AdminDeleteRepo(c *gin.Context) {
httputil.GetURL(c.Request),
)

user, err := store.GetUser(c, repo.UserID)
user, err := store.GetUser(c, repo.UserID)
if err != nil {
msg := fmt.Sprintf("Deleting repository %s", name)
c.Error(exterror.Append(err, msg))
Expand Down
2 changes: 1 addition & 1 deletion api/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"bytes"
"encoding/json"

log "github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
)

func IndentedJSON(c *gin.Context, code int, obj interface{}) {
Expand Down
2 changes: 1 addition & 1 deletion api/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"github.com/capitalone/checks-out/shared/token"
"github.com/capitalone/checks-out/store"

"github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

func collectAllOrgs(c *gin.Context) ([]*model.GitHubOrg, set.Set, error) {
Expand Down
2 changes: 1 addition & 1 deletion api/orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import (
"github.com/capitalone/checks-out/router/middleware"
"github.com/capitalone/checks-out/store"

"github.com/Sirupsen/logrus"
"github.com/franela/goblin"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

type mockCache struct {
Expand Down
2 changes: 1 addition & 1 deletion api/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"github.com/capitalone/checks-out/shared/token"
"github.com/capitalone/checks-out/store"

"github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

// GetAllReposCount gets the count of all repositories managed by Checks-Out.
Expand Down
10 changes: 5 additions & 5 deletions api/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ See the License for the specific language governing permissions and limitations
package api

import (
"github.com/gin-gonic/gin"
"github.com/capitalone/checks-out/store"
"github.com/capitalone/checks-out/exterror"
"fmt"
"encoding/json"
"io/ioutil"
"fmt"
"github.com/capitalone/checks-out/exterror"
"github.com/capitalone/checks-out/router/middleware/session"
"github.com/capitalone/checks-out/store"
"github.com/gin-gonic/gin"
"io/ioutil"
)

type UrlHolder struct {
Expand Down
2 changes: 1 addition & 1 deletion api/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (

"github.com/capitalone/checks-out/model"

"github.com/Sirupsen/logrus"
"github.com/franela/goblin"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)

func TestUsers(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"context"
"time"

"github.com/koding/cache"
"github.com/capitalone/checks-out/envvars"
"github.com/koding/cache"
)

type Cache interface {
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"github.com/capitalone/checks-out/envvars"
gh "github.com/capitalone/checks-out/remote/github"

log "github.com/Sirupsen/logrus"
"github.com/google/go-github/github"
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion exterror/exterror.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"fmt"
"reflect"

log "github.com/Sirupsen/logrus"
"github.com/mspiegel/go-multierror"
log "github.com/sirupsen/logrus"
)

type ExtError struct {
Expand Down
81 changes: 37 additions & 44 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,52 +1,45 @@
module github.com/capitalone/checks-out

go 1.14

require (
github.com/BurntSushi/toml v0.3.0 // indirect
github.com/Sirupsen/logrus v0.11.5
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/dgrijalva/jwt-go v3.1.0+incompatible
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/franela/goblin v0.0.0-20170821161553-b962efd4bb2a
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect
github.com/gin-gonic/gin v0.0.0-20170702092826-d459835d2b07
github.com/go-sql-driver/mysql v1.3.0
github.com/golang/protobuf v0.0.0-20170920220647-130e6b02ab05 // indirect
github.com/google/go-github v0.0.0-20180723152927-e1be32f26e66
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect
github.com/hashicorp/go-version v0.0.0-20170914154128-fc61389e27c7
github.com/hjson/hjson-go v0.2.3
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db
github.com/gin-gonic/gin v1.6.2
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-sql-driver/mysql v1.5.0
github.com/golang/protobuf v1.3.5 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-github/v30 v30.1.0
github.com/hashicorp/go-version v1.2.0
github.com/hjson/hjson-go v3.0.1+incompatible
github.com/ianschenck/envflag v0.0.0-20140720210342-9111d830d133
github.com/joho/godotenv v1.2.0
github.com/joho/godotenv v1.3.0
github.com/jonbodner/stackerr v1.0.0
github.com/json-iterator/go v1.1.9 // indirect
github.com/koding/cache v0.0.0-20161222233015-e8a81b0b3f20
github.com/kr/pretty v0.1.0 // indirect
github.com/lib/pq v0.0.0-20171019223007-456514e2defe
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/mattn/go-jsonpointer v0.0.0-20170427002117-a39417dc2a77
github.com/mattn/go-sqlite3 v1.2.0
github.com/mspiegel/go-multierror v0.0.0-20170309222903-065aa648c994
github.com/pelletier/go-toml v1.0.1
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pkg/errors v0.8.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20180717144149-af8b230fcd20 // indirect
github.com/rubenv/sql-migrate v0.0.0-20170824124545-79fe99e24311
github.com/russross/meddler v0.0.0-20170319163028-9515f6b01c15
github.com/stretchr/objx v0.0.0-20150928122152-1a9d0bb9f541 // indirect
github.com/stretchr/testify v1.1.4
github.com/tinylib/msgp v1.0.2 // indirect
github.com/ugorji/go v0.0.0-20171019201919-bdcc60b419d1 // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
golang.org/x/net v0.0.0-20171019164906-aabf50738bcd // indirect
golang.org/x/oauth2 v0.0.0-20170928010508-bb50c06baba3
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
golang.org/x/sys v0.0.0-20171017063910-8dbc5d05d6ed // indirect
google.golang.org/appengine v1.0.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/lib/pq v1.3.0
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-jsonpointer v0.0.1
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/mspiegel/go-multierror v0.0.0-20171123200149-ea68e724609a
github.com/pelletier/go-toml v1.6.0
github.com/pkg/errors v0.9.1
github.com/rubenv/sql-migrate v0.0.0-20200401080106-baf4e4b6812c
github.com/russross/meddler v0.0.0-20191023082315-51a972bb8fb2
github.com/sirupsen/logrus v1.5.0
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.5.1
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 // indirect
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
gopkg.in/gorp.v1 v1.7.1 // indirect
gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528 // indirect
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)
Loading