하드코딩된 폴더들 const로 뺌
This commit is contained in:
@ -20,9 +20,15 @@ import (
|
|||||||
현재 접속 중인 Agent 목록을 보여줍니다.
|
현재 접속 중인 Agent 목록을 보여줍니다.
|
||||||
- http method : GET
|
- 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) {
|
func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) {
|
||||||
enc := json.NewEncoder(w)
|
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) {
|
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
|
var filename string
|
||||||
|
|
||||||
if version == "config" {
|
if version == "config" {
|
||||||
filename = path.Join(h.deployPath, name, version, "config.json")
|
filename = path.Join(h.deployPath, name, version, "config"+ext)
|
||||||
} else {
|
} else {
|
||||||
// deploys 폴더는 파일시스템 서비스이므로 다운로드 가능
|
// deploys 폴더는 파일시스템 서비스이므로 다운로드 가능
|
||||||
filename = path.Join(h.deployPath, name, version, name+ext)
|
filename = path.Join(h.deployPath, name, version, name+ext)
|
||||||
@ -180,14 +186,14 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
configPath := ""
|
configPath := ""
|
||||||
if _, err := os.Stat(path.Join(h.deployPath, name, "config", "config.json")); err == nil || errors.Is(err, fs.ErrExist) {
|
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(
|
h.Operation().Deploy(MakeDeployRequest(
|
||||||
shared.DeployRequest{
|
shared.DeployRequest{
|
||||||
Name: name,
|
Name: name,
|
||||||
Version: version,
|
Version: version,
|
||||||
Url: path.Join("deploys", name, version, latestFilename),
|
Url: path.Join(sub_folder_name_deploys, name, version, latestFilename),
|
||||||
Config: configPath,
|
Config: configPath,
|
||||||
},
|
},
|
||||||
targets,
|
targets,
|
||||||
@ -357,7 +363,7 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
var out []string
|
var out []string
|
||||||
for _, lf := range logfiles {
|
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)
|
enc := json.NewEncoder(w)
|
||||||
|
|||||||
@ -45,9 +45,10 @@ func NewHoustonHandler() HoustonServerWithHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
|
func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
|
||||||
storagePath := loadServerConfig().StorageRoot
|
config := loadServerConfig()
|
||||||
h.deployPath = path.Join(storagePath, "deploys")
|
storagePath := config.StorageRoot
|
||||||
h.downloadPath = path.Join(storagePath, "downloads")
|
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 {
|
if err := os.MkdirAll(h.deployPath, 0775); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user