@@ -2,26 +2,28 @@ package goginserver
2
2
3
3
import (
4
4
"errors"
5
+ "text/template"
6
+
5
7
"github.com/gertd/go-pluralize"
6
8
"github.com/iancoleman/strcase"
7
9
corenode "github.com/intelops/compage/core/internal/core/node"
8
10
"github.com/intelops/compage/core/internal/languages/executor"
9
11
commonUtils "github.com/intelops/compage/core/internal/languages/utils"
10
12
log "github.com/sirupsen/logrus"
11
- "text/template"
13
+
14
+ "strings"
12
15
13
16
"github.com/intelops/compage/core/internal/utils"
14
17
"golang.org/x/text/cases"
15
18
"golang.org/x/text/language"
16
- "strings"
17
19
)
18
20
19
21
const RestServerPath = "/pkg/rest/server"
20
22
const RestClientPath = "/pkg/rest/client"
21
23
22
24
const DaosPath = RestServerPath + "/daos"
23
25
const SQLDBClientsPath = DaosPath + "/clients/sqls"
24
- const NOSQLDBClientsPath = DaosPath + "/clients/nosqls"
26
+ const NoSQLDBClientsPath = DaosPath + "/clients/nosqls"
25
27
26
28
const ServicesPath = RestServerPath + "/services"
27
29
const ControllersPath = RestServerPath + "/controllers"
@@ -161,17 +163,16 @@ func (c *Copier) createRestServerDirectories() error {
161
163
log .Debugf ("error creating daos directory: %v" , err )
162
164
return err
163
165
}
164
- // create directories for every resource's db client.
165
166
if c .IsSQLDB {
167
+ // create directories for every resource's db client.
166
168
sqlDBClientsDirectory := c .NodeDirectoryName + SQLDBClientsPath
167
169
if err := utils .CreateDirectories (sqlDBClientsDirectory ); err != nil {
168
170
log .Debugf ("error creating sql db clients directory: %v" , err )
169
171
return err
170
172
}
171
- }
172
- // create directories for every resource's db client.
173
- if c .IsNoSQLDB {
174
- noSQLDBClientsDirectory := c .NodeDirectoryName + NOSQLDBClientsPath
173
+ } else if c .IsNoSQLDB {
174
+ // create directories for every resource's db client.
175
+ noSQLDBClientsDirectory := c .NodeDirectoryName + NoSQLDBClientsPath
175
176
if err := utils .CreateDirectories (noSQLDBClientsDirectory ); err != nil {
176
177
log .Debugf ("error creating nosql db clients directory: %v" , err )
177
178
return err
@@ -556,44 +557,43 @@ func (c *Copier) CreateRestServer() error {
556
557
return err
557
558
}
558
559
}
559
- // create sql db config file (common to all resources for specific database)
560
- // No vars in config file as of now but in future they may be there.
561
560
if c .IsSQLDB {
561
+ // create sql db config file (common to all resources for specific database)
562
+ // No vars in config file as of now but in future they may be there.
562
563
if c .SQLDB == SQLite {
563
564
var filePaths []string
564
565
// client files
565
566
targetSQLiteConfigFileName := c .NodeDirectoryName + SQLDBClientsPath + "/" + SQLiteDBConfigFile
566
- _ , err2 := utils .CopyFile (targetSQLiteConfigFileName , c .TemplatesRootPath + SQLDBClientsPath + "/" + SQLiteDBConfigFile )
567
- if err2 != nil {
568
- log .Debugf ("error copying sqlite config file: %v" , err2 )
569
- return err2
567
+ _ , err := utils .CopyFile (targetSQLiteConfigFileName , c .TemplatesRootPath + SQLDBClientsPath + "/" + SQLiteDBConfigFile )
568
+ if err != nil {
569
+ log .Debugf ("error copying sqlite config file: %v" , err )
570
+ return err
570
571
}
571
572
filePaths = append (filePaths , targetSQLiteConfigFileName )
572
573
return executor .Execute (filePaths , c .Data )
573
574
} else if c .SQLDB == MySQL {
574
575
var filePaths []string
575
576
// client files
576
577
targetMySQLConfigFileName := c .NodeDirectoryName + SQLDBClientsPath + "/" + MySQLDBConfigFile
577
- _ , err2 := utils .CopyFile (targetMySQLConfigFileName , c .TemplatesRootPath + SQLDBClientsPath + "/" + MySQLDBConfigFile )
578
- if err2 != nil {
579
- log .Debugf ("error copying mysql config file: %v" , err2 )
580
- return err2
578
+ _ , err := utils .CopyFile (targetMySQLConfigFileName , c .TemplatesRootPath + SQLDBClientsPath + "/" + MySQLDBConfigFile )
579
+ if err != nil {
580
+ log .Debugf ("error copying mysql config file: %v" , err )
581
+ return err
581
582
}
582
583
filePaths = append (filePaths , targetMySQLConfigFileName )
583
584
return executor .Execute (filePaths , c .Data )
584
585
}
585
- }
586
- // create nosql db config file (common to all resources for specific database)
587
- // No vars in config file as of now but in future they may be there.
588
- if c .IsNoSQLDB {
586
+ } else if c .IsNoSQLDB {
587
+ // create nosql db config file (common to all resources for specific database)
588
+ // No vars in config file as of now but in future they may be there.
589
589
if c .NoSQLDB == MongoDB {
590
590
var filePaths []string
591
591
// client files
592
- targetMongoDBConfigFileName := c .NodeDirectoryName + NOSQLDBClientsPath + "/" + MongoDBConfigFile
593
- _ , err2 := utils .CopyFile (targetMongoDBConfigFileName , c .TemplatesRootPath + NOSQLDBClientsPath + "/" + MongoDBConfigFile )
594
- if err2 != nil {
595
- log .Debugf ("error copying mongodb config file: %v" , err2 )
596
- return err2
592
+ targetMongoDBConfigFileName := c .NodeDirectoryName + NoSQLDBClientsPath + "/" + MongoDBConfigFile
593
+ _ , err := utils .CopyFile (targetMongoDBConfigFileName , c .TemplatesRootPath + NoSQLDBClientsPath + "/" + MongoDBConfigFile )
594
+ if err != nil {
595
+ log .Debugf ("error copying mongodb config file: %v" , err )
596
+ return err
597
597
}
598
598
filePaths = append (filePaths , targetMongoDBConfigFileName )
599
599
return executor .Execute (filePaths , c .Data )
0 commit comments