Skip to content

Commit fd3cfcf

Browse files
author
Gergely Brautigam
committed
Working on outputs for jobs
1 parent ed1ca01 commit fd3cfcf

File tree

11 files changed

+219
-56
lines changed

11 files changed

+219
-56
lines changed

gaia.go

+7
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ type Job struct {
219219
Status JobStatus `json:"status,omitempty"`
220220
Args []*Argument `json:"args,omitempty"`
221221
FailPipeline bool `json:"failpipeline,omitempty"`
222+
Outs []*Output `json:"outs,omitempty"`
222223
}
223224

224225
// Argument represents a single argument of a job
@@ -229,6 +230,12 @@ type Argument struct {
229230
Value string `json:"value,omitempty"`
230231
}
231232

233+
// Output represents a single output of a job
234+
type Output struct {
235+
Key string `json:"key,omitempty"`
236+
Value string `json:"value,omitempty"`
237+
}
238+
232239
// CreatePipeline represents a pipeline which is not yet
233240
// compiled.
234241
type CreatePipeline struct {

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ require (
55
github.com/GeertJohan/go.rice v1.0.0
66
github.com/Microsoft/go-winio v0.4.14 // indirect
77
github.com/Pallinder/go-randomdata v1.1.0
8+
github.com/Skarlso/protobuf v0.0.0-20200307140829-e2fe748a72a5
89
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 // indirect
910
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
1011
github.com/boltdb/bolt v1.3.1 // indirect
@@ -62,3 +63,5 @@ require (
6263
gopkg.in/yaml.v2 v2.2.2
6364
gotest.tools v2.2.0+incompatible // indirect
6465
)
66+
67+
go 1.13

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+q
99
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
1010
github.com/Pallinder/go-randomdata v1.1.0 h1:gUubB1IEUliFmzjqjhf+bgkg1o6uoFIkRsP3VrhEcx8=
1111
github.com/Pallinder/go-randomdata v1.1.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y=
12+
github.com/Skarlso/protobuf v0.0.0-20180812091451-7be8a901b55a h1:4HqYngkMAP3NjNrDoLMeUL+UWAhSb1Y2NucsOSHAUeM=
13+
github.com/Skarlso/protobuf v0.0.0-20180812091451-7be8a901b55a/go.mod h1:D/ResgH7nQRyfO3W9YadC7oTWlF9M5YSGvbrRebmLhg=
14+
github.com/Skarlso/protobuf v0.0.0-20200307130307-c786b2468c2e h1:N8RjWy1dTXt85FSO9rnaQXC33s0XAQlnVSReKGGBAWs=
15+
github.com/Skarlso/protobuf v0.0.0-20200307130307-c786b2468c2e/go.mod h1:D/ResgH7nQRyfO3W9YadC7oTWlF9M5YSGvbrRebmLhg=
16+
github.com/Skarlso/protobuf v0.0.0-20200307140829-e2fe748a72a5 h1:GthyChPbR7o0AjYNtdFPCf73/NfWKAnc7riHfxrOFTg=
17+
github.com/Skarlso/protobuf v0.0.0-20200307140829-e2fe748a72a5/go.mod h1:D/ResgH7nQRyfO3W9YadC7oTWlF9M5YSGvbrRebmLhg=
1218
github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw=
1319
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
1420
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=

plugin/grpc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package plugin
33
import (
44
"context"
55

6-
proto "github.com/gaia-pipeline/protobuf"
6+
proto "github.com/Skarlso/protobuf"
77
plugin "github.com/hashicorp/go-plugin"
88
"google.golang.org/grpc"
99
)

plugin/plugin.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"sync"
1212
"time"
1313

14+
proto "github.com/Skarlso/protobuf"
1415
"github.com/gaia-pipeline/gaia"
1516
"github.com/gaia-pipeline/gaia/security"
16-
proto "github.com/gaia-pipeline/protobuf"
1717
"github.com/hashicorp/go-plugin"
1818
)
1919

@@ -269,6 +269,18 @@ func (p *GoPlugin) Execute(j *gaia.Job) error {
269269
timeString := time.Now().Format(timeFormat)
270270
_, _ = p.logger.WriteString(fmt.Sprintf("%s Job '%s' threw an error: %s\n", timeString, j.Title, err.Error()))
271271
} else {
272+
// We set up the job's output if there was any
273+
outs := resultObj.GetOutput()
274+
if outs != nil {
275+
o := make([]*gaia.Output, 0)
276+
for _, out := range outs {
277+
o = append(o, &gaia.Output{
278+
Key: out.GetKey(),
279+
Value: out.GetValue(),
280+
})
281+
}
282+
j.Outs = o
283+
}
272284
j.Status = gaia.JobSuccess
273285
}
274286

@@ -313,6 +325,15 @@ func (p *GoPlugin) GetJobs() ([]*gaia.Job, error) {
313325
args = append(args, a)
314326
}
315327

328+
outs := make([]*gaia.Output, 0, len(job.GetOuts()))
329+
for _, out := range job.GetOuts() {
330+
o := &gaia.Output{
331+
Key: out.GetKey(),
332+
Value: out.GetValue(),
333+
}
334+
outs = append(outs, o)
335+
}
336+
316337
// add proto object to separate list to rebuild dep later.
317338
pList = append(pList, job)
318339

@@ -323,6 +344,7 @@ func (p *GoPlugin) GetJobs() ([]*gaia.Job, error) {
323344
Description: job.Description,
324345
Status: gaia.JobWaitingExec,
325346
Args: args,
347+
Outs: outs,
326348
}
327349
l = append(l, j)
328350
jobsMap[j.ID] = j

plugin/plugin_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"testing"
1414
"time"
1515

16+
proto "github.com/Skarlso/protobuf"
1617
"github.com/gaia-pipeline/gaia"
17-
proto "github.com/gaia-pipeline/protobuf"
1818
"github.com/hashicorp/go-hclog"
1919
"google.golang.org/grpc/metadata"
2020
)

workers/agent/agent.go

+9
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,15 @@ func (a *Agent) scheduleWork() {
351351
}
352352
j.Args = append(j.Args, a)
353353
}
354+
// Outputs
355+
j.Outs = make([]*gaia.Output, 0, len(job.GetOuts()))
356+
for _, out := range job.GetOuts() {
357+
o := &gaia.Output{
358+
Key: out.GetKey(),
359+
Value: out.GetValue(),
360+
}
361+
j.Outs = append(j.Outs, o)
362+
}
354363
}
355364

356365
// Convert dependencies

0 commit comments

Comments
 (0)