Skip to content

Commit

Permalink
fix side effect on configYaml
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed Aug 7, 2017
1 parent d4b715e commit b81daf4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
44 changes: 44 additions & 0 deletions controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,50 @@ limits:
memory: "66Mi"
cpu: "2"
shutdownTimeout: 20
autoscaling:
min: 4
up:
delta: 3
trigger:
usage: 60
time: 100
cooldown: 200
down:
delta: 2
trigger:
usage: 30
time: 500
cooldown: 500
env:
- name: MY_ENV_VAR
value: myvalue
cmd:
- "./room"
`
var configYaml2 models.ConfigYAML
err := yaml.Unmarshal([]byte(yaml2), &configYaml2)
Expect(err).NotTo(HaveOccurred())
Expect(controller.MustUpdatePods(configYaml1, &configYaml2)).To(BeFalse())
})

It("should return false if delta is different", func() {
yaml2 := `
name: controller-name
game: controller
image: controller/controller:v123
affinity: maestro-dedicated
toleration: maestro
ports:
- containerPort: 1234
protocol: UDP
name: port1
- containerPort: 7654
protocol: TCP
name: port2
limits:
memory: "66Mi"
cpu: "2"
shutdownTimeout: 20
autoscaling:
min: 4
up:
Expand Down
2 changes: 1 addition & 1 deletion helm/charts/maestro/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: maestro
home: https://github.com/topfreegames/maestro
description: Maestro api and worker
version: 3.0.0
version: 3.0.1
maintainers:
- name: TFGCo
email: backend@tfgco.com
2 changes: 1 addition & 1 deletion metadata/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package metadata

//Version of Maestro
var Version = "3.0.0"
var Version = "3.0.1"

//KubeVersion is the desired Kubernetes version
var KubeVersion = "v1.7.0"
8 changes: 7 additions & 1 deletion models/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,14 @@ func (p *Pod) configureHostPorts(clientset kubernetes.Interface, redisClient red
if err != nil {
return err
}
podPorts := make([]*Port, len(ports))
for i, port := range ports {
p.Ports[i].HostPort = port
podPorts[i] = &Port{
ContainerPort: p.Ports[i].ContainerPort,
Name: p.Ports[i].Name,
HostPort: port,
}
}
p.Ports = podPorts
return nil
}
2 changes: 1 addition & 1 deletion models/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _ = Describe("Pod", func() {
},
{
ContainerPort: 8888,
HostPort: 5000,
HostPort: 5001,
},
}
limits = &models.Resources{
Expand Down
2 changes: 1 addition & 1 deletion models/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Port struct {
ContainerPort int `yaml:"containerPort" json:"containerPort" valid:"int64,required"`
Protocol string `yaml:"protocol" json:"protocol" valid:"required"`
Name string `yaml:"name" json:"name" valid:"required"`
HostPort int
HostPort int `yaml:"-" json:"-"`
}

func FreePortsRedisKey() string {
Expand Down

0 comments on commit b81daf4

Please sign in to comment.