-
Notifications
You must be signed in to change notification settings - Fork 248
/
dummy.go
57 lines (46 loc) · 1.31 KB
/
dummy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package dummy
import (
"log"
"github.com/taskcluster/taskcluster/v27/tools/taskcluster-worker-runner/cfg"
"github.com/taskcluster/taskcluster/v27/tools/taskcluster-worker-runner/protocol"
"github.com/taskcluster/taskcluster/v27/tools/taskcluster-worker-runner/run"
"github.com/taskcluster/taskcluster/v27/tools/taskcluster-worker-runner/worker/worker"
yaml "gopkg.in/yaml.v3"
)
type dummy struct {
runnercfg *cfg.RunnerConfig
}
func (d *dummy) ConfigureRun(state *run.State) error {
return nil
}
func (d *dummy) UseCachedRun(state *run.State) error {
return nil
}
func (d *dummy) StartWorker(state *run.State) (protocol.Transport, error) {
out, err := yaml.Marshal(state)
if err != nil {
return nil, err
}
log.Printf("State information:\n%s", out)
return protocol.NewNullTransport(), nil
}
func (d *dummy) SetProtocol(proto *protocol.Protocol) {
// the protocol is running on a null transport, so mark it as initialized
proto.SetInitialized()
}
func (d *dummy) Wait() error {
return nil
}
func New(runnercfg *cfg.RunnerConfig) (worker.Worker, error) {
return &dummy{runnercfg}, nil
}
func Usage() string {
return `
The "dummy" worker implementation does nothing but dump the state instead of
"starting" anything. It is intended for debugging.
` + "```yaml" + `
worker:
implementation: dummy
` + "```" + `
`
}