Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
slartibaartfast authored Aug 14, 2018
2 parents 7ba5b5d + d5062ce commit 5f96c13
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# build
FROM golang:1.10.3 as builder
WORKDIR /go/src/simple-udp

COPY examples/simple-udp/main.go .
COPY . /go/src/agones.dev/agones
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server .

# final image
FROM alpine:3.7

RUN adduser -D server

COPY ./bin/server /home/server/server

COPY --from=builder /go/src/simple-udp/server /home/server/server
RUN chown -R server /home/server && \
chmod o+x /home/server/server

Expand Down
19 changes: 3 additions & 16 deletions examples/simple-udp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ REPOSITORY = gcr.io/agones-images
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
server_tag = $(REPOSITORY)/udp-server:0.3
package = agones.dev/agones/examples/simple-udp
root_path = $(realpath $(project_path)/../..)

# _____ _
# |_ _|_ _ _ __ __ _ ___| |_ ___
Expand All @@ -37,19 +37,6 @@ package = agones.dev/agones/examples/simple-udp
# |_|\__,_|_| \__, |\___|\__|___/
# |___/

# build both client and server
build: build-server build-client

# Build the server
build-server:
CGO_ENABLED=0 go build -o $(project_path)/server/bin/server -a -installsuffix cgo $(package)/server

# Build a docker image for the server, and tag it
build-server-image:
docker build $(project_path)/server/ --tag=$(server_tag)

# Build the client
build-client:
go build -o $(project_path)/client/bin/client $(package)/client


build:
cd $(root_path) && docker build -f $(project_path)/Dockerfile --tag=$(server_tag) .
8 changes: 3 additions & 5 deletions examples/simple-udp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simple UDP Server

A very simple UDP logging server and client, for the purposes of demoing and testing
A very simple UDP logging server, for the purposes of demoing and testing
running a UDP based server on Agones.

## Server
Expand All @@ -10,7 +10,5 @@ When it receives a text packet, it will send back "ACK:<text content>" as an ech

If it receives the text "EXIT", then it will `sys.Exit(0)`

## Client
Client will read in from stdin and send each line to the server.

Address defaults to `localhost:7654` but can be changed through the `address` flag.
To learn how to deploy your edited version of go server to gcp, please check out this link: [Edit Your First Game Server (Go)](../../../docs/edit_first_game_server.md),
or also look at the [`Makefile`](./Makefile).
85 changes: 0 additions & 85 deletions examples/simple-udp/client/main.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
1 change: 0 additions & 1 deletion examples/simple-udp/server/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions examples/simple-udp/server/gameserver-legacy.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/apis/stable/v1alpha1/fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestFleetGameServerSetGameServer(t *testing.T) {
Replicas: 10,
Template: GameServerTemplateSpec{
Spec: GameServerSpec{
GameServerPort: &GameServerPort{ContainerPort: 1234},
Ports: []GameServerPort{{ContainerPort: 1234}},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{{Name: "container", Image: "myimage"}},
Expand Down
11 changes: 0 additions & 11 deletions pkg/apis/stable/v1alpha1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ type GameServerSpec struct {
// Container specifies which Pod container is the game server. Only required if there is more than one
// container defined
Container string `json:"container,omitempty"`
// GameServerPort is deprecated, to be removed in 0.4.0:
*GameServerPort `json:",inline,omitempty"`
// Ports are the array of ports that can be exposed via the game server
Ports []GameServerPort `json:"ports"`
// Health configures health checking
Expand Down Expand Up @@ -178,7 +176,6 @@ func (gs *GameServer) ApplyDefaults() {
gs.ObjectMeta.Finalizers = append(gs.ObjectMeta.Finalizers, stable.GroupName)

gs.applyContainerDefaults()
gs.applyLegacyConversion()
gs.applyPortDefaults()
gs.applyStateDefaults()
gs.applyHealthDefaults()
Expand Down Expand Up @@ -216,14 +213,6 @@ func (gs *GameServer) applyStateDefaults() {
}
}

// applyLegacyConversion applies the legacy conversion
func (gs *GameServer) applyLegacyConversion() {
if gs.Spec.GameServerPort != nil {
gs.Spec.Ports = append(gs.Spec.Ports, *gs.Spec.GameServerPort)
gs.Spec.GameServerPort = nil
}
}

// applyPortDefaults applies default values for all ports
func (gs *GameServer) applyPortDefaults() {
for i, p := range gs.Spec.Ports {
Expand Down
28 changes: 16 additions & 12 deletions pkg/apis/stable/v1alpha1/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ func TestGameServerApplyDefaults(t *testing.T) {
gameServer: GameServer{
Spec: GameServerSpec{
Container: "testing2",
GameServerPort: &GameServerPort{
Ports: []GameServerPort{{
Protocol: "TCP",
PortPolicy: Static,
},
}},
Health: Health{
Disabled: false,
PeriodSeconds: 12,
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestGameServerApplyDefaults(t *testing.T) {
"set basic defaults on static gameserver": {
gameServer: GameServer{
Spec: GameServerSpec{
GameServerPort: &GameServerPort{PortPolicy: Static},
Ports: []GameServerPort{{PortPolicy: Static}},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "testing", Image: "testing/image"}}}}},
},
Expand Down Expand Up @@ -161,11 +161,13 @@ func TestGameServerApplyDefaults(t *testing.T) {
"convert from legacy single port to multiple": {
gameServer: GameServer{
Spec: GameServerSpec{
GameServerPort: &GameServerPort{
ContainerPort: 777,
HostPort: 777,
PortPolicy: Static,
Protocol: corev1.ProtocolTCP,
Ports: []GameServerPort{
{
ContainerPort: 777,
HostPort: 777,
PortPolicy: Static,
Protocol: corev1.ProtocolTCP,
},
},
Health: Health{Disabled: true},
Template: corev1.PodTemplateSpec{
Expand Down Expand Up @@ -235,10 +237,12 @@ func TestGameServerValidate(t *testing.T) {
func TestGameServerPod(t *testing.T) {
fixture := &GameServer{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default", UID: "1234"},
Spec: GameServerSpec{
GameServerPort: &GameServerPort{
ContainerPort: 7777,
HostPort: 9999,
PortPolicy: Static,
Ports: []GameServerPort{
{
ContainerPort: 7777,
HostPort: 9999,
PortPolicy: Static,
},
},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/stable/v1alpha1/gameserverset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestGameServerSetGameServer(t *testing.T) {
Replicas: 10,
Template: GameServerTemplateSpec{
Spec: GameServerSpec{
GameServerPort: &GameServerPort{ContainerPort: 1234},
Ports: []GameServerPort{{ContainerPort: 1234}},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{{Name: "container", Image: "myimage"}},
Expand All @@ -59,7 +59,7 @@ func TestGameServerSetValidateUpdate(t *testing.T) {
Spec: GameServerSetSpec{
Replicas: 10,
Template: GameServerTemplateSpec{
Spec: GameServerSpec{GameServerPort: &GameServerPort{ContainerPort: 1234}},
Spec: GameServerSpec{Ports: []GameServerPort{{ContainerPort: 1234}}},
},
},
}
Expand All @@ -74,7 +74,7 @@ func TestGameServerSetValidateUpdate(t *testing.T) {
assert.True(t, ok)
assert.Empty(t, causes)

newGSS.Spec.Template.Spec.ContainerPort = 321
newGSS.Spec.Template.Spec.Ports[0].ContainerPort = 321
ok, causes = gsSet.ValidateUpdate(newGSS)
assert.False(t, ok)
assert.Len(t, causes, 1)
Expand Down
9 changes: 0 additions & 9 deletions pkg/apis/stable/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5f96c13

Please sign in to comment.