Skip to content

Commit 7508346

Browse files
fix: map implementation, dockerfile and ui
1 parent d2d2f96 commit 7508346

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

core/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ FROM alpine:3.18.2
2222
# Create project directory (workdir)
2323
WORKDIR /app
2424

25-
RUN apk update && apk add protoc && apk add dos2unix && apk add openjdk8 && apk add make && apk add bash && apk add curl && apk add jq && apk add --update go \
25+
RUN apk update && apk add protoc && apk add dos2unix && apk add openjdk11 && apk add make && apk add bash && apk add curl && apk add jq && apk add --update go \
2626
&& curl https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/bin/utils/openapi-generator-cli.sh \
2727
> /app/openapi-generator-cli \
2828
&& chmod a+x /app/openapi-generator-cli
2929

3030
# Downloading and installing Maven
31-
ARG MAVEN_VERSION=3.9.3
31+
ARG MAVEN_VERSION=3.9.4
3232
ARG USER_HOME_DIR="/root"
33-
ARG BASE_URL=https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries
33+
ARG BASE_URL=https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries
3434
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
3535
&& echo "Downloading maven" \
3636
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \

core/internal/languages/golang/frameworks/go-gin-server/copier.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const MySQLGORMDaoFile = "mysql-gorm-dao.go.tmpl"
5252
const SQLiteGORMDaoFile = "sqlite-gorm-dao.go.tmpl"
5353
const MySQLGORMDBConfigFile = "mysql-gorm.go.tmpl"
5454
const SQLiteGORMDBConfigFile = "sqlite-gorm.go.tmpl"
55+
const MapDBConfigFile = "map.go.tmpl"
5556

5657
const ClientFile = "client.go.tmpl"
5758
const ConfigFile = "rest-opentel-config.go.tmpl"
@@ -62,7 +63,7 @@ const MongoDB = "MongoDB"
6263
// SQLite sql databases
6364
const SQLite = "SQLite"
6465
const MySQL = "MySQL"
65-
const InMemory = "InMemory"
66+
const Map = "Map"
6667

6768
const SQLiteGORM = "SQLite-GORM"
6869
const MySQLGORM = "MySQL-GORM"
@@ -554,7 +555,16 @@ func (c *Copier) copySQLDBResourceFiles(resourceName string, filePaths []*string
554555
return nil, err
555556
}
556557
filePaths = append(filePaths, &targetResourceDaoFileName)
557-
} else if c.SQLDB == InMemory {
558+
} else if c.SQLDB == Map {
559+
// model files
560+
// copy model files to generated project
561+
targetResourceModelFileName := c.NodeDirectoryName + ModelsPath + "/" + resourceName + "-" + strings.Replace(SQLModelFile, "sqls-", "", 1)
562+
_, err = utils.CopyFile(targetResourceModelFileName, c.TemplatesRootPath+ModelsPath+"/"+SQLModelFile)
563+
if err != nil {
564+
log.Debugf("error copying model file: %v", err)
565+
return nil, err
566+
}
567+
filePaths = append(filePaths, &targetResourceModelFileName)
558568
targetResourceDaoFileName = c.NodeDirectoryName + DaosPath + "/" + resourceName + "-" + DaoFile
559569
_, err := utils.CopyFile(targetResourceDaoFileName, c.TemplatesRootPath+DaosPath+"/"+DaoFile)
560570
if err != nil {
@@ -694,6 +704,17 @@ func (c *Copier) CreateRestServer() error {
694704
}
695705
filePaths = append(filePaths, targetMySQLConfigFileName)
696706
return executor.Execute(filePaths, c.Data)
707+
} else if c.SQLDB == Map {
708+
var filePaths []string
709+
// client files
710+
targetMapConfigFileName := c.NodeDirectoryName + SQLDBClientsPath + "/" + MapDBConfigFile
711+
_, err := utils.CopyFile(targetMapConfigFileName, c.TemplatesRootPath+SQLDBClientsPath+"/"+MapDBConfigFile)
712+
if err != nil {
713+
log.Debugf("error copying map config file: %v", err)
714+
return err
715+
}
716+
filePaths = append(filePaths, targetMapConfigFileName)
717+
return executor.Execute(filePaths, c.Data)
697718
}
698719
} else if c.IsNoSQLDB {
699720
// create nosql db config file (common to all resources for specific database)

core/internal/languages/golang/frameworks/go-grpc-server/copier.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const MySQLGORMDaoFile = "mysql-gorm-dao.go.tmpl"
5252
const SQLiteGORMDaoFile = "sqlite-gorm-dao.go.tmpl"
5353
const MySQLGORMDBConfigFile = "mysql-gorm.go.tmpl"
5454
const SQLiteGORMDBConfigFile = "sqlite-gorm.go.tmpl"
55+
const MapDBConfigFile = "map.go.tmpl"
5556

5657
const ClientFile = "client.go.tmpl"
5758
const ConfigFile = "grpc-opentel-config.go.tmpl"
@@ -62,7 +63,7 @@ const MongoDB = "MongoDB"
6263
// SQLite sql databases
6364
const SQLite = "SQLite"
6465
const MySQL = "MySQL"
65-
const InMemory = "InMemory"
66+
const Map = "Map"
6667

6768
// SQLiteGORM - GORM sql databases
6869
const SQLiteGORM = "SQLite-GORM"
@@ -363,7 +364,16 @@ func (c *Copier) copySQLDBResourceFiles(resourceName string, filePaths []*string
363364
return nil, err
364365
}
365366
filePaths = append(filePaths, &targetResourceDaoFileName)
366-
} else if c.SQLDB == InMemory {
367+
} else if c.SQLDB == Map {
368+
// model files
369+
// copy model files to generated project
370+
targetResourceModelFileName := c.NodeDirectoryName + ModelsPath + "/" + resourceName + "-" + strings.Replace(SQLModelFile, "sqls-", "", 1)
371+
_, err = utils.CopyFile(targetResourceModelFileName, c.TemplatesRootPath+ModelsPath+"/"+SQLModelFile)
372+
if err != nil {
373+
log.Debugf("error copying model file: %v", err)
374+
return nil, err
375+
}
376+
filePaths = append(filePaths, &targetResourceModelFileName)
367377
targetResourceDaoFileName = c.NodeDirectoryName + DaosPath + "/" + resourceName + "-" + DaoFile
368378
_, err := utils.CopyFile(targetResourceDaoFileName, c.TemplatesRootPath+DaosPath+"/"+DaoFile)
369379
if err != nil {
@@ -729,6 +739,17 @@ func (c *Copier) CreateGrpcServer() error {
729739
}
730740
filePaths = append(filePaths, targetMySQLConfigFileName)
731741
return executor.Execute(filePaths, c.Data)
742+
} else if c.SQLDB == Map {
743+
var filePaths []string
744+
// client files
745+
targetMapConfigFileName := c.NodeDirectoryName + SQLDBClientsPath + "/" + MapDBConfigFile
746+
_, err := utils.CopyFile(targetMapConfigFileName, c.TemplatesRootPath+SQLDBClientsPath+"/"+MapDBConfigFile)
747+
if err != nil {
748+
log.Debugf("error copying map config file: %v", err)
749+
return err
750+
}
751+
filePaths = append(filePaths, targetMapConfigFileName)
752+
return executor.Execute(filePaths, c.Data)
732753
}
733754
} else if c.IsNoSQLDB {
734755
// create nosql db config file (common to all resources for specific database)

ui/src/components/diagram-maker/node-properties/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const COMPAGE_LANGUAGE_SQL_DBS = {
3434

3535
// compage template sql_dbs supported.
3636
export const COMPAGE_LANGUAGE_NOSQL_DBS = {
37-
[GO]: ["MongoDB", "Map"],
37+
[GO]: ["MongoDB"],
3838
};
3939

4040
// openapi template frameworks supported.

0 commit comments

Comments
 (0)