From 70fd3f47d0e1208ec005eb96a8f3d3b1e3bc8903 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Fri, 20 Jan 2023 23:52:27 +0200 Subject: [PATCH] Remove unused functions Signed-off-by: Gabriel Adrian Samfira --- .github/workflows/go-tests.yml | 8 +++++++- Makefile | 4 +++- auth/context.go | 14 -------------- auth/instance_middleware.go | 1 - auth/jwt.go | 1 - 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index e6ad1a1c..148c60de 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -8,6 +8,12 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +permissions: {} + jobs: linters: name: Linters @@ -48,4 +54,4 @@ jobs: - run: go version - name: Run GARM Go Tests - run: make test + run: make go-test diff --git a/Makefile b/Makefile index 218fdebd..b0385ac8 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,9 @@ build-static: @echo Binaries are available in $(PWD)/bin .PHONY: test -test: +test: verify go-test + +go-test: go test -race -mod=vendor -tags testing -v $(TEST_ARGS) -timeout=15m -parallel=4 -count=1 ./... fmtcheck: diff --git a/auth/context.go b/auth/context.go index ba1bf9cb..19da9582 100644 --- a/auth/context.go +++ b/auth/context.go @@ -157,20 +157,6 @@ func FullName(ctx context.Context) string { return name.(string) } -// SetJWTClaim will set the JWT claim in the context -func SetJWTClaim(ctx context.Context, claim JWTClaims) context.Context { - return context.WithValue(ctx, jwtTokenFlag, claim) -} - -// JWTClaim returns the JWT claim saved in the context -func JWTClaim(ctx context.Context) JWTClaims { - jwtClaim := ctx.Value(jwtTokenFlag) - if jwtClaim == nil { - return JWTClaims{} - } - return jwtClaim.(JWTClaims) -} - // SetIsEnabled sets a flag indicating if account is enabled func SetIsEnabled(ctx context.Context, enabled bool) context.Context { return context.WithValue(ctx, isEnabledFlag, enabled) diff --git a/auth/instance_middleware.go b/auth/instance_middleware.go index 562df07f..b8afd22a 100644 --- a/auth/instance_middleware.go +++ b/auth/instance_middleware.go @@ -155,7 +155,6 @@ func (amw *instanceMiddleware) Middleware(next http.Handler) http.Handler { return } - // ctx = SetJWTClaim(ctx, *claims) next.ServeHTTP(w, r.WithContext(ctx)) }) } diff --git a/auth/jwt.go b/auth/jwt.go index f96ae01b..8e098d24 100644 --- a/auth/jwt.go +++ b/auth/jwt.go @@ -128,7 +128,6 @@ func (amw *jwtMiddleware) Middleware(next http.Handler) http.Handler { return } - ctx = SetJWTClaim(ctx, *claims) next.ServeHTTP(w, r.WithContext(ctx)) }) }