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 }