// UpdateCharts updates all charts func UpdateCharts(db storage.DB) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) startToken := "[helm-lint] <start>" endToken := "[helm-lint] <end>" if vars["startToken"] != "" { startToken = vars["startToken"] } if vars["endToken"] != "" { endToken = vars["endToken"] } var travisData map[string]travis.WebhookPayload decoder := json.NewDecoder(r.Body) if err := decoder.Decode(&travisData); err != nil { log.Printf("[ERROR] json couldn't be decoded: %s\n", err) } travisLog := travisData["payload"].Matrix[0].Log output := extractJSONFromLog(startToken, endToken, travisLog) for _, value := range output { db.Set(value) } }) }
// GetAllCharts responds with a list of charts and their quality metrics func GetAllCharts(db storage.DB) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { returning := db.GetAll() log.Printf("[DEBUG] Returning %d charts", returning) json.NewEncoder(w).Encode(returning) }) }
// GetChart responds with a single chart and its quality metrics func GetChart(db storage.DB) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) name := vars["name"] chart := db.Get(name) if chart.IsComplete() { log.Printf("[DEBUG] Chart being returned: %s\n", chart) json.NewEncoder(w).Encode(db.Get(name)) } else { log.Printf("[DEBUG] Chart with name: %s not found", name) http.Error(w, "", http.StatusNotFound) } }) }