[ Agent ] [ Initialization ] - modify Initialization process - 1

This commit is contained in:
zeaslity
2023-11-08 16:42:08 +08:00
parent ffe29993b3
commit 25f1dd029a

View File

@@ -172,14 +172,14 @@ func shutdownRegisterQueueConnection(initFromServerQueue *rabbitmq.RabbitQueue,
func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo { func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo {
// 约定文件地址为 /octopus-agent/octopus-agent.conf // 约定文件地址为 /octopus-agent/octopus-agent.conf
var agentServerInfo *register.AgentServerInfo var agentServerInfo register.AgentServerInfo
yamlFile, err := ioutil.ReadFile(agentServerInfoConf) yamlFile, err := ioutil.ReadFile(agentServerInfoConf)
if err != nil { if err != nil {
panic(fmt.Errorf("failed to read YAML file: %v", err)) panic(fmt.Errorf("failed to read YAML file: %v", err))
} }
err = yaml.Unmarshal(yamlFile, &agentServerInfo) err = yaml.Unmarshal(yamlFile, agentServerInfo)
if err != nil { if err != nil {
panic(fmt.Errorf("failed to unmarshal YAML: %v", err)) panic(fmt.Errorf("failed to unmarshal YAML: %v", err))
} }
@@ -197,11 +197,11 @@ func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo
// build operator cache // build operator cache
BuildAgentOsOperator(agentServerInfo) BuildAgentOsOperator(agentServerInfo)
return agentServerInfo return &agentServerInfo
} }
// UniformAgentServerInfo uniform deal with ip // UniformAgentServerInfo uniform deal with ip
func UniformAgentServerInfo(agentServerInfo *register.AgentServerInfo) { func UniformAgentServerInfo(agentServerInfo register.AgentServerInfo) {
// reflect to iterator all field // reflect to iterator all field
log.Info("[Initialization] - UniformAgentServerInfo !") log.Info("[Initialization] - UniformAgentServerInfo !")
@@ -224,7 +224,7 @@ func UniformAgentServerInfo(agentServerInfo *register.AgentServerInfo) {
} }
func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) { func BuildAgentOsOperator(agentServerInfo register.AgentServerInfo) {
// 2023年8月4日 passthrough some key information // 2023年8月4日 passthrough some key information
ossOfflinePrefix := g.G.AgentConfig.GetString("octopus.agent.executor.ossOfflinePrefix") ossOfflinePrefix := g.G.AgentConfig.GetString("octopus.agent.executor.ossOfflinePrefix")
@@ -236,7 +236,7 @@ func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
agentOsOperator := executor.BuildAgentOsOperator(agentServerInfo.OSInfo, ossOfflinePrefix) agentOsOperator := executor.BuildAgentOsOperator(agentServerInfo.OSInfo, ossOfflinePrefix)
// assign the agentServerInfo // assign the agentServerInfo
agentOsOperator.AgentServerInfo = agentServerInfo agentOsOperator.AgentServerInfo = &agentServerInfo
// debug // debug
marshal, _ := json.Marshal(agentOsOperator) marshal, _ := json.Marshal(agentOsOperator)