diff --git a/server/http_api.go b/server/http_api.go index 3b4fceb..c49d18a 100644 --- a/server/http_api.go +++ b/server/http_api.go @@ -20,9 +20,15 @@ import ( 현재 접속 중인 Agent 목록을 보여줍니다. - http method : GET */ +const ( + sub_folder_name_deploys = string("_deploys") + sub_folder_name_downloads = string("_downloads") +) + func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) { enc := json.NewEncoder(w) - enc.Encode(h.Operation().Hosts()) + allHosts := h.Operation().Hosts() + enc.Encode(allHosts) } func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) { @@ -84,7 +90,7 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque var filename string if version == "config" { - filename = path.Join(h.deployPath, name, version, "config.json") + filename = path.Join(h.deployPath, name, version, "config"+ext) } else { // deploys 폴더는 파일시스템 서비스이므로 다운로드 가능 filename = path.Join(h.deployPath, name, version, name+ext) @@ -180,14 +186,14 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) { configPath := "" if _, err := os.Stat(path.Join(h.deployPath, name, "config", "config.json")); err == nil || errors.Is(err, fs.ErrExist) { - configPath = path.Join("deploys", name, "config", "config.json") + configPath = path.Join(sub_folder_name_deploys, name, "config", "config.json") } h.Operation().Deploy(MakeDeployRequest( shared.DeployRequest{ Name: name, Version: version, - Url: path.Join("deploys", name, version, latestFilename), + Url: path.Join(sub_folder_name_deploys, name, version, latestFilename), Config: configPath, }, targets, @@ -357,7 +363,7 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request) var out []string for _, lf := range logfiles { - out = append(out, path.Join("downloads", name, version, lf.Name())) + out = append(out, path.Join(sub_folder_name_downloads, name, version, lf.Name())) } enc := json.NewEncoder(w) diff --git a/server/http_handler.go b/server/http_handler.go index 42e7a09..546153d 100644 --- a/server/http_handler.go +++ b/server/http_handler.go @@ -45,9 +45,10 @@ func NewHoustonHandler() HoustonServerWithHandler { } func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error { - storagePath := loadServerConfig().StorageRoot - h.deployPath = path.Join(storagePath, "deploys") - h.downloadPath = path.Join(storagePath, "downloads") + config := loadServerConfig() + storagePath := config.StorageRoot + h.deployPath = path.Join(storagePath, sub_folder_name_deploys) + h.downloadPath = path.Join(storagePath, sub_folder_name_downloads) if err := os.MkdirAll(h.deployPath, 0775); err != nil { return err