Commit 0787543c authored by Kamil Trzciński's avatar Kamil Trzciński 🔴

Pass common.Config to Executor::Prepare

parent 54eb320a
......@@ -199,7 +199,7 @@ func (mr *MultiRunner) processRunners(id int, stopWorker chan bool, runners chan
}
mr.addBuild(newJob)
newJob.Run()
newJob.Run(mr.config)
mr.removeBuild(newJob)
newJob = nil
......
......@@ -53,6 +53,7 @@ func runHerokuURL(addr string) error {
func runSingle(c *cli.Context) {
buildsDir := c.String("builds-dir")
shell := c.String("shell")
config := common.NewConfig()
runner := common.RunnerConfig{
URL: c.String("url"),
Token: c.String("token"),
......@@ -128,7 +129,7 @@ func runSingle(c *cli.Context) {
BuildAbort: abortSignal,
}
newBuild.AssignID()
newBuild.Run()
newBuild.Run(config)
}
doneSignal <- 0
......
......@@ -191,7 +191,7 @@ func (b *Build) SendBuildLog() {
}
}
func (b *Build) Run() error {
func (b *Build) Run(globalConfig *Config) error {
executor := GetExecutor(b.Runner.Executor)
if executor == nil {
b.FinishBuild(Failed, "Executor not found: %v", b.Runner.Executor)
......@@ -199,7 +199,7 @@ func (b *Build) Run() error {
return errors.New("executor not found")
}
err := executor.Prepare(b.Runner, b)
err := executor.Prepare(globalConfig, b.Runner, b)
if err == nil {
err = executor.Start()
}
......
......@@ -5,7 +5,7 @@ import (
)
type Executor interface {
Prepare(config *RunnerConfig, build *Build) error
Prepare(globalConfig *Config, config *RunnerConfig, build *Build) error
Start() error
Wait() error
Finish(err error)
......
......@@ -459,8 +459,8 @@ func (s *DockerExecutor) getImageName() (string, error) {
return s.Config.Docker.Image, nil
}
func (s *DockerExecutor) Prepare(config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(config, build)
func (s *DockerExecutor) Prepare(globalConfig *common.Config, config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(globalConfig, config, build)
if err != nil {
return err
}
......
......@@ -196,7 +196,7 @@ func (e *AbstractExecutor) verifyOptions() error {
return nil
}
func (e *AbstractExecutor) Prepare(config *common.RunnerConfig, build *common.Build) error {
func (e *AbstractExecutor) Prepare(globalConfig *common.Config, config *common.RunnerConfig, build *common.Build) error {
e.Config = config
e.Build = build
e.BuildCanceled = make(chan bool, 1)
......
......@@ -150,8 +150,8 @@ func (s *ParallelsExecutor) createVM() error {
return nil
}
func (s *ParallelsExecutor) Prepare(config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(config, build)
func (s *ParallelsExecutor) Prepare(globalConfig *common.Config, config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(globalConfig, config, build)
if err != nil {
return err
}
......
......@@ -19,8 +19,8 @@ type ShellExecutor struct {
scriptDir string
}
func (s *ShellExecutor) Prepare(config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(config, build)
func (s *ShellExecutor) Prepare(globalConfig *common.Config, config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(globalConfig, config, build)
if err != nil {
return err
}
......
......@@ -13,8 +13,8 @@ type SSHExecutor struct {
sshCommand ssh.Command
}
func (s *SSHExecutor) Prepare(config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(config, build)
func (s *SSHExecutor) Prepare(globalConfig *common.Config, config *common.RunnerConfig, build *common.Build) error {
err := s.AbstractExecutor.Prepare(globalConfig, config, build)
if err != nil {
return err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment