Adding ability to add named ports to job configuration

This commit is contained in:
Renan DelValle 2016-08-10 11:59:04 -07:00
parent 7aa6c07c66
commit 403abcd684

18
job.go
View file

@ -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
}