From 6a80553d7b718044f86366b37cdb17b8055660ee Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Wed, 11 Feb 2015 13:20:51 -0800 Subject: [PATCH] Don't include port in config when not specified. When no port is specified the flag default of "-1" is taken. Fixes #4305 --- pkg/kubectl/run.go | 12 ++++++++---- pkg/kubectl/run_test.go | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/kubectl/run.go b/pkg/kubectl/run.go index 2fad5ced9e..3b8e69e1cf 100644 --- a/pkg/kubectl/run.go +++ b/pkg/kubectl/run.go @@ -79,10 +79,14 @@ func (BasicReplicationController) Generate(params map[string]string) (runtime.Ob if err != nil { return nil, err } - controller.Spec.Template.Spec.Containers[0].Ports = []api.Port{ - { - ContainerPort: port, - }, + + // Don't include the port if it was not specified. + if port > 0 { + controller.Spec.Template.Spec.Containers[0].Ports = []api.Port{ + { + ContainerPort: port, + }, + } } } return &controller, nil diff --git a/pkg/kubectl/run_test.go b/pkg/kubectl/run_test.go index a6efa35fbb..f009d81c4e 100644 --- a/pkg/kubectl/run_test.go +++ b/pkg/kubectl/run_test.go @@ -34,6 +34,7 @@ func TestGenerate(t *testing.T) { "name": "foo", "image": "someimage", "replicas": "1", + "port": "-1", }, expected: &api.ReplicationController{ ObjectMeta: api.ObjectMeta{