[ Agent ] [ Initialization ] - modify Initialization process
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -190,12 +191,39 @@ func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo
|
||||
}
|
||||
log.Info(fmt.Sprintf("agent server info is %v", string(jsonFormat)))
|
||||
|
||||
// uniform agent server info
|
||||
UniformAgentServerInfo(agentServerInfo)
|
||||
|
||||
// build operator cache
|
||||
BuildAgentOsOperator(agentServerInfo)
|
||||
|
||||
return agentServerInfo
|
||||
}
|
||||
|
||||
// UniformAgentServerInfo uniform deal with ip
|
||||
func UniformAgentServerInfo(agentServerInfo *register.AgentServerInfo) {
|
||||
|
||||
// reflect to iterator all field
|
||||
log.Info("[Initialization] - UniformAgentServerInfo !")
|
||||
value := reflect.ValueOf(agentServerInfo)
|
||||
for i := 0; i < value.NumField(); i++ {
|
||||
field := value.Field(i)
|
||||
if field.Kind() == reflect.String && field.CanSet() {
|
||||
field.SetString(strings.TrimSpace(field.String()))
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("[Initialization] - uniform ip address !")
|
||||
if strings.Contains(agentServerInfo.ServerIPInV4, "/") {
|
||||
agentServerInfo.ServerIPInV4 = strings.Split(agentServerInfo.ServerIPInV4, "/")[0]
|
||||
}
|
||||
|
||||
if strings.Contains(agentServerInfo.ServerIPInV6, "/") {
|
||||
agentServerInfo.ServerIPInV6 = strings.Split(agentServerInfo.ServerIPInV6, "/")[0]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
|
||||
|
||||
// 2023年8月4日 passthrough some key information
|
||||
|
||||
@@ -1077,19 +1077,19 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||
"s/$HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/HarborHostPort/8033/g",
|
||||
"s/$HarborHostPort/8033/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/HarborAdminPas/V2ryStr@ngPss/g",
|
||||
"s/$HarborAdminPas/V2ryStr@ngPss/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
}})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user