diff --git a/auroraAPI.thrift b/auroraAPI.thrift index 3e43f6f..da7ca36 100644 --- a/auroraAPI.thrift +++ b/auroraAPI.thrift @@ -152,6 +152,8 @@ struct MesosFetcherURI { 2: optional bool extract /** Cache value using Mesos Fetcher caching mechanism **/ 3: optional bool cache + /** Filename for the resource that is downloaded **/ + 4: optional string outputFile } struct ExecutorConfig { diff --git a/gen-go/apache/aurora/auroraAPI.go b/gen-go/apache/aurora/auroraAPI.go index 849c381..88df8f7 100644 --- a/gen-go/apache/aurora/auroraAPI.go +++ b/gen-go/apache/aurora/auroraAPI.go @@ -2564,10 +2564,12 @@ func (p *InstanceKey) String() string { // - Value: Where to get the resource from // - Extract: Extract compressed archive after downloading // - Cache: Cache value using Mesos Fetcher caching mechanism * +// - OutputFile: Filename for the resource that is downloaded * type MesosFetcherURI struct { Value string `thrift:"value,1" db:"value" json:"value"` Extract *bool `thrift:"extract,2" db:"extract" json:"extract,omitempty"` Cache *bool `thrift:"cache,3" db:"cache" json:"cache,omitempty"` + OutputFile *string `thrift:"outputFile,4" db:"outputFile" json:"outputFile,omitempty"` } func NewMesosFetcherURI() *MesosFetcherURI { @@ -2592,6 +2594,13 @@ func (p *MesosFetcherURI) GetCache() bool { } return *p.Cache } +var MesosFetcherURI_OutputFile_DEFAULT string +func (p *MesosFetcherURI) GetOutputFile() string { + if !p.IsSetOutputFile() { + return MesosFetcherURI_OutputFile_DEFAULT + } +return *p.OutputFile +} func (p *MesosFetcherURI) IsSetExtract() bool { return p.Extract != nil } @@ -2600,6 +2609,10 @@ func (p *MesosFetcherURI) IsSetCache() bool { return p.Cache != nil } +func (p *MesosFetcherURI) IsSetOutputFile() bool { + return p.OutputFile != nil +} + func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error { if _, err := iprot.ReadStructBegin(); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) @@ -2643,6 +2656,16 @@ func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error { return err } } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } default: if err := iprot.Skip(fieldTypeId); err != nil { return err @@ -2685,6 +2708,15 @@ func (p *MesosFetcherURI) ReadField3(iprot thrift.TProtocol) error { return nil } +func (p *MesosFetcherURI) ReadField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.OutputFile = &v +} + return nil +} + func (p *MesosFetcherURI) Write(oprot thrift.TProtocol) error { if err := oprot.WriteStructBegin("MesosFetcherURI"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } @@ -2692,6 +2724,7 @@ func (p *MesosFetcherURI) Write(oprot thrift.TProtocol) error { if err := p.writeField1(oprot); err != nil { return err } if err := p.writeField2(oprot); err != nil { return err } if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField4(oprot); err != nil { return err } } if err := oprot.WriteFieldStop(); err != nil { return thrift.PrependError("write field stop error: ", err) } @@ -2734,6 +2767,18 @@ func (p *MesosFetcherURI) writeField3(oprot thrift.TProtocol) (err error) { return err } +func (p *MesosFetcherURI) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetOutputFile() { + if err := oprot.WriteFieldBegin("outputFile", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:outputFile: ", p), err) } + if err := oprot.WriteString(string(*p.OutputFile)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.outputFile (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:outputFile: ", p), err) } + } + return err +} + func (p *MesosFetcherURI) String() string { if p == nil { return "" diff --git a/job.go b/job.go index b614f95..779f46c 100644 --- a/job.go +++ b/job.go @@ -51,6 +51,7 @@ type Job interface { // will allow any owner to elect for a job to run on the host(s) AddDedicatedConstraint(role, name string) Job AddURIs(extract bool, cache bool, values ...string) Job + AddURI(extract bool, cache bool, outputFilename, value string) Job JobKey() *aurora.JobKey JobConfig() *aurora.JobConfiguration TaskConfig() *aurora.TaskConfig @@ -255,6 +256,25 @@ func (j *AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job { return j } +// AddURI adds a single URI to to fetch while the task is bootstrapping. Unlike AddURIs, this function allows +// the user to specify an outputFilename. If outputFilename is anything other than the empty string, the artifact +// downloaded will be renamed to the value provided by this string. +// --enable_mesos_fetcher flag enabled. There is currently no duplicate detection. +func (j *AuroraJob) AddURI(extract bool, cache bool, outputFilename, value string) Job { + resource := &aurora.MesosFetcherURI{ + Value: value, + Extract: &extract, + Cache: &cache, + } + + if outputFilename != "" { + resource.OutputFile = &outputFilename + } + + j.jobConfig.TaskConfig.MesosFetcherUris = append(j.jobConfig.TaskConfig.MesosFetcherUris, resource) + return j +} + // AddLabel adds a Mesos label to the job. Note that Aurora will add the // prefix "org.apache.aurora.metadata." to the beginning of each key. func (j *AuroraJob) AddLabel(key string, value string) Job { diff --git a/realis_e2e_test.go b/realis_e2e_test.go index bdfca72..e0b51d8 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -209,7 +209,8 @@ func TestRealisClient_CreateJob_Thermos(t *testing.T) { Disk(50). IsService(true). InstanceCount(2). - AddPorts(1) + AddPorts(1). + AddURI(false, false, "test.version", "https://raw.githubusercontent.com/paypal/gorealis/master/.auroraversion") _, err := r.CreateJob(job) require.NoError(t, err)