Adding outputFilename field to URI allowing user to pick a name to use for the downloaded artifact from the Mesos fetcher.
This commit is contained in:
parent
682cfd931b
commit
1944f6992a
4 changed files with 69 additions and 1 deletions
|
@ -152,6 +152,8 @@ struct MesosFetcherURI {
|
||||||
2: optional bool extract
|
2: optional bool extract
|
||||||
/** Cache value using Mesos Fetcher caching mechanism **/
|
/** Cache value using Mesos Fetcher caching mechanism **/
|
||||||
3: optional bool cache
|
3: optional bool cache
|
||||||
|
/** Filename for the resource that is downloaded **/
|
||||||
|
4: optional string outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ExecutorConfig {
|
struct ExecutorConfig {
|
||||||
|
|
|
@ -2564,10 +2564,12 @@ func (p *InstanceKey) String() string {
|
||||||
// - Value: Where to get the resource from
|
// - Value: Where to get the resource from
|
||||||
// - Extract: Extract compressed archive after downloading
|
// - Extract: Extract compressed archive after downloading
|
||||||
// - Cache: Cache value using Mesos Fetcher caching mechanism *
|
// - Cache: Cache value using Mesos Fetcher caching mechanism *
|
||||||
|
// - OutputFile: Filename for the resource that is downloaded *
|
||||||
type MesosFetcherURI struct {
|
type MesosFetcherURI struct {
|
||||||
Value string `thrift:"value,1" db:"value" json:"value"`
|
Value string `thrift:"value,1" db:"value" json:"value"`
|
||||||
Extract *bool `thrift:"extract,2" db:"extract" json:"extract,omitempty"`
|
Extract *bool `thrift:"extract,2" db:"extract" json:"extract,omitempty"`
|
||||||
Cache *bool `thrift:"cache,3" db:"cache" json:"cache,omitempty"`
|
Cache *bool `thrift:"cache,3" db:"cache" json:"cache,omitempty"`
|
||||||
|
OutputFile *string `thrift:"outputFile,4" db:"outputFile" json:"outputFile,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMesosFetcherURI() *MesosFetcherURI {
|
func NewMesosFetcherURI() *MesosFetcherURI {
|
||||||
|
@ -2592,6 +2594,13 @@ func (p *MesosFetcherURI) GetCache() bool {
|
||||||
}
|
}
|
||||||
return *p.Cache
|
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 {
|
func (p *MesosFetcherURI) IsSetExtract() bool {
|
||||||
return p.Extract != nil
|
return p.Extract != nil
|
||||||
}
|
}
|
||||||
|
@ -2600,6 +2609,10 @@ func (p *MesosFetcherURI) IsSetCache() bool {
|
||||||
return p.Cache != nil
|
return p.Cache != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *MesosFetcherURI) IsSetOutputFile() bool {
|
||||||
|
return p.OutputFile != nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error {
|
func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error {
|
||||||
if _, err := iprot.ReadStructBegin(); err != nil {
|
if _, err := iprot.ReadStructBegin(); err != nil {
|
||||||
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
|
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
|
||||||
|
@ -2643,6 +2656,16 @@ func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error {
|
||||||
return err
|
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:
|
default:
|
||||||
if err := iprot.Skip(fieldTypeId); err != nil {
|
if err := iprot.Skip(fieldTypeId); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -2685,6 +2708,15 @@ func (p *MesosFetcherURI) ReadField3(iprot thrift.TProtocol) error {
|
||||||
return nil
|
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 {
|
func (p *MesosFetcherURI) Write(oprot thrift.TProtocol) error {
|
||||||
if err := oprot.WriteStructBegin("MesosFetcherURI"); err != nil {
|
if err := oprot.WriteStructBegin("MesosFetcherURI"); err != nil {
|
||||||
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
|
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.writeField1(oprot); err != nil { return err }
|
||||||
if err := p.writeField2(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.writeField3(oprot); err != nil { return err }
|
||||||
|
if err := p.writeField4(oprot); err != nil { return err }
|
||||||
}
|
}
|
||||||
if err := oprot.WriteFieldStop(); err != nil {
|
if err := oprot.WriteFieldStop(); err != nil {
|
||||||
return thrift.PrependError("write field stop error: ", err) }
|
return thrift.PrependError("write field stop error: ", err) }
|
||||||
|
@ -2734,6 +2767,18 @@ func (p *MesosFetcherURI) writeField3(oprot thrift.TProtocol) (err error) {
|
||||||
return err
|
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 {
|
func (p *MesosFetcherURI) String() string {
|
||||||
if p == nil {
|
if p == nil {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
|
|
20
job.go
20
job.go
|
@ -51,6 +51,7 @@ type Job interface {
|
||||||
// will allow any owner to elect for a job to run on the host(s)
|
// will allow any owner to elect for a job to run on the host(s)
|
||||||
AddDedicatedConstraint(role, name string) Job
|
AddDedicatedConstraint(role, name string) Job
|
||||||
AddURIs(extract bool, cache bool, values ...string) Job
|
AddURIs(extract bool, cache bool, values ...string) Job
|
||||||
|
AddURI(extract bool, cache bool, outputFilename, value string) Job
|
||||||
JobKey() *aurora.JobKey
|
JobKey() *aurora.JobKey
|
||||||
JobConfig() *aurora.JobConfiguration
|
JobConfig() *aurora.JobConfiguration
|
||||||
TaskConfig() *aurora.TaskConfig
|
TaskConfig() *aurora.TaskConfig
|
||||||
|
@ -255,6 +256,25 @@ func (j *AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job {
|
||||||
return j
|
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
|
// 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.
|
// prefix "org.apache.aurora.metadata." to the beginning of each key.
|
||||||
func (j *AuroraJob) AddLabel(key string, value string) Job {
|
func (j *AuroraJob) AddLabel(key string, value string) Job {
|
||||||
|
|
|
@ -209,7 +209,8 @@ func TestRealisClient_CreateJob_Thermos(t *testing.T) {
|
||||||
Disk(50).
|
Disk(50).
|
||||||
IsService(true).
|
IsService(true).
|
||||||
InstanceCount(2).
|
InstanceCount(2).
|
||||||
AddPorts(1)
|
AddPorts(1).
|
||||||
|
AddURI(false, false, "test.version", "https://raw.githubusercontent.com/paypal/gorealis/master/.auroraversion")
|
||||||
|
|
||||||
_, err := r.CreateJob(job)
|
_, err := r.CreateJob(job)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue