完善证书部署路径与任务状态处理
This commit is contained in:
1 parent
09e449226a
commit
e68b8ec342
7 files changed
+136
-1
No files matched your search
@@ -132,6 +132,10 @@ func (s *Service) deployOne(ctx context.Context, server Server, artifact Artifac
|
||||
return result
|
||||
}
|
||||
}
|
||||
if err := validateDeploymentPaths(paths); err != nil {
|
||||
result.Message = err.Error()
|
||||
return result
|
||||
}
|
||||
backupID := s.backupID()
|
||||
type backup struct{ original, saved string }
|
||||
backups := make([]backup, 0, len(paths))
|
||||
@@ -211,6 +215,21 @@ type remoteFile struct {
|
||||
mode uint32
|
||||
}
|
||||
|
||||
func validateDeploymentPaths(files []remoteFile) error {
|
||||
seen := make(map[string]struct{}, len(files))
|
||||
for _, file := range files {
|
||||
cleaned := RemotePath(file.path)
|
||||
if cleaned == "" || cleaned == "." || !strings.HasPrefix(cleaned, "/") {
|
||||
return errors.New("远程证书路径必须是绝对路径")
|
||||
}
|
||||
if _, exists := seen[cleaned]; exists {
|
||||
return errors.New("远程证书、完整证书链和私钥不能使用相同路径")
|
||||
}
|
||||
seen[cleaned] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateArtifact(artifact Artifact) error {
|
||||
if len(artifact.Certificate) == 0 || len(artifact.FullChain) == 0 || len(artifact.PrivateKey) == 0 {
|
||||
return errors.New("证书部署文件不完整")
|
||||
|
||||
Reference in new issue
Block a user