From 81e75e5a9c7259ade46cfa835cc7808891125119 Mon Sep 17 00:00:00 2001 From: Vyacheslav1557 Date: Sat, 5 Oct 2024 21:05:29 +0500 Subject: [PATCH] fix: --- Makefile | 6 +++++- go.mod | 1 + go.sum | 4 ++++ internal/lib/config.go | 2 +- internal/services/contest.go | 2 +- internal/services/language.go | 2 +- internal/services/participants.go | 2 +- internal/services/permission.go | 2 +- internal/services/problem.go | 6 +++--- internal/services/solution.go | 2 +- internal/services/task.go | 2 +- internal/services/user.go | 2 +- internal/storage/contests.go | 2 +- internal/storage/language.go | 8 ++++---- internal/storage/participants.go | 2 +- internal/storage/problem.go | 2 +- internal/storage/solution.go | 2 +- internal/storage/task.go | 2 +- internal/storage/user.go | 2 +- internal/transport/interceptors.go | 2 +- internal/transport/problem.go | 2 +- internal/transport/server.go | 14 +++++++++----- 22 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index caa845b..4ee8e6c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +tag = latest + + gen: @buf generate dev: @@ -6,4 +9,5 @@ dev: build: @make gen - # TODO: build dockerfile + @docker build . -t ms-tester:${tag} + @#docker push ms-tester:${tag} diff --git a/go.mod b/go.mod index 7ca4a62..ec94a67 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( ) require ( + git.sch9.ru/new_gate/models v0.0.1 // indirect github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index 0c926cf..0c89821 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +git.sch9.ru/new_gate/models v0.0.0-20240923183834-466a81903af8 h1:PwRvUZ1iSZO1Na+0HXpjYiCgt5gxqh3aKbWtV64FDXk= +git.sch9.ru/new_gate/models v0.0.0-20240923183834-466a81903af8/go.mod h1:oLUfkN1hwclYTj8Y+br5ShZHLB4y2StRwf+mhc33NNc= +git.sch9.ru/new_gate/models v0.0.1 h1:VmRUUNNFrX1ZN26wuyfa5Z8il7VuIN49XjXsCtDQhLs= +git.sch9.ru/new_gate/models v0.0.1/go.mod h1:oLUfkN1hwclYTj8Y+br5ShZHLB4y2StRwf+mhc33NNc= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= diff --git a/internal/lib/config.go b/internal/lib/config.go index 91bd557..bf06cdb 100644 --- a/internal/lib/config.go +++ b/internal/lib/config.go @@ -3,7 +3,7 @@ package lib type Config struct { Env string `env:"ENV" env-default:"prod"` Pandoc string `env:"PANDOC" required:"true"` - Auth string `env:"PANDOC" required:"true"` + Auth string `env:"AUTH" required:"true"` Address string `env:"ADDRESS" required:"true"` PostgresDSN string `env:"POSTGRES_DSN" required:"true"` } diff --git a/internal/services/contest.go b/internal/services/contest.go index 194f300..c792fd8 100644 --- a/internal/services/contest.go +++ b/internal/services/contest.go @@ -2,8 +2,8 @@ package services import ( "context" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" ) type ContestStorage interface { diff --git a/internal/services/language.go b/internal/services/language.go index 6cd46bd..42db07f 100644 --- a/internal/services/language.go +++ b/internal/services/language.go @@ -2,7 +2,7 @@ package services import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" ) type LanguageStorage interface { diff --git a/internal/services/participants.go b/internal/services/participants.go index bfdf174..72eaebd 100644 --- a/internal/services/participants.go +++ b/internal/services/participants.go @@ -2,8 +2,8 @@ package services import ( "context" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" ) type ParticipantStorage interface { diff --git a/internal/services/permission.go b/internal/services/permission.go index 6d22dbe..59af1f8 100644 --- a/internal/services/permission.go +++ b/internal/services/permission.go @@ -2,7 +2,7 @@ package services import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/open-policy-agent/opa/rego" ) diff --git a/internal/services/problem.go b/internal/services/problem.go index 140bf68..e65a9d5 100644 --- a/internal/services/problem.go +++ b/internal/services/problem.go @@ -2,8 +2,8 @@ package services import ( "context" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" ) type ProblemStorage interface { @@ -30,12 +30,12 @@ type ProblemService struct { func NewProblemService( problemStorage ProblemStorage, pandocClient PandocClient, - permissionService IPermissionService, + permissionService IPermissionService, ) *ProblemService { return &ProblemService{ problemStorage: problemStorage, pandocClient: pandocClient, - permissionService: permissionService, + permissionService: permissionService, } } diff --git a/internal/services/solution.go b/internal/services/solution.go index 3089f0e..6d61013 100644 --- a/internal/services/solution.go +++ b/internal/services/solution.go @@ -2,8 +2,8 @@ package services import ( "context" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" ) type SolutionStorage interface { diff --git a/internal/services/task.go b/internal/services/task.go index 94465e4..401a22f 100644 --- a/internal/services/task.go +++ b/internal/services/task.go @@ -2,8 +2,8 @@ package services import ( "context" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" ) type TaskStorage interface { diff --git a/internal/services/user.go b/internal/services/user.go index cf80595..ecdec84 100644 --- a/internal/services/user.go +++ b/internal/services/user.go @@ -2,7 +2,7 @@ package services import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" ) type UserStorage interface { diff --git a/internal/storage/contests.go b/internal/storage/contests.go index 2ed0528..146bcd6 100644 --- a/internal/storage/contests.go +++ b/internal/storage/contests.go @@ -2,7 +2,7 @@ package storage import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/jmoiron/sqlx" "go.uber.org/zap" ) diff --git a/internal/storage/language.go b/internal/storage/language.go index 1903c1c..b8be4e2 100644 --- a/internal/storage/language.go +++ b/internal/storage/language.go @@ -2,7 +2,7 @@ package storage import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" "github.com/jmoiron/sqlx" "go.uber.org/zap" @@ -21,8 +21,8 @@ func NewLanguageStorage(db *sqlx.DB, logger *zap.Logger) *LanguageStorage { } func (storage *LanguageStorage) ReadLanguageById(ctx context.Context, id int32) (*models.Language, error) { - if(id<=int32(len(models.Languages))) { - return nil,lib.StorageError(nil,lib.ErrNotFound,"language not found") - } + if id <= int32(len(models.Languages)) { + return nil, lib.StorageError(nil, lib.ErrNotFound, "language not found") + } return &models.Languages[id], nil } diff --git a/internal/storage/participants.go b/internal/storage/participants.go index 664f23a..e703e18 100644 --- a/internal/storage/participants.go +++ b/internal/storage/participants.go @@ -2,7 +2,7 @@ package storage import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/jmoiron/sqlx" "go.uber.org/zap" ) diff --git a/internal/storage/problem.go b/internal/storage/problem.go index 6765964..4f7b52d 100644 --- a/internal/storage/problem.go +++ b/internal/storage/problem.go @@ -3,7 +3,7 @@ package storage import ( "context" "errors" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/jmoiron/sqlx" "go.uber.org/zap" ) diff --git a/internal/storage/solution.go b/internal/storage/solution.go index c50648c..88c1822 100644 --- a/internal/storage/solution.go +++ b/internal/storage/solution.go @@ -2,7 +2,7 @@ package storage import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/jmoiron/sqlx" "go.uber.org/zap" ) diff --git a/internal/storage/task.go b/internal/storage/task.go index 091d484..0e08fe4 100644 --- a/internal/storage/task.go +++ b/internal/storage/task.go @@ -2,7 +2,7 @@ package storage import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/jmoiron/sqlx" "go.uber.org/zap" ) diff --git a/internal/storage/user.go b/internal/storage/user.go index 69ea160..64a0172 100644 --- a/internal/storage/user.go +++ b/internal/storage/user.go @@ -2,7 +2,7 @@ package storage import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" "github.com/jmoiron/sqlx" ) diff --git a/internal/transport/interceptors.go b/internal/transport/interceptors.go index 7c36b96..fae667b 100644 --- a/internal/transport/interceptors.go +++ b/internal/transport/interceptors.go @@ -3,8 +3,8 @@ package transport import ( "context" "errors" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" sessionv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/session/v1" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/internal/transport/problem.go b/internal/transport/problem.go index ea3c396..ef5645d 100644 --- a/internal/transport/problem.go +++ b/internal/transport/problem.go @@ -2,8 +2,8 @@ package transport import ( "context" + "git.sch9.ru/new_gate/models" "git.sch9.ru/new_gate/ms-tester/internal/lib" - "git.sch9.ru/new_gate/ms-tester/pkg/models" problemv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/problem/v1" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/internal/transport/server.go b/internal/transport/server.go index 347eec8..2f87a62 100644 --- a/internal/transport/server.go +++ b/internal/transport/server.go @@ -2,7 +2,7 @@ package transport import ( "context" - "git.sch9.ru/new_gate/ms-tester/pkg/models" + "git.sch9.ru/new_gate/models" problemv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/problem/v1" sessionv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/proto/session/v1" "go.uber.org/zap" @@ -58,10 +58,14 @@ func NewTesterServer( } grpcServer := grpc.NewServer( - grpc.UnaryInterceptor(server.ErrUnwrappingUnaryInterceptor()), - grpc.StreamInterceptor(server.ErrUnwrappingStreamInterceptor()), - grpc.UnaryInterceptor(server.AuthUnaryInterceptor()), - grpc.StreamInterceptor(server.AuthStreamInterceptor()), + grpc.ChainUnaryInterceptor( + server.ErrUnwrappingUnaryInterceptor(), + server.AuthUnaryInterceptor(), + ), + grpc.ChainStreamInterceptor( + server.ErrUnwrappingStreamInterceptor(), + server.AuthStreamInterceptor(), + ), ) problemv1.RegisterProblemServiceServer(grpcServer, server)