File: default_executor_provider.go

package info (click to toggle)
gitlab-ci-multi-runner 14.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 31,248 kB
  • sloc: sh: 1,694; makefile: 384; asm: 79; ruby: 68
file content (52 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download
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
package executors

import (
	"errors"

	"gitlab.com/gitlab-org/gitlab-runner/common"
)

type DefaultExecutorProvider struct {
	Creator          func() common.Executor
	FeaturesUpdater  func(features *common.FeaturesInfo)
	ConfigUpdater    func(input *common.RunnerConfig, output *common.ConfigInfo)
	DefaultShellName string
}

func (e DefaultExecutorProvider) CanCreate() bool {
	return e.Creator != nil
}

func (e DefaultExecutorProvider) Create() common.Executor {
	if e.Creator == nil {
		return nil
	}
	return e.Creator()
}

func (e DefaultExecutorProvider) Acquire(config *common.RunnerConfig) (common.ExecutorData, error) {
	return nil, nil
}

func (e DefaultExecutorProvider) Release(config *common.RunnerConfig, data common.ExecutorData) {}

func (e DefaultExecutorProvider) GetFeatures(features *common.FeaturesInfo) error {
	if e.FeaturesUpdater == nil {
		return errors.New("cannot evaluate features")
	}

	e.FeaturesUpdater(features)
	return nil
}

func (e DefaultExecutorProvider) GetConfigInfo(input *common.RunnerConfig, output *common.ConfigInfo) {
	if e.ConfigUpdater == nil {
		return
	}

	e.ConfigUpdater(input, output)
}

func (e DefaultExecutorProvider) GetDefaultShell() string {
	return e.DefaultShellName
}