Skip to content

Commit

Permalink
Enable shell for both mysql and postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb committed Jan 24, 2021
1 parent cae1a20 commit 6af6cff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type Settings struct {
ShellTaskFamily string `json:"shell_task_family"`
S3Bucket string `json:"s3_bucket"`
DumpLoadTaskFamily string `json:"dumpload_task_family"`
Engine string `json:"engine"`
} `json:"dbutils"`
CodebuildProject struct {
Name string `json:"name"`
Expand Down
10 changes: 9 additions & 1 deletion cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ var dbShellCmd = &cobra.Command{
checkErr(err)
err = a.LoadSettings()
checkErr(err)
var exec string
if a.Settings.DBUtils.Engine == "mysql" {
exec = "mysql"
} else if a.Settings.DBUtils.Engine == "postgres" {
exec = "psql"
} else {
checkErr(fmt.Errorf("unknoown database engine %s", a.Settings.DBUtils.Engine))
}
taskOutput, err := a.StartTask(&a.Settings.DBUtils.ShellTaskFamily, app.ShellBackgroundCommand, false)
checkErr(err)
shellTask := taskOutput.Tasks[0]
Expand All @@ -97,7 +105,7 @@ var dbShellCmd = &cobra.Command{
err = a.WaitForTaskRunning(shellTask)
checkErr(err)
Spinner.Stop()
err = a.ConnectToTask(shellTask, aws.String("entrypoint.sh psql"))
err = a.ConnectToTask(shellTask, aws.String(fmt.Sprintf("entrypoint.sh %s", exec)))
checkErr(err)
},
}
Expand Down

0 comments on commit 6af6cff

Please sign in to comment.