default_executor_provider.go 991 Bytes
Newer Older
1 2
package executors

Kamil Trzciński's avatar
Kamil Trzciński committed
3 4 5 6 7
import (
	"errors"

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

type DefaultExecutorProvider struct {
10 11 12
	Creator          func() common.Executor
	FeaturesUpdater  func(features *common.FeaturesInfo)
	DefaultShellName string
13 14 15 16 17 18 19 20 21 22 23 24 25
}

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

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

26 27 28 29 30 31 32 33
func (e DefaultExecutorProvider) Acquire(config *common.RunnerConfig) (common.ExecutorData, error) {
	return nil, nil
}

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

Kamil Trzciński's avatar
Kamil Trzciński committed
34 35 36
func (e DefaultExecutorProvider) GetFeatures(features *common.FeaturesInfo) error {
	if e.FeaturesUpdater == nil {
		return errors.New("cannot evaluate features")
37
	}
Kamil Trzciński's avatar
Kamil Trzciński committed
38 39 40

	e.FeaturesUpdater(features)
	return nil
41
}
42 43 44 45

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