From 3145b710c1639ae3972e1a5d48ad28b578301928 Mon Sep 17 00:00:00 2001 From: Alex Suraci Date: Wed, 26 Mar 2014 22:40:17 -0700 Subject: [PATCH 1/2] run privileged builds in web workers --- pkg/queue/build_runner.go | 5 +++-- pkg/queue/worker.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/queue/build_runner.go b/pkg/queue/build_runner.go index 0c04ad102..ca9606f08 100644 --- a/pkg/queue/build_runner.go +++ b/pkg/queue/build_runner.go @@ -11,7 +11,7 @@ import ( ) type BuildRunner interface { - Run(buildScript *script.Build, repo *repo.Repo, key []byte, buildOutput io.Writer) (success bool, err error) + Run(buildScript *script.Build, repo *repo.Repo, key []byte, privileged bool, buildOutput io.Writer) (success bool, err error) } type buildRunner struct { @@ -26,11 +26,12 @@ func NewBuildRunner(dockerClient *docker.Client, timeout time.Duration) BuildRun } } -func (runner *buildRunner) Run(buildScript *script.Build, repo *repo.Repo, key []byte, buildOutput io.Writer) (bool, error) { +func (runner *buildRunner) Run(buildScript *script.Build, repo *repo.Repo, key []byte, privileged bool, buildOutput io.Writer) (bool, error) { builder := build.New(runner.dockerClient) builder.Build = buildScript builder.Repo = repo builder.Key = key + builder.Privileged = privileged builder.Stdout = buildOutput builder.Timeout = runner.timeout diff --git a/pkg/queue/worker.go b/pkg/queue/worker.go index 174eb69eb..26612aade 100644 --- a/pkg/queue/worker.go +++ b/pkg/queue/worker.go @@ -183,6 +183,7 @@ func (w *worker) runBuild(task *BuildTask, buf io.Writer) (bool, error) { task.Script, repo, []byte(task.Repo.PrivateKey), + task.Repo.Privileged, buf, ) } From ded5c5ef7df2ef85a909356d5bac5a383c43a151 Mon Sep 17 00:00:00 2001 From: Nurahmadie Date: Thu, 27 Mar 2014 17:43:07 +0700 Subject: [PATCH 2/2] sync mysql behavior with sqlite --- pkg/database/migrate/mysql.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/database/migrate/mysql.go b/pkg/database/migrate/mysql.go index 248b510c4..7fe29ce65 100644 --- a/pkg/database/migrate/mysql.go +++ b/pkg/database/migrate/mysql.go @@ -21,7 +21,8 @@ func MySQL(tx *sql.Tx) *MigrationDriver { } func (m *mysqlDriver) CreateTable(tableName string, args []string) (sql.Result, error) { - return m.Tx.Exec(fmt.Sprintf("CREATE TABLE %s (%s) ROW_FORMAT=DYNAMIC", tableName, strings.Join(args, ", "))) + return m.Tx.Exec(fmt.Sprintf("CREATE TABLE IF NOT EXISTS %s (%s) ROW_FORMAT=DYNAMIC", + tableName, strings.Join(args, ", "))) } func (m *mysqlDriver) RenameTable(tableName, newName string) (sql.Result, error) { @@ -41,6 +42,9 @@ func (m *mysqlDriver) ChangeColumn(tableName, columnName, newSpecs string) (sql. } func (m *mysqlDriver) DropColumns(tableName string, columnsToDrop ...string) (sql.Result, error) { + if len(columnsToDrop) == 0 { + return nil, fmt.Errorf("No columns to drop.") + } for k, v := range columnsToDrop { columnsToDrop[k] = fmt.Sprintf("DROP %s", v) }