复制config文件到pod
(k k8s.KubernetesUtil, pod coreV1.Pod, containerName string, podDestGitRepoPath string, agentFilePath string, runAsUserName string)
| 615 | |
| 616 | // 复制config文件到pod |
| 617 | func copyAgentToPod(k k8s.KubernetesUtil, pod coreV1.Pod, containerName string, podDestGitRepoPath string, agentFilePath string, runAsUserName string) error { |
| 618 | // 目录 |
| 619 | configFileDir := path.Dir(agentFilePath) |
| 620 | tempDirPath := common.PathJoin(configFileDir, ".temp") |
| 621 | if !common.IsExist(tempDirPath) { |
| 622 | err := os.MkdirAll(tempDirPath, os.ModePerm) |
| 623 | if err != nil { |
| 624 | return err |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | // 把文件写入到临时文件中 |
| 629 | input, err := os.ReadFile(agentFilePath) |
| 630 | if err != nil { |
| 631 | return err |
| 632 | } |
| 633 | tempAgentFilePath := common.PathJoin(tempDirPath, "smartide-agent") |
| 634 | err = os.WriteFile(tempAgentFilePath, input, 0775) |
| 635 | if err != nil { |
| 636 | return err |
| 637 | } |
| 638 | |
| 639 | // copy |
| 640 | destDir := common.PathJoin("/", "smartide-agent") |
| 641 | |
| 642 | err = k.CopyToPod(pod, containerName, tempDirPath, destDir, runAsUserName) |
| 643 | if err != nil { |
| 644 | return err |
| 645 | } |
| 646 | |
| 647 | return nil |
| 648 | } |
| 649 | |
| 650 | // 下载配置文件 和 关联的k8s yaml文件 |
| 651 | func downloadConfigAndLinkFiles(workspaceInfo workspace.WorkspaceInfo) ( |