From 403abcd68424c1dea2b4cb0afac974d455b4d97a Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Wed, 10 Aug 2016 11:59:04 -0700 Subject: [PATCH] Adding ability to add named ports to job configuration --- job.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/job.go b/job.go index 86f7796..4f24d2c 100644 --- a/job.go +++ b/job.go @@ -161,13 +161,27 @@ func (a *Job) AddLabel(key string, value string) *Job { return a } -// Adds a request for a number of ports to the job configuration. These are random ports as it's +// Add a named port to the job configuration These are random ports as it's // not currently possible to request specific ports using Aurora. +func (a *Job) AddNamedPorts(names ...string) *Job { + a.portCount += len(names) + for _, name := range names { + a.jobConfig.TaskConfig.Resources[&aurora.Resource{NamedPort: &name}] = true + } + + return a +} + + +// Adds a request for a number of ports to the job configuration. The names chosen for these ports +// will be org.apache.aurora.portX, where X is the current port count for the job configuration +// starting at 0. These are random ports as it's not currently possible to request +// specific ports using Aurora. func (a *Job) AddPorts(num int) *Job { start := a.portCount a.portCount += num for i := start; i < a.portCount; i++ { - portName := "port" + strconv.Itoa(i) + portName := "gorealis.port" + strconv.Itoa(i) a.jobConfig.TaskConfig.Resources[&aurora.Resource{NamedPort: &portName}] = true }