Skip to content

Commit

Permalink
Adding test coverage with agones
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Simpson committed Mar 21, 2024
1 parent 28f7474 commit 6cd0731
Show file tree
Hide file tree
Showing 6 changed files with 1,618 additions and 960 deletions.
15 changes: 9 additions & 6 deletions cmd/gamebackend/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"errors"
"os"

aapb "agones.dev/agones/pkg/allocation/go"
"agones.dev/agones/pkg/client/clientset/versioned"
"github.com/Nerzal/gocloak/v13"
"github.com/ShatteredRealms/go-backend/pkg/config"
"github.com/ShatteredRealms/go-backend/pkg/helpers"
Expand All @@ -18,6 +18,7 @@ import (
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"k8s.io/client-go/rest"
)

var (
Expand All @@ -29,8 +30,8 @@ type GameBackendServerContext struct {
CharacterClient pb.CharacterServiceClient
ChatClient pb.ChatServiceClient
GamebackendService service.GamebackendService
AgonesClient aapb.AllocationServiceClient
KeycloakClient *gocloak.GoCloak
AgonesClient versioned.Interface
Tracer trace.Tracer
}

Expand All @@ -49,10 +50,12 @@ func NewServerContext(ctx context.Context, conf *config.GlobalConfig) *GameBacke
helpers.Check(ctx, err, "connecting to chat")
server.ChatClient = pb.NewChatServiceClient(chatService)

if conf.GameBackend.Mode != config.LocalMode {
ac, err := helpers.GrpcClientWithOtel(conf.Agones.Allocator.Address())
helpers.Check(ctx, err, "connecting to agones")
server.AgonesClient = aapb.NewAllocationServiceClient(ac)
if server.GlobalConfig.GameBackend.Mode != config.LocalMode {
conf, err := rest.InClusterConfig()
helpers.Check(ctx, err, "creating config")

server.AgonesClient, err = versioned.NewForConfig(conf)
helpers.Check(ctx, err, "creating agones connection")
}

db, err := repository.ConnectDB(conf.GameBackend.Postgres)
Expand Down
Loading

0 comments on commit 6cd0731

Please sign in to comment.