[ Agent ] [ Executor ] - 增加Pipeline部分的代码

This commit is contained in:
zeaslity
2023-10-18 09:26:58 +08:00
parent 0e8f633166
commit be01eb28a9
8 changed files with 192 additions and 94 deletions

View File

@@ -518,80 +518,66 @@ func (op *AgentOsOperator) installDockerExec(args []string) (bool, []string) {
return false, l
}
executor, resultLog := AllCompleteExecutor([][]string{
{
"rm",
"-rf",
"/etc/apt/keyrings/docker.gpg",
},
{
"mkdir",
"-p",
"/etc/apt/keyrings",
},
})
if !executor {
return false, append(resultLog, "创建docker-key gpg文件失败")
}
dockerGPGFilePath := "/etc/apt/keyrings/docker.gpg"
dockerGPGSource := "https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg"
dockerAPTSource := "https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu"
// 安装镜像的证书
if op.IsAgentInnerWall {
// 国内 使用 UTSC 的源
ok, l2 := AllCommandExecutor([]string{
"curl",
"-o",
dockerGPGFilePath,
"https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg",
})
if !ok {
return false, l2
}
if !BasicFileExistAndNotNull(dockerGPGFilePath) {
return false, []string{"添加gpg失败"}
}
resultOk, log2 := AllCompleteExecutor([][]string{
{
"gpg",
"--dearmor",
"-o",
dockerGPGFilePath,
},
{
"chmod",
"a+r",
dockerGPGFilePath,
},
{
"add-apt-repository",
"deb [arch=" + op.AgentArch + "] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu " + op.AgentOSReleaseCode + " stable",
},
})
if !resultOk {
return false, log2
}
} else {
if !op.IsAgentInnerWall {
// outside world
// 国内 使用 UTSC 的源
ok, l2 := AllCommandExecutor([]string{
"curl",
dockerGPGSource = "https://download.docker.com/linux/ubuntu/gpg"
dockerAPTSource = "https://download.docker.com/linux/ubuntu"
}
ok, l2 := AllCommandExecutor([]string{
"curl",
"-fsSL",
dockerGPGSource,
"-o",
dockerGPGFilePath,
})
if !ok {
return false, append(l2, "下载docker gpg文件失败", dockerGPGSource, dockerAPTSource)
}
if !BasicFileExistAndNotNull(dockerGPGFilePath) {
return false, []string{"添加gpg失败"}
}
resultOk, log2 := AllCompleteExecutor([][]string{
{
"gpg",
"--dearmor",
"-o",
dockerGPGFilePath,
"https://download.docker.com/linux/ubuntu/gpg",
})
if !ok {
return false, l2
}
if !BasicFileExistAndNotNull(dockerGPGFilePath) {
return false, []string{"添加gpg失败"}
}
resultOk, log2 := AllCompleteExecutor([][]string{
{
"gpg",
"--dearmor",
"-o",
dockerGPGFilePath,
},
{
"chmod",
"a+r",
dockerGPGFilePath,
},
{
"add-apt-repository",
"deb [arch=" + op.AgentArch + "] https://download.docker.com/linux/ubuntu " + op.AgentOSReleaseCode + " stable",
},
})
if !resultOk {
return false, log2
}
},
{
"chmod",
"a+r",
dockerGPGFilePath,
},
{
"add-apt-repository",
"deb [arch=" + op.AgentArch + "] " + dockerAPTSource + " " + op.AgentOSReleaseCode + " stable",
},
})
if !resultOk {
return false, append(log2, "添加APT源失败")
}
// look for specific docker-version to install
@@ -607,7 +593,7 @@ func (op *AgentOsOperator) installDockerExec(args []string) (bool, []string) {
specificDockerVersion = "5:20.10.10~3-0~ubuntu-" + op.AgentOSReleaseCode
}
resultOk, log2 := AllCommandExecutor([]string{
resultOk, log2 = AllCommandExecutor([]string{
"docker-ce=" + specificDockerVersion,
"docker-ce-cli=" + specificDockerVersion,
"containerd.io",
@@ -1177,7 +1163,7 @@ func (op *AgentOsOperator) installZSHExec() (bool, []string) {
executor, log2 := AllCompleteExecutor([][]string{
{
"chomd",
"chmod",
"+x",
"/root/wdd/zsh-install.sh",
},