Compare commits

..

10 Commits

2 changed files with 23 additions and 13 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
nohup /home/opdev/houston -client -logfile & nohup /home/opdev/houston -client -logfile > /dev/null &

View File

@ -34,6 +34,16 @@ func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) {
enc.Encode(allHosts) enc.Encode(allHosts)
} }
func readTagsFromFile(paths ...string) string {
raw, _ := os.ReadFile(path.Join(paths...))
if len(raw) > 0 {
tag := string(raw)
return strings.Trim(tag, "\n")
}
return ""
}
func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) { func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) {
files, err := os.ReadDir(h.deployPath) files, err := os.ReadDir(h.deployPath)
if err != nil { if err != nil {
@ -43,12 +53,16 @@ func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request
} }
getVersions := func(name string) []string { getVersions := func(name string) []string {
var out []string
vers, _ := os.ReadDir(path.Join(h.deployPath, name)) vers, _ := os.ReadDir(path.Join(h.deployPath, name))
mytags := readTagsFromFile(h.deployPath, name, "@tags")
out := []string{
mytags,
}
for _, fd := range vers { for _, fd := range vers {
if fd.IsDir() { if fd.IsDir() {
ver := fd.Name() ver := fd.Name()
files, _ := os.ReadDir(path.Join(h.deployPath, name, ver)) files, _ := os.ReadDir(path.Join(h.deployPath, name, ver))
vertags := readTagsFromFile(h.deployPath, name, ver, "@tags")
if len(files) > 0 { if len(files) > 0 {
for _, file := range files { for _, file := range files {
if strings.HasPrefix(file.Name(), "@") { if strings.HasPrefix(file.Name(), "@") {
@ -56,18 +70,14 @@ func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request
} }
downloadpath := path.Join(sub_folder_name_deploys, name, ver, file.Name()) downloadpath := path.Join(sub_folder_name_deploys, name, ver, file.Name())
ver = fmt.Sprintf("%s:%s", ver, downloadpath) ver = fmt.Sprintf("%s:%s", ver+mytags+vertags, downloadpath)
break break
} }
} }
vertags, _ := os.ReadFile(path.Join(h.deployPath, name, ver, "@tags")) out = append(out, ver)
out = append(out, ver+string(vertags))
} }
} }
mytags, _ := os.ReadFile(path.Join(h.deployPath, name, "@tags"))
if len(mytags) > 0 {
out = append(out, string(mytags))
}
return out return out
} }
@ -112,10 +122,10 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
if version == "config" { if version == "config" {
filename = path.Join(h.deployPath, name, version, "config"+ext) filename = path.Join(h.deployPath, name, version, "config"+ext)
tags, _ := os.ReadFile(path.Join(h.deployPath, name, version, "@tags")) tags := readTagsFromFile(h.deployPath, name, version, "@tags")
if !strings.Contains(string(tags), "#hidden") { if !strings.Contains(tags, "#hidden") {
tags = []byte(string(tags) + "#hidden") tags = tags + "#hidden"
os.WriteFile(path.Join(h.deployPath, name, version, "@tags"), tags, 0644) os.WriteFile(path.Join(h.deployPath, name, version, "@tags"), []byte(tags), 0644)
} }
} else { } else {
filename = path.Join(h.deployPath, name, version, name+ext) filename = path.Join(h.deployPath, name, version, name+ext)