Skip to content

Commit b23dc67

Browse files
feat: Generate code for selected methods for REST and GRPC in golang
1 parent eccf802 commit b23dc67

File tree

138 files changed

+2391
-15420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2391
-15420
lines changed

app/package-lock.json

Lines changed: 91 additions & 157 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,35 @@
1818
"keywords": [],
1919
"license": "MIT",
2020
"dependencies": {
21-
"@grpc/grpc-js": "^1.9.5",
21+
"@grpc/grpc-js": "^1.9.8",
2222
"@grpc/proto-loader": "^0.7.10",
2323
"@kubernetes/client-node": "^0.19.0",
24-
"@types/body-parser": "^1.19.3",
25-
"@types/express": "^4.17.18",
26-
"@types/js-yaml": "^4.0.6",
27-
"@types/morgan": "^1.9.6",
28-
"@types/multer": "^1.4.8",
29-
"@types/node": "^18.18.3",
30-
"@types/ws": "^8.5.5",
31-
"axios": "^1.5.1",
24+
"@types/body-parser": "^1.19.4",
25+
"@types/express": "^4.17.20",
26+
"@types/morgan": "^1.9.7",
27+
"@types/multer": "^1.4.9",
28+
"@types/node": "^18.18.7",
29+
"axios": "^1.6.0",
3230
"cassandra-driver": "^4.7.2",
3331
"dotenv": "^16.3.1",
3432
"express": "^4.18.2",
3533
"helmet": "^7.0.0",
3634
"morgan": "^1.10.0",
3735
"multer": "^1.4.5-lts.1",
3836
"nodemon": "^3.0.1",
39-
"rimraf": "^5.0.1",
37+
"rimraf": "^5.0.5",
4038
"simple-git": "^3.20.0",
4139
"sqlite3": "^5.1.6",
4240
"ts-node": "^10.9.1",
4341
"typescript": "^4.9.5",
44-
"uuid": "^9.0.0",
45-
"winston": "^3.10.0"
42+
"uuid": "^9.0.1",
43+
"winston": "^3.11.0"
4644
},
4745
"devDependencies": {
4846
"@types/jest": "^29.5.5",
49-
"@types/react-redux-toastr": "^7.6.3",
50-
"@types/supertest": "^2.0.12",
51-
"@types/tar": "^6.1.6",
52-
"@types/uuid": "^9.0.3",
47+
"@types/supertest": "^2.0.15",
48+
"@types/tar": "^6.1.7",
49+
"@types/uuid": "^9.0.6",
5350
"jest": "^29.7.0",
5451
"supertest": "^6.3.3",
5552
"ts-jest": "^29.1.1",

app/src/models/code.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface Resource {
22
name: string;
3+
allowedMethods: string[];
34
// the below map can contain metadata about the field.
45
fields: Map<string, FieldMetadata>;
56
}

core/go.mod

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ require (
66
github.com/gertd/go-pluralize v0.2.1
77
github.com/iancoleman/strcase v0.3.0
88
github.com/sirupsen/logrus v1.9.3
9-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0
10-
go.opentelemetry.io/otel v1.18.0
11-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0
12-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0
13-
go.opentelemetry.io/otel/sdk v1.18.0
14-
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
9+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0
10+
go.opentelemetry.io/otel v1.19.0
11+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
12+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0
13+
go.opentelemetry.io/otel/sdk v1.19.0
14+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
1515
golang.org/x/text v0.13.0
16-
google.golang.org/grpc v1.58.1
16+
google.golang.org/grpc v1.59.0
1717
google.golang.org/protobuf v1.31.0
1818
)
1919

2020
require (
2121
cloud.google.com/go/compute v1.23.0 // indirect
2222
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
23-
github.com/go-logr/logr v1.2.4 // indirect
23+
github.com/go-logr/logr v1.3.0 // indirect
2424
github.com/go-logr/stdr v1.2.2 // indirect
2525
github.com/golang/protobuf v1.5.3 // indirect
2626
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
27-
go.opentelemetry.io/otel/metric v1.18.0 // indirect
28-
go.opentelemetry.io/otel/trace v1.18.0 // indirect
27+
go.opentelemetry.io/otel/metric v1.19.0 // indirect
28+
go.opentelemetry.io/otel/trace v1.19.0 // indirect
2929
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
30-
golang.org/x/net v0.15.0 // indirect
31-
golang.org/x/sys v0.12.0 // indirect
32-
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
33-
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
34-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect
30+
golang.org/x/net v0.17.0 // indirect
31+
golang.org/x/sys v0.13.0 // indirect
32+
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect
33+
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
34+
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
3535
)

core/go.sum

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cloud.google.com/go v0.110.7 h1:rJyC7nWRg2jWGZ4wSJ5nY65GTdYJkg0cd/uXb+ACI6o=
2+
cloud.google.com/go v0.110.8 h1:tyNdfIxjzaWctIiLYOTalaLKZ17SI44SKFW26QbOhME=
23
cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY=
34
cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
45
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
@@ -17,10 +18,13 @@ github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkH
1718
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
1819
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
1920
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
21+
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
22+
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
2023
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
2124
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
2225
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
2326
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
27+
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
2428
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
2529
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
2630
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
@@ -41,44 +45,72 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
4145
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
4246
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0 h1:b8xjZxHbLrXAum4SxJd1Rlm7Y/fKaB+6ACI7/e5EfSA=
4347
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.44.0/go.mod h1:1ei0a32xOGkFoySu7y1DAHfcuIhC0pNZpvY2huXuMy4=
48+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0 h1:RsQi0qJ2imFfCvZabqzM9cNXBG8k6gXMv1A0cXRmH6A=
49+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0/go.mod h1:vsh3ySueQCiKPxFLvjWC4Z135gIa34TQ/NSqkDTZYUM=
4450
go.opentelemetry.io/otel v1.18.0 h1:TgVozPGZ01nHyDZxK5WGPFB9QexeTMXEH7+tIClWfzs=
4551
go.opentelemetry.io/otel v1.18.0/go.mod h1:9lWqYO0Db579XzVuCKFNPDl4s73Voa+zEck3wHaAYQI=
52+
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
53+
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
4654
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0 h1:IAtl+7gua134xcV3NieDhJHjjOVeJhXAnYf/0hswjUY=
4755
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0/go.mod h1:w+pXobnBzh95MNIkeIuAKcHe/Uu/CX2PKIvBP6ipKRA=
56+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U=
57+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE=
4858
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0 h1:yE32ay7mJG2leczfREEhoW3VfSZIvHaB+gvVo1o8DQ8=
4959
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0/go.mod h1:G17FHPDLt74bCI7tJ4CMitEk4BXTYG4FW6XUpkPBXa4=
60+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S281UTjM+AbF31XSOYn1qXn3BgIdWl8HNEpx08Jk=
61+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I=
5062
go.opentelemetry.io/otel/metric v1.18.0 h1:JwVzw94UYmbx3ej++CwLUQZxEODDj/pOuTCvzhtRrSQ=
5163
go.opentelemetry.io/otel/metric v1.18.0/go.mod h1:nNSpsVDjWGfb7chbRLUNW+PBNdcSTHD4Uu5pfFMOI0k=
64+
go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
65+
go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8=
5266
go.opentelemetry.io/otel/sdk v1.18.0 h1:e3bAB0wB3MljH38sHzpV/qWrOTCFrdZF2ct9F8rBkcY=
5367
go.opentelemetry.io/otel/sdk v1.18.0/go.mod h1:1RCygWV7plY2KmdskZEDDBs4tJeHG92MdHZIluiYs/M=
68+
go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
69+
go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A=
5470
go.opentelemetry.io/otel/trace v1.18.0 h1:NY+czwbHbmndxojTEKiSMHkG2ClNH2PwmcHrdo0JY10=
5571
go.opentelemetry.io/otel/trace v1.18.0/go.mod h1:T2+SGJGuYZY3bjj5rgh/hN7KIrlpWC5nS8Mjvzckz+0=
72+
go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
73+
go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
5674
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
5775
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
5876
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
5977
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
6078
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
6179
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
80+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
81+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
6282
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
6383
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
84+
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
85+
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
6486
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
6587
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
6688
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6789
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
6890
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
91+
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
92+
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6993
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
7094
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
7195
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7296
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
7397
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
7498
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY=
7599
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4=
100+
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8=
101+
google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE=
76102
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI=
77103
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
104+
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k=
105+
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870=
78106
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0=
79107
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
108+
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
109+
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc=
80110
google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58=
81111
google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
112+
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
113+
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
82114
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
83115
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
84116
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=

core/internal/core/node/node.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Node struct {
1111
type ConsumerData struct {
1212
// Language node's(component) language.
1313
Language string `json:"language"`
14-
// Name of component (required, this will be service and deployment name).
14+
// Name of a component (required, this will be service and deployment name).
1515
Name string `json:"name"`
1616
// RestConfig holds all config related to REST. If nil, it means that the node is not REST server or has REST clients.
1717
RestConfig *RestConfig `json:"restConfig,omitempty"`
@@ -21,7 +21,7 @@ type ConsumerData struct {
2121
WsConfig *WsConfig `json:"wsConfig,omitempty"`
2222
// Metadata holds misc information about the node.
2323
Metadata map[string]interface{} `json:"metadata,omitempty"`
24-
// Annotations holds annotations for the node.
24+
// Annotations hold annotations for the node.
2525
Annotations map[string]string `json:"annotations,omitempty"`
2626
}
2727

@@ -38,7 +38,7 @@ type RestClient struct {
3838
SourceNodeName string `json:"sourceNodeName"`
3939
SourceNodeID string `json:"sourceNodeId"`
4040
Port string `json:"port"`
41-
// below two keys are populated in language node and are used to create server's clients.
41+
// The below given, two keys are populated in language node and are used to create server's clients.
4242
Resources []*Resource `json:"resources"`
4343
OpenAPIFileYamlContent string `json:"openAPIFileYamlContent,omitempty"`
4444
}
@@ -63,7 +63,7 @@ type GrpcClient struct {
6363
SourceNodeName string `json:"sourceNodeName"`
6464
SourceNodeID string `json:"sourceNodeId"`
6565
Port string `json:"port"`
66-
// below two keys are populated in language node and are used to create server's clients.
66+
// the below given, two keys are populated in language node and are used to create server's clients.
6767
Resources []*Resource `json:"resources"`
6868
ProtoFileContent string `json:"protoFileContent,omitempty"`
6969
}
@@ -84,7 +84,7 @@ type WsClient struct {
8484
SourceNodeName string `json:"sourceNodeName"`
8585
SourceNodeID string `json:"sourceNodeId"`
8686
Port string `json:"port"`
87-
// below two keys are populated in language node and are used to create server's clients.
87+
// the below given, two keys are populated in language node and are used to create server's clients.
8888
Resources []Resource `json:"resources"`
8989
}
9090

@@ -102,7 +102,8 @@ type FieldMetadata struct {
102102

103103
// Resource depicts the endpoints(e.g. /users, /accounts)
104104
type Resource struct {
105-
Name string `json:"name"`
106-
// resources fields (e.g. name, age in user)
105+
Name string `json:"name"`
106+
AllowedMethods []*string `json:"allowedMethods"`
107+
// resource fields (e.g., name, age in user)
107108
Fields map[string]FieldMetadata `json:"fields"`
108109
}

core/internal/languages/golang/frameworks/common-files/copier.go

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/gertd/go-pluralize"
66
corenode "github.com/intelops/compage/core/internal/core/node"
77
"github.com/intelops/compage/core/internal/languages/executor"
8+
"github.com/intelops/compage/core/internal/languages/golang/frameworks"
89
commonUtils "github.com/intelops/compage/core/internal/languages/utils"
910
"github.com/intelops/compage/core/internal/utils"
1011
"golang.org/x/text/cases"
@@ -37,22 +38,6 @@ type Copier struct {
3738
PluralizeClient *pluralize.Client
3839
}
3940

40-
type restResourceData struct {
41-
SmallResourceNameSingular string
42-
SmallResourceNamePlural string
43-
CapsResourceNameSingular string
44-
CapsResourceNamePlural string
45-
ResourcePostBody string
46-
ResourcePutBody string
47-
}
48-
49-
type grpcResourceData struct {
50-
SmallResourceNameSingular string
51-
SmallResourceNamePlural string
52-
CapsResourceNameSingular string
53-
CapsResourceNamePlural string
54-
}
55-
5641
type clientData struct {
5742
SourceNodeID string
5843
}
@@ -69,33 +54,38 @@ func NewCopier(gitPlatformURL, gitPlatformUserName, gitRepositoryName, nodeName,
6954
"GitPlatformURL": strings.Replace(gitPlatformURL, "https://", "", -1),
7055
}
7156
// set all grpcResources for main.go.tmpl
72-
var grpcResourcesData []grpcResourceData
57+
var grpcResourcesData []frameworks.GrpcResourceData
7358
for _, r := range grpcResources {
74-
grpcResourcesData = append(grpcResourcesData, grpcResourceData{
59+
grpcResourceData := frameworks.GrpcResourceData{
7560
SmallResourceNameSingular: strings.ToLower(r.Name),
7661
SmallResourceNamePlural: pluralizeClient.Plural(strings.ToLower(r.Name)),
7762
CapsResourceNameSingular: r.Name,
7863
CapsResourceNamePlural: pluralizeClient.Plural(r.Name),
79-
})
64+
}
65+
frameworks.AddGRPCAllowedMethods(&grpcResourceData, r.AllowedMethods)
66+
grpcResourcesData = append(grpcResourcesData, grpcResourceData)
8067
}
68+
8169
data["GrpcResources"] = grpcResourcesData
8270
data["GrpcServerPort"] = grpcServerPort
8371
data["IsGrpcServer"] = isGrpcServer
8472
// if grpcClients slice has elements
8573
HasGrpcClients := len(grpcClients) > 0
8674
data["HasGrpcClients"] = HasGrpcClients
8775

88-
// set all grpcResources for main.go.tmpl
89-
var restResourcesData []restResourceData
76+
// set all restResources for main.go.tmpl
77+
var restResourcesData []frameworks.RestResourceData
9078
for _, r := range restResources {
91-
restResourcesData = append(restResourcesData, restResourceData{
79+
resourceData := frameworks.RestResourceData{
9280
SmallResourceNameSingular: strings.ToLower(r.Name),
9381
SmallResourceNamePlural: pluralizeClient.Plural(strings.ToLower(r.Name)),
9482
CapsResourceNameSingular: r.Name,
9583
CapsResourceNamePlural: pluralizeClient.Plural(r.Name),
9684
ResourcePostBody: getResourcePostBody(r),
9785
ResourcePutBody: getResourcePutBody(r),
98-
})
86+
}
87+
frameworks.AddRESTAllowedMethods(&resourceData, r.AllowedMethods)
88+
restResourcesData = append(restResourcesData, resourceData)
9989
}
10090
data["RestResources"] = restResourcesData
10191
data["RestServerPort"] = restServerPort
@@ -189,7 +179,7 @@ func getResourcePutBody(r *corenode.Resource) string {
189179
return putBody
190180
}
191181

192-
// CreateCommonFiles creates/copies relevant files to generated project
182+
// CreateCommonFiles creates/copies relevant files to a generated project
193183
func (c Copier) CreateCommonFiles() error {
194184
var filePaths []string
195185
targetMainGoFileName := c.NodeDirectoryName + "/" + MainGoFile

0 commit comments

Comments
 (0)