Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Allow the usage of a string or int as a value in portMappings #455

Merged
merged 1 commit into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/examples/portMappings/mariadb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ containers:
value: wordpress
services:
- portMappings:
- 3306:3306/TCP
- 3306
type: NodePort
2 changes: 1 addition & 1 deletion pkg/spec/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func (deployment *DeploymentSpecMod) Unmarshal(data []byte) error {
err := yaml.Unmarshal(data, &deployment)
if err != nil {
return errors.Wrap(err, "could not unmarshal into internal struct")
return errors.Wrap(err, "Deployment could not unmarshal into internal struct")
}
log.Debugf("object unmarshalled: %#v\n", deployment)
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/spec/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (app *ControllerFields) createServices() ([]runtime.Object, error) {
}

for _, portMapping := range s.PortMappings {
servicePort, err := parsePortMapping(portMapping)
servicePort, err := parsePortMapping(portMapping.String())
if err != nil {
return nil, errors.Wrap(err, "unable to parse port mapping")
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/spec/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
image_v1 "github.com/openshift/origin/pkg/image/apis/image/v1"
os_route_v1 "github.com/openshift/origin/pkg/route/apis/route/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
api_v1 "k8s.io/kubernetes/pkg/api/v1"
batch_v1 "k8s.io/kubernetes/pkg/apis/batch/v1"
ext_v1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
Expand Down Expand Up @@ -63,7 +64,7 @@ type ServiceSpecMod struct {
// The list of portMappings, where each portMapping allows specifying port,
// targetPort and protocol in the format '<port>:<targetPort>/<protocol>'
// +optional
PortMappings []string `json:"portMappings,omitempty"`
PortMappings []intstr.IntOrString `json:"portMappings,omitempty"`
// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
meta_v1.ObjectMeta `json:",inline"`
}
Expand Down
11 changes: 11 additions & 0 deletions tests/cmd/portmappings/port-mixed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: database

containers:
- image: mariadb:10

services:
- name: database
portMappings:
- 80
- "3306"
- "3307"
9 changes: 9 additions & 0 deletions tests/cmd/portmappings/port-port.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: database

containers:
- image: mariadb:10

services:
- name: database
portMappings:
- 3306:3306
9 changes: 9 additions & 0 deletions tests/cmd/portmappings/port-string.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: database

containers:
- image: mariadb:10

services:
- name: database
portMappings:
- "3306"
9 changes: 9 additions & 0 deletions tests/cmd/portmappings/port.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: database

containers:
- image: mariadb:10

services:
- name: database
portMappings:
- 3306