mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 05:41:12 +00:00
9c6c4559a7
Add SSH backend that runs commands via SSH. Close #848
45 lines
1 KiB
Go
45 lines
1 KiB
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/ssh"
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
|
)
|
|
|
|
var engines map[string]types.Engine
|
|
|
|
func init() {
|
|
loadedEngines := []types.Engine{
|
|
docker.New(),
|
|
local.New(),
|
|
ssh.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
|
|
}
|