Refactoring NewJob to use struct literals for clarity.
This commit is contained in:
parent
54378b2d8a
commit
7967270b3b
1 changed files with 19 additions and 16 deletions
35
job.go
35
job.go
|
@ -29,26 +29,29 @@ type AuroraJob struct {
|
||||||
|
|
||||||
// Create a AuroraJob object with everything initialized.
|
// Create a AuroraJob object with everything initialized.
|
||||||
func NewJob() *AuroraJob {
|
func NewJob() *AuroraJob {
|
||||||
jobConfig := aurora.NewJobConfiguration()
|
|
||||||
taskConfig := aurora.NewTaskConfig()
|
|
||||||
jobKey := aurora.NewJobKey()
|
|
||||||
|
|
||||||
// AuroraJob Config
|
jobKey := &aurora.JobKey{}
|
||||||
jobConfig.Key = jobKey
|
|
||||||
jobConfig.TaskConfig = taskConfig
|
|
||||||
|
|
||||||
// Task Config
|
// Task Config
|
||||||
taskConfig.Job = jobKey
|
taskConfig := &aurora.TaskConfig{
|
||||||
taskConfig.Container = aurora.NewContainer()
|
Job: jobKey,
|
||||||
taskConfig.Container.Mesos = aurora.NewMesosContainer()
|
MesosFetcherUris: make([]*aurora.MesosFetcherURI, 0),
|
||||||
taskConfig.MesosFetcherUris = make([]*aurora.MesosFetcherURI, 0)
|
Metadata: make([]*aurora.Metadata, 0),
|
||||||
taskConfig.Metadata = make([]*aurora.Metadata, 0)
|
Constraints: make([]*aurora.Constraint, 0),
|
||||||
taskConfig.Constraints = make([]*aurora.Constraint, 0)
|
// Container is a Union so one container field must be set. Set Mesos by default.
|
||||||
|
Container: NewMesosContainer().Build(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuroraJob Config
|
||||||
|
jobConfig := &aurora.JobConfiguration{
|
||||||
|
Key: jobKey,
|
||||||
|
TaskConfig: taskConfig,
|
||||||
|
}
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
numCpus := aurora.NewResource()
|
numCpus := &aurora.Resource{}
|
||||||
ramMb := aurora.NewResource()
|
ramMb := &aurora.Resource{}
|
||||||
diskMb := aurora.NewResource()
|
diskMb := &aurora.Resource{}
|
||||||
|
|
||||||
numCpus.NumCpus = new(float64)
|
numCpus.NumCpus = new(float64)
|
||||||
ramMb.RamMb = new(int64)
|
ramMb.RamMb = new(int64)
|
||||||
|
@ -78,7 +81,7 @@ func (j *AuroraJob) Environment(env string) *AuroraJob {
|
||||||
func (j *AuroraJob) Role(role string) *AuroraJob {
|
func (j *AuroraJob) Role(role string) *AuroraJob {
|
||||||
j.jobConfig.Key.Role = role
|
j.jobConfig.Key.Role = role
|
||||||
|
|
||||||
//Will be deprecated
|
// Will be deprecated
|
||||||
identity := &aurora.Identity{User: role}
|
identity := &aurora.Identity{User: role}
|
||||||
j.jobConfig.Owner = identity
|
j.jobConfig.Owner = identity
|
||||||
j.jobConfig.TaskConfig.Owner = identity
|
j.jobConfig.TaskConfig.Owner = identity
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue