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

20
http.go
View File

@ -220,7 +220,14 @@ func serveCluster(w http.ResponseWriter, r *http.Request) {
return 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() cfg, err := readConfig()
if err != nil { if err != nil {
@ -267,7 +274,16 @@ func serveCluster(w http.ResponseWriter, r *http.Request) {
cm.Data[addon.Name] = buf.String() 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: default:
http.NotFound(w, r) http.NotFound(w, r)