Skip to content

Commit 03f8ac6

Browse files
author
piexlMax(奇淼
committed
Add registration parameters
1 parent def9706 commit 03f8ac6

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

global/config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ func InitViper() {
2626
var version string
2727
var name string
2828
var auto bool
29+
var projectGroupId int
30+
var projectTemplateId int
2931

3032
flag.StringVar(&version, "DongtaiGoProjectVersion", "v1.0.0", "Project Version")
3133
flag.StringVar(&name, "DongtaiGoProjectName", "GO Project", "Project Name")
3234
flag.BoolVar(&auto, "DongtaiGoProjectCreate", true, "Auto Create Project")
35+
flag.IntVar(&projectGroupId, "DongtaiGoProjectGroupId", 1, "Group ID")
36+
flag.IntVar(&projectTemplateId, "DongtaiGoProjectTemplateId", 1, "Template ID")
37+
3338
flag.Parse()
3439
if version != "v1.0.0" {
3540
Config.DongtaiGoProjectVersion = version
@@ -40,5 +45,12 @@ func InitViper() {
4045
if auto != true {
4146
Config.DongtaiGoProjectCreate = auto
4247
}
48+
if projectGroupId != 1 {
49+
Config.DongtaiGoProjectGroupId = projectGroupId
50+
}
51+
if projectTemplateId != 1 {
52+
Config.DongtaiGoProjectTemplateId = projectTemplateId
53+
}
54+
4355
fmt.Println(Config)
4456
}

model/config.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package model
22

33
type Config struct {
4-
DongtaiGoOpenapi string `yaml:"DongtaiGoOpenapi"`
5-
DongtaiGoToken string `yaml:"DongtaiGoToken"`
6-
DongtaiGoProjectName string `yaml:"DongtaiGoProjectName"`
7-
DongtaiGoProjectVersion string `yaml:"DongtaiGoProjectVersion"`
8-
DongtaiGoProjectCreate bool `yaml:"DongtaiGoProjectCreate"`
4+
DongtaiGoOpenapi string `yaml:"DongtaiGoOpenapi"`
5+
DongtaiGoToken string `yaml:"DongtaiGoToken"`
6+
DongtaiGoProjectName string `yaml:"DongtaiGoProjectName"`
7+
DongtaiGoProjectVersion string `yaml:"DongtaiGoProjectVersion"`
8+
DongtaiGoProjectCreate bool `yaml:"DongtaiGoProjectCreate"`
9+
DongtaiGoProjectGroupId int `yaml:"DongtaiGoProjectGroupId"`
10+
DongtaiGoProjectTemplateId int `yaml:"DongtaiGoProjectTemplateId"`
911
}

model/request/engine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type AgentRegisterReq struct {
2525
ServerEnv string `json:"serverEnv"`
2626
Pid string `json:"pid"`
2727
ProjectVersion string `json:"projectVersion"`
28+
ProjectGroupId int `json:"projectGroupId"`
29+
ProjectTemplateId int `json:"projectTemplateId"`
2830
}
2931

3032
type HookRuleReq struct {

service/engine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ func AgentRegister() (err error) {
145145
ServerPath: filePath,
146146
ServerEnv: encodeEnv,
147147
Pid: strconv.Itoa(pid),
148+
ProjectGroupId: global.Config.DongtaiGoProjectGroupId,
149+
ProjectTemplateId: global.Config.DongtaiGoProjectTemplateId,
148150
}
149151
go func() {
150152
for {

0 commit comments

Comments
 (0)