From 46b6ad67e511723c273d78fbe0ba732ec02eb519 Mon Sep 17 00:00:00 2001 From: Kcrong Date: Wed, 4 Oct 2023 03:54:29 +0900 Subject: [PATCH] Update --- .golangci.yml | 9 --------- Makefile | 22 ++++++++++++---------- pkg/handler/captiveportal/auth_test.go | 3 ++- pkg/handler/route.go | 18 ------------------ 4 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 pkg/handler/route.go diff --git a/.golangci.yml b/.golangci.yml index 0f82517..f57739d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,10 +10,6 @@ run: # Default: 1m timeout: 3m - # Exit code when at least one issue was found. - # Default: 1 - issues-exit-code: 2 - # Include test files or not. # Default: true tests: true @@ -27,11 +23,6 @@ run: skip-dirs: - pkg/models - # Enables skipping of directories: - # - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - # Default: true - skip-dirs-use-default: true - # If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes diff --git a/Makefile b/Makefile index ff8c716..cf48b89 100644 --- a/Makefile +++ b/Makefile @@ -3,33 +3,33 @@ format: @#go install golang.org/x/tools/cmd/goimports@latest @#goimports -local "github.com/hodlgap/captive-portal" -w . @go install -v github.com/incu6us/goimports-reviser/v3@latest - goimports-reviser -rm-unused \ + @goimports-reviser -rm-unused \ -company-prefixes 'github.com/hodlgap' \ -excludes 'db' \ -project-name 'github.com/hodlgap/captive-portal' \ -format \ ./... - gofmt -s -w . - go mod tidy + @gofmt -s -w . + @go mod tidy .PHONY: lint lint: - golangci-lint run + @golangci-lint run -v ./... .PHONY: test test: @go install github.com/rakyll/gotest@latest - gotest -race -cover -v ./... + @gotest -race -cover -v ./... .PHONY: update update: @go get -u all - go mod tidy + @go mod tidy .PHONY: generate generate: @go install go.uber.org/mock/mockgen@latest - go generate ./... + @go generate ./... .PHONY: models models: @@ -42,12 +42,14 @@ models: .PHONY: dump-db dump-db: - # This dumps your local postgres to db/schema.sql - PGPASSWORD=example pg_dump --no-owner --schema-only --no-privileges --host=localhost --username=postgres --dbname=captive-portal > db/schema.sql + @# This dumps your local postgres to db/schema.sql + @PGPASSWORD=example pg_dump --no-owner --schema-only --no-privileges --host=localhost --username=postgres --dbname=captive-portal > db/schema.sql + echo "db/schema.sql" .PHONY: restore-db restore-db: # This restores your local postgres to db/schema.sql #PGPASSWORD=example psql --host=localhost --username=postgres --dbname=captive-portal -c "drop database if exists \"captive-portal\";" - PGPASSWORD=example psql -h localhost -U postgres -d captive-portal < db/schema.sql + @PGPASSWORD=example psql -h localhost -U postgres -d captive-portal < db/schema.sql + echo "Completed" diff --git a/pkg/handler/captiveportal/auth_test.go b/pkg/handler/captiveportal/auth_test.go index b3461fb..fab564f 100644 --- a/pkg/handler/captiveportal/auth_test.go +++ b/pkg/handler/captiveportal/auth_test.go @@ -5,7 +5,6 @@ import ( "crypto/cipher" "encoding/base64" "fmt" - "github.com/hodlgap/captive-portal/pkg/auth" "net/http" "net/http/httptest" "strings" @@ -15,6 +14,8 @@ import ( echo "github.com/labstack/echo/v4" "github.com/pkg/errors" "github.com/stretchr/testify/assert" + + "github.com/hodlgap/captive-portal/pkg/auth" ) // nolint:unused diff --git a/pkg/handler/route.go b/pkg/handler/route.go deleted file mode 100644 index 1e64dc0..0000000 --- a/pkg/handler/route.go +++ /dev/null @@ -1,18 +0,0 @@ -package handler - -import ( - "database/sql" - - echo "github.com/labstack/echo/v4" - - "github.com/hodlgap/captive-portal/pkg/auth" - "github.com/hodlgap/captive-portal/pkg/config" - "github.com/hodlgap/captive-portal/pkg/handler/captiveportal" -) - -func SetRoute(c config.Config, app *echo.Echo, authProvider auth.Provider, db *sql.DB) *echo.Echo { - app.GET(captiveportal.AuthHandlerURL, captiveportal.NewAuthHandler(c.Openwrt.EncryptionKey, authProvider, db)) - app.POST(captiveportal.AuthGetHandlerURL, captiveportal.NewAuthGetHandler(authProvider)) - - return app -}