-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.go
40 lines (33 loc) · 864 Bytes
/
driver.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
package domjudge_driver
import (
"context"
"github.com/Myriad-Dreamin/tarus/api/tarus"
tarus_driver "github.com/Myriad-Dreamin/tarus/pkg/tarus-driver"
"github.com/containerd/containerd/errdefs"
"github.com/pkg/errors"
)
type Driver struct {
Problem string
}
func New() (*Driver, error) {
return &Driver{}, nil
}
func (d *Driver) CreateJudgeRequest(ctx context.Context) (*tarus.MakeJudgeRequest, error) {
if len(d.Problem) == 0 {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, "problem option required")
}
return CreateLocalJudgeRequest(d.Problem)
}
func init() {
tarus_driver.Register(&tarus_driver.Registration{
Id: "domjudge",
Init: func(args *tarus_driver.InitContext) (tarus_driver.Driver, error) {
d, err := New()
if err != nil {
return nil, err
}
d.Problem = args.Arguments["problem"]
return d, nil
},
})
}