-
Notifications
You must be signed in to change notification settings - Fork 9
/
executor.go
57 lines (51 loc) · 1.49 KB
/
executor.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
// SPDX-License-Identifier: Apache-2.0
package executor
import (
"fmt"
"github.com/go-vela/types/constants"
"github.com/sirupsen/logrus"
)
// New creates and returns a Vela engine capable of
// integrating with the configured executor.
//
// Currently the following executors are supported:
//
// * linux
// * local
// .
func New(s *Setup) (Engine, error) {
// validate the setup being provided
//
// https://pkg.go.dev/github.com/go-vela/worker/executor#Setup.Validate
err := s.Validate()
if err != nil {
return nil, err
}
logrus.Debug("creating executor engine from setup")
// process the executor driver being provided
switch s.Driver {
case constants.DriverDarwin:
// handle the Darwin executor driver being provided
//
// https://pkg.go.dev/github.com/go-vela/worker/executor#Setup.Darwin
return s.Darwin()
case constants.DriverLinux:
// handle the Linux executor driver being provided
//
// https://pkg.go.dev/github.com/go-vela/worker/executor#Setup.Linux
return s.Linux()
case constants.DriverLocal:
// handle the Local executor driver being provided
//
// https://pkg.go.dev/github.com/go-vela/worker/executor#Setup.Local
return s.Local()
case constants.DriverWindows:
// handle the Windows executor driver being provided
//
// https://pkg.go.dev/github.com/go-vela/worker/executor#Setup.Windows
return s.Windows()
default:
// handle an invalid executor driver being provided
return nil, fmt.Errorf("invalid executor driver provided: %s", s.Driver)
}
}