[ Agent ] [ Initialization ] - modify Initialization process
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -190,12 +191,39 @@ func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo
|
|||||||
}
|
}
|
||||||
log.Info(fmt.Sprintf("agent server info is %v", string(jsonFormat)))
|
log.Info(fmt.Sprintf("agent server info is %v", string(jsonFormat)))
|
||||||
|
|
||||||
|
// uniform agent server info
|
||||||
|
UniformAgentServerInfo(agentServerInfo)
|
||||||
|
|
||||||
// build operator cache
|
// build operator cache
|
||||||
BuildAgentOsOperator(agentServerInfo)
|
BuildAgentOsOperator(agentServerInfo)
|
||||||
|
|
||||||
return 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) {
|
func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
|
||||||
|
|
||||||
// 2023年8月4日 passthrough some key information
|
// 2023年8月4日 passthrough some key information
|
||||||
|
|||||||
@@ -1077,19 +1077,19 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
|||||||
{
|
{
|
||||||
"sed",
|
"sed",
|
||||||
"-i",
|
"-i",
|
||||||
"s/HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
"s/$HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||||
"/root/wdd/harbor/harbor.yml",
|
"/root/wdd/harbor/harbor.yml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sed",
|
"sed",
|
||||||
"-i",
|
"-i",
|
||||||
"s/HarborHostPort/8033/g",
|
"s/$HarborHostPort/8033/g",
|
||||||
"/root/wdd/harbor/harbor.yml",
|
"/root/wdd/harbor/harbor.yml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sed",
|
"sed",
|
||||||
"-i",
|
"-i",
|
||||||
"s/HarborAdminPas/V2ryStr@ngPss/g",
|
"s/$HarborAdminPas/V2ryStr@ngPss/g",
|
||||||
"/root/wdd/harbor/harbor.yml",
|
"/root/wdd/harbor/harbor.yml",
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user