feat: addons pure yaml format

This commit is contained in:
Mikaël Cluseau 2018-07-07 16:39:55 +11:00
parent 54acc215ad
commit b188da84ed
1 changed files with 18 additions and 2 deletions

20
http.go
View File

@ -220,7 +220,14 @@ func serveCluster(w http.ResponseWriter, r *http.Request) {
return
}
clusterName, what := p[2], p[3]
clusterName := p[2]
p = strings.SplitN(p[3], ".", 2)
what := p[0]
format := ""
if len(p) > 1 {
format = p[1]
}
cfg, err := readConfig()
if err != nil {
@ -267,7 +274,16 @@ func serveCluster(w http.ResponseWriter, r *http.Request) {
cm.Data[addon.Name] = buf.String()
}
yaml.NewEncoder(w).Encode(cm)
switch format {
case "yaml":
for name, data := range cm.Data {
w.Write([]byte("\n# addon: " + name + "\n---\n\n"))
w.Write([]byte(data))
}
default:
yaml.NewEncoder(w).Encode(cm)
}
default:
http.NotFound(w, r)