deploy, download 경로 지정

This commit is contained in:
2023-06-13 11:04:30 +09:00
parent 5c00ff73d7
commit 5f1b23ed80
2 changed files with 18 additions and 17 deletions

View File

@ -26,7 +26,7 @@ func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) {
}
func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) {
files, err := os.ReadDir("deploys")
files, err := os.ReadDir(h.deployPath)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
err = os.MkdirAll("deploys", 0775)
@ -41,7 +41,7 @@ func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request
getVersions := func(name string) []string {
var out []string
files, _ := os.ReadDir(path.Join("deploys", name))
files, _ := os.ReadDir(path.Join(h.deployPath, name))
for _, fd := range files {
if fd.IsDir() {
out = append(out, fd.Name())
@ -90,10 +90,10 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
var filename string
if version == "config" {
filename = path.Join("deploys", name, version, "config.json")
filename = path.Join(h.deployPath, name, version, "config.json")
} else {
// deploys 폴더는 파일시스템 서비스이므로 다운로드 가능
filename = path.Join("deploys", name, version, name+ext)
filename = path.Join(h.deployPath, name, version, name+ext)
}
if err = os.MkdirAll(path.Dir(filename), 0775); err != nil {
@ -125,7 +125,7 @@ func (h *houstonHandler) DeleteDeploySource(w http.ResponseWriter, r *http.Reque
}
// deploys 폴더는 파일시스템 서비스이므로 다운로드 가능
targetpath := path.Join("deploys", name, version)
targetpath := path.Join(h.deployPath, name, version)
if err := os.RemoveAll(targetpath); err != nil {
logger.Println("deleteDeploySource failed :", err)
w.WriteHeader(http.StatusInternalServerError)
@ -158,7 +158,7 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
return
}
relPath := path.Join("deploys", name, version)
relPath := path.Join(h.deployPath, name, version)
files, err := os.ReadDir(relPath)
if err != nil {
logger.Error(err)
@ -189,7 +189,7 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
Name: name,
Version: version,
Url: path.Join(relPath, latestFilename),
Config: path.Join("deploys", name, "config", "config.json"),
Config: path.Join(h.deployPath, name, "config", "config.json"),
},
targets,
))
@ -346,10 +346,10 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request)
}
if version == "latest" {
version, _ = shared.FindLastestVersion(path.Join("downloads", name))
version, _ = shared.FindLastestVersion(path.Join(h.downloadPath, name))
}
root := path.Join("downloads", name, version)
root := path.Join(h.downloadPath, name, version)
logfiles, err := os.ReadDir(root)
if err != nil {
w.WriteHeader(http.StatusBadRequest)