Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of the legacy port configuration #318

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.