mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-17 17:45:03 +02:00
80c72b590c
This adds support for #559. I tested using [this .woodpecker.yml](https://git.exozy.me/Ta180m/Hello-world/src/branch/main/.woodpecker.yml) on my self-hosted [Woodpecker instance](https://ci.exozy.me/Ta180m/Hello-world). I was also able to get this to build [Hugo websites](https://ci.exozy.me/Ta180m/howtuwu/build/1). It's currently very simplistic but works! close #559
44 lines
969 B
Go
44 lines
969 B
Go
package backend
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/backend/docker"
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/backend/local"
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
|
)
|
|
|
|
var engines map[string]types.Engine
|
|
|
|
func init() {
|
|
loadedEngines := []types.Engine{
|
|
docker.New(),
|
|
local.New(),
|
|
// kubernetes.New(), // TODO: disabled for now as kubernetes backend has not been implemented yet
|
|
}
|
|
|
|
engines = make(map[string]types.Engine)
|
|
for _, engine := range loadedEngines {
|
|
engines[engine.Name()] = engine
|
|
}
|
|
}
|
|
|
|
func FindEngine(engineName string) (types.Engine, error) {
|
|
if engineName == "auto-detect" {
|
|
for _, engine := range engines {
|
|
if engine.IsAvailable() {
|
|
return engine, nil
|
|
}
|
|
}
|
|
|
|
return nil, fmt.Errorf("Can't detect an available backend engine")
|
|
}
|
|
|
|
engine, ok := engines[engineName]
|
|
if !ok {
|
|
return nil, fmt.Errorf("Backend engine '%s' not found", engineName)
|
|
}
|
|
|
|
return engine, nil
|
|
}
|