Skip to content

Commit 94852cd

Browse files
committed
Updating source codes such as docker compose
1 parent dc72d20 commit 94852cd

18 files changed

+223
-296
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ docker-compose-mode-files/data/cb-dragonfly/
4949

5050
# Binary
5151
src/mcc
52+
53+
54+
*.db
55+
package.json
56+
yarn.lock
57+
58+
docker-compose-mode-files/data/*
59+
conf/docker/data/*

bin/mcc

165 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
version: 1
2-
grpc:
3-
spidersrv:
4-
addr: :2048
5-
#reflection: enable
6-
#tls:
7-
# tls_cert: $CBSPIDER_ROOT/certs/server.crt
8-
# tls_key: $CBSPIDER_ROOT/certs/server.key
9-
interceptors:
10-
#auth_jwt:
11-
# jwt_key: your_secret_key
12-
prometheus_metrics:
13-
listen_port: 9092
14-
opentracing:
15-
jaeger:
16-
endpoint: localhost:6831
17-
service_name: spider grpc server
18-
sample_rate: 1
1+
version: 1
2+
grpc:
3+
spidersrv:
4+
addr: :2048
5+
#reflection: enable
6+
#tls:
7+
# tls_cert: $CBSPIDER_ROOT/certs/server.crt
8+
# tls_key: $CBSPIDER_ROOT/certs/server.key
9+
interceptors:
10+
#auth_jwt:
11+
# jwt_key: your_secret_key
12+
prometheus_metrics:
13+
listen_port: 9092
14+
opentracing:
15+
jaeger:
16+
endpoint: localhost:6831
17+
service_name: spider grpc server
18+
sample_rate: 1
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
version: 1
2-
grpc:
3-
tumblebugsrv:
4-
addr: :50252
5-
reflection: enable
6-
#tls:
7-
# tls_cert: $CBTUMBLEBUG_ROOT/certs/server.crt
8-
# tls_key: $CBTUMBLEBUG_ROOT/certs/server.key
9-
interceptors:
10-
#auth_jwt:
11-
# jwt_key: your_secret_key
12-
prometheus_metrics:
13-
listen_port: 9093
14-
opentracing:
15-
jaeger:
16-
endpoint: localhost:6832
17-
service_name: tumblebug grpc server
18-
sample_rate: 1
19-
spidercli:
20-
server_addr: cb-spider:2048
21-
timeout: 90s
22-
#tls:
23-
# tls_ca: $CBTUMBLEBUG_ROOT/certs/ca.crt
24-
interceptors:
25-
#auth_jwt:
26-
# jwt_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJUCI6IjEyNy4wLjAuMSIsImV4cGlyZSI6MTkwODMyNTY1OCwib3JnTmFtZSI6IkVUUkkiLCJ1c2VyTmFtZSI6IkhvbmdHaWxEb25nIn0.4lkjYduo8iwv4AcKH96MpTnk8d7HRhi_p1xlnvZts8A
27-
opentracing:
28-
jaeger:
29-
endpoint: localhost:6832
30-
service_name: spider grpc client for tumblebug
31-
sample_rate: 1
1+
version: 1
2+
grpc:
3+
tumblebugsrv:
4+
addr: :50252
5+
reflection: enable
6+
#tls:
7+
# tls_cert: $CBTUMBLEBUG_ROOT/certs/server.crt
8+
# tls_key: $CBTUMBLEBUG_ROOT/certs/server.key
9+
interceptors:
10+
#auth_jwt:
11+
# jwt_key: your_secret_key
12+
prometheus_metrics:
13+
listen_port: 9093
14+
opentracing:
15+
jaeger:
16+
endpoint: localhost:6832
17+
service_name: tumblebug grpc server
18+
sample_rate: 1
19+
spidercli:
20+
server_addr: cb-spider:2048
21+
timeout: 90s
22+
#tls:
23+
# tls_ca: $CBTUMBLEBUG_ROOT/certs/ca.crt
24+
interceptors:
25+
#auth_jwt:
26+
# jwt_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJUCI6IjEyNy4wLjAuMSIsImV4cGlyZSI6MTkwODMyNTY1OCwib3JnTmFtZSI6IkVUUkkiLCJ1c2VyTmFtZSI6IkhvbmdHaWxEb25nIn0.4lkjYduo8iwv4AcKH96MpTnk8d7HRhi_p1xlnvZts8A
27+
opentracing:
28+
jaeger:
29+
endpoint: localhost:6832
30+
service_name: spider grpc client for tumblebug
31+
sample_rate: 1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.3"
1+
version: "3.9"
22

33
services:
44
# The priority used by Compose to choose which env var value to use:
@@ -10,12 +10,13 @@ services:
1010

1111
# CB-Spider
1212
cb-spider:
13-
image: cloudbaristaorg/cb-spider:0.8.10
13+
image: cloudbaristaorg/cb-spider:0.8.19
1414
container_name: mc-infra-connector #cb-spider
1515
ports:
1616
- "0.0.0.0:1024:1024"
1717
- "0.0.0.0:2048:2048"
18-
- "0.0.0.0:4096:4096"
18+
networks:
19+
- spider_net
1920
volumes:
2021
- ./conf/cb-spider/:/root/go/src/github.com/mcc/cb-spider/conf/
2122
- ./data/cb-spider/meta_db/:/root/go/src/github.com/mcc/cb-spider/meta_db/
@@ -31,33 +32,37 @@ services:
3132

3233
# CB-Tumblebug
3334
cb-tumblebug:
34-
image: cloudbaristaorg/cb-tumblebug:0.8.4
35+
image: cloudbaristaorg/cb-tumblebug:0.8.13
3536
container_name: mc-infra-manager #cb-tumblebug
3637
ports:
3738
- "0.0.0.0:1323:1323"
38-
- "0.0.0.0:50252:50252"
39+
# - "0.0.0.0:50252:50252"
40+
networks:
41+
- spider_net
42+
- default
3943
depends_on:
40-
#- cb-restapigw
4144
- cb-spider
42-
# - cb-tumblebug-mysql
4345
volumes:
4446
- ./conf/cb-tumblebug/:/app/conf/
4547
- ./data/cb-tumblebug/meta_db/:/app/meta_db/
4648
- ./data/cb-tumblebug/log/:/app/log/
4749
environment:
4850
- SPIDER_CALL_METHOD=REST
4951
- SPIDER_REST_URL=http://cb-spider:1024/spider
50-
- DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly
52+
# - DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly
5153
- API_USERNAME=default
5254
- API_PASSWORD=default
53-
- CB_NETWORK_SERVICE_ENDPOINT=localhost:8053
54-
- CB_NETWORK_ETCD_ENDPOINTS="localhost:2379"
55-
- AUTOCONTROL_DURATION_MS=10000
55+
# - CB_NETWORK_SERVICE_ENDPOINT=localhost:8053
56+
# - CB_NETWORK_ETCD_ENDPOINTS="localhost:2379"
57+
# - AUTOCONTROL_DURATION_MS=10000
5658
- SELF_ENDPOINT=localhost:1323
57-
- GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore
58-
- API_DOC_PATH=/app/src/api/rest/docs/swagger.json
59+
# - GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore
60+
# - API_DOC_PATH=/app/src/api/rest/docs/swagger.json
5961
# - DB_URL=cb-tumblebug-mysql:3306
6062
# - DB_DATABASE=cb_tumblebug
6163
# - DB_USER=cb_tumblebug
6264
# - DB_PASSWORD=cb_tumblebug
63-
# - GODEBUG=netdns=go
65+
# - GODEBUG=netdns=go
66+
67+
networks:
68+
spider_net:

go.mod

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ require (
88
github.com/spf13/viper v1.10.1
99
)
1010

11-
require golang.org/x/net v0.22.0 // indirect
11+
require (
12+
github.com/tidwall/gjson v1.17.3 // indirect
13+
github.com/tidwall/match v1.1.1 // indirect
14+
github.com/tidwall/pretty v1.2.1 // indirect
15+
golang.org/x/net v0.22.0 // indirect
16+
)
1217

1318
require (
1419
github.com/fsnotify/fsnotify v1.7.0 // indirect

go.sum

+7
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
356356
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
357357
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
358358
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
359+
github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
360+
github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
361+
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
362+
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
363+
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
364+
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
365+
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
359366
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
360367
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
361368
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

src/cmd/apicall/parse.go

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package apicall
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
"strings"
8+
9+
"github.com/spf13/cobra"
10+
"github.com/tidwall/gjson"
11+
)
12+
13+
var swaggerFile string
14+
15+
// pullCmd represents the pull command
16+
var parseCmd = &cobra.Command{
17+
Use: "tool",
18+
Short: "Swagger JSON file parsing",
19+
Long: `Swagger JSON file parsing to assist in writing api.yaml files`,
20+
Run: func(cmd *cobra.Command, args []string) {
21+
parseJson()
22+
},
23+
}
24+
25+
func parseJson() {
26+
// swagger.json 파일 읽기
27+
data, err := os.ReadFile(swaggerFile)
28+
if err != nil {
29+
log.Fatalf("파일 읽기 오류: %s", err)
30+
}
31+
32+
json := string(data)
33+
34+
// 기본 정보 추출
35+
title := gjson.Get(json, "info.title")
36+
version := gjson.Get(json, "info.version")
37+
host := gjson.Get(json, "host")
38+
basePath := gjson.Get(json, "basePath")
39+
40+
fmt.Println("API Title:", title.String())
41+
fmt.Println("API Version:", version.String())
42+
fmt.Println("Host:", host.String())
43+
fmt.Println("Base Path:", basePath.String())
44+
45+
// paths 하위의 URI, method 및 operationId 추출
46+
paths := gjson.Get(json, "paths").Map()
47+
for path, methods := range paths {
48+
//fmt.Println("URI:", path)
49+
for method, details := range methods.Map() {
50+
operationId := details.Get("operationId")
51+
if strings.ToLower(method) == "parameters" {
52+
continue
53+
}
54+
55+
//fmt.Printf(" Method: %s, OperationId: %s\n", method, operationId.String())
56+
tmpActionName := convertActionlName(operationId.String())
57+
fmt.Printf(" %s:\n", tmpActionName)
58+
fmt.Printf(" method: %s\n", method)
59+
fmt.Printf(" resourcePath: %s\n", path)
60+
fmt.Printf(" description: %q\n", details.Get("description").String())
61+
}
62+
}
63+
}
64+
65+
func convertActionlName(tmpActionName string) string {
66+
//일부 특수 기호들 제거
67+
tmpActionName = strings.ReplaceAll(tmpActionName, ":", "-")
68+
tmpActionName = strings.ReplaceAll(tmpActionName, "`", "")
69+
tmpActionName = strings.ReplaceAll(tmpActionName, "'", "")
70+
//tmpActionName = strings.ReplaceAll(tmpActionName, "\n", " ")
71+
72+
//카멜타입으로 변경
73+
tmpActionName = toCamelCase(tmpActionName)
74+
75+
return tmpActionName
76+
}
77+
78+
func toCamelCase(str string) string {
79+
words := strings.Fields(str) // 문자열을 공백을 기준으로 단어로 분할
80+
var result strings.Builder
81+
for _, word := range words {
82+
result.WriteString(strings.Title(word)) // 각 단어의 첫 글자를 대문자로 만듦
83+
}
84+
return result.String()
85+
}
86+
87+
func init() {
88+
apiCmd.AddCommand(parseCmd)
89+
parseCmd.PersistentFlags().StringVarP(&swaggerFile, "file", "f", "../conf/swagger.json", "Swagger JSON file full path")
90+
}

src/cmd/apicall/root.go

+21-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package apicall
66
import (
77
"errors"
88
"fmt"
9+
"io/ioutil"
910
"strings"
1011

1112
"github.com/go-resty/resty/v2"
@@ -28,6 +29,7 @@ var queryString string
2829
var client = resty.New()
2930
var req = client.R()
3031
var sendData string
32+
var inputFileData string
3133
var fileData string
3234

3335
type ServiceInfo struct {
@@ -300,11 +302,26 @@ func SetBasicAuth() {
300302
}
301303

302304
// func SetReqData(req *resty.Request) {
303-
func SetReqData() {
304-
if isVerbose {
305-
fmt.Println("request data : \n" + sendData)
305+
func SetReqData() error {
306+
if inputFileData != "" {
307+
if isVerbose {
308+
fmt.Printf("use [%s] data file\n" + inputFileData)
309+
}
310+
311+
// 파일에서 데이터 읽기
312+
data, err := ioutil.ReadFile(inputFileData)
313+
if err != nil {
314+
return err
315+
}
316+
req.SetBody(data)
317+
} else {
318+
if isVerbose {
319+
fmt.Printf("request data : %s\n" + sendData)
320+
}
321+
req.SetBody(sendData)
306322
}
307-
req.SetBody(sendData)
323+
324+
return nil
308325
}
309326

310327
func ProcessResultInfo(resp *resty.Response) {

0 commit comments

Comments
 (0)