Skip to content

Commit b6cdc4a

Browse files
committed
feat(be): sqlite support, setup
1 parent 8534dba commit b6cdc4a

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

cli/setup/setup.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func InteractiveSetup(conf *util.ConfigType) {
115115
1 - MySQL
116116
2 - BoltDB
117117
3 - PostgreSQL
118+
4 - SQLite
118119
`
119120

120121
var db int
@@ -130,6 +131,9 @@ func InteractiveSetup(conf *util.ConfigType) {
130131
case 3:
131132
conf.Dialect = util.DbDriverPostgres
132133
scanPostgres(conf)
134+
case 4:
135+
conf.Dialect = util.DbDriverSQLite
136+
scanSQLite(conf)
133137
}
134138

135139
defaultPlaybookPath := filepath.Join(os.TempDir(), "semaphore")
@@ -183,13 +187,11 @@ func InteractiveSetup(conf *util.ConfigType) {
183187
}
184188

185189
func scanBoltDb(conf *util.ConfigType) {
186-
workingDirectory, err := os.Getwd()
187-
if err != nil {
188-
workingDirectory = os.TempDir()
189-
}
190-
defaultBoltDBPath := filepath.Join(workingDirectory, "database.boltdb")
191-
conf.BoltDb = &util.DbConfig{}
192-
askValue("db filename", defaultBoltDBPath, &conf.BoltDb.Hostname)
190+
conf.BoltDb = scanFileDB("database.boltdb")
191+
}
192+
193+
func scanSQLite(conf *util.ConfigType) {
194+
conf.SQLite = scanFileDB("database.sqlite")
193195
}
194196

195197
func scanMySQL(conf *util.ConfigType) {
@@ -214,6 +216,17 @@ func scanPostgres(conf *util.ConfigType) {
214216
}
215217
}
216218

219+
func scanFileDB(defaultDbFile string) *util.DbConfig {
220+
workingDirectory, err := os.Getwd()
221+
if err != nil {
222+
workingDirectory = os.TempDir()
223+
}
224+
defaultDBPath := filepath.Join(workingDirectory, defaultDbFile)
225+
conf := &util.DbConfig{}
226+
askValue("db Hostname", defaultDBPath, &conf.Hostname)
227+
return conf
228+
}
229+
217230
func scanErrorChecker(n int, err error) {
218231
if err != nil && err.Error() != "unexpected newline" {
219232
log.Warn("An input error occurred: " + err.Error())

0 commit comments

Comments
 (0)