mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-16 17:42:03 +00:00
feat(multiplayer): propagate allocated launch configuration
This commit is contained in:
@@ -172,6 +172,10 @@ func (c Client) Allocate(ctx context.Context, request domain.AllocationRequest,
|
||||
body.Spec.Metadata.Annotations = map[string]string{
|
||||
"cosmic-clash.io/match-id": request.MatchID,
|
||||
"cosmic-clash.io/allocation-id": request.AllocationID,
|
||||
"cosmic-clash.io/region": request.Region,
|
||||
"cosmic-clash.io/build": request.Build,
|
||||
"cosmic-clash.io/protocol": strconv.Itoa(request.Protocol),
|
||||
"cosmic-clash.io/transport": request.Transport,
|
||||
}
|
||||
if len(c.WorkloadSecret) > 0 {
|
||||
ttl := c.WorkloadTokenTTL
|
||||
|
||||
@@ -32,6 +32,12 @@ func TestAllocateBuildsStrictGameServerAllocationAndEndpoint(t *testing.T) {
|
||||
if body.Spec.Metadata.Annotations["cosmic-clash.io/match-id"] != "match-1" || body.Spec.Metadata.Annotations["cosmic-clash.io/allocation-id"] != "allocation-1" {
|
||||
t.Fatalf("allocation did not request match/allocation ID annotations on the GameServer: %+v", body.Spec.Metadata.Annotations)
|
||||
}
|
||||
want := map[string]string{"cosmic-clash.io/region": "EU", "cosmic-clash.io/build": "build-1", "cosmic-clash.io/protocol": "1", "cosmic-clash.io/transport": "enet"}
|
||||
for key, value := range want {
|
||||
if body.Spec.Metadata.Annotations[key] != value {
|
||||
t.Fatalf("annotation %s = %q, want %q", key, body.Spec.Metadata.Annotations[key], value)
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"status":{"state":"Allocated","gameServerName":"gs-a","address":"2001:db8::1","ports":[{"name":"default","port":7777}]}}`))
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user