New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TRT-1615: Create api to use the new variant registry #1616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -627,6 +627,29 @@ func (s *Server) jsonComponentTestVariantsFromBigQuery(w http.ResponseWriter, re | |
api.RespondWithJSON(http.StatusOK, w, outputs) | ||
} | ||
|
||
func (s *Server) jsonJobVariantsFromBigQuery(w http.ResponseWriter, req *http.Request) { | ||
if s.bigQueryClient == nil { | ||
api.RespondWithJSON(http.StatusBadRequest, w, map[string]interface{}{ | ||
"code": http.StatusBadRequest, | ||
"message": "job variants API is only available when google-service-account-credential-file is configured", | ||
}) | ||
return | ||
} | ||
outputs, errs := api.GetJobVariantsFromBigQuery(s.bigQueryClient, s.gcsBucket) | ||
if len(errs) > 0 { | ||
log.Warningf("%d errors were encountered while querying job variants from big query:", len(errs)) | ||
for _, err := range errs { | ||
log.Error(err.Error()) | ||
} | ||
api.RespondWithJSON(http.StatusInternalServerError, w, map[string]interface{}{ | ||
"code": http.StatusInternalServerError, | ||
"message": fmt.Sprintf("error querying job variants from big query: %v", errs), | ||
}) | ||
return | ||
} | ||
api.RespondWithJSON(http.StatusOK, w, outputs) | ||
} | ||
|
||
func (s *Server) jsonComponentReportFromBigQuery(w http.ResponseWriter, req *http.Request) { | ||
baseRelease, sampleRelease, testIDOption, variantOption, excludeOption, advancedOption, cacheOption, err := s.parseComponentReportRequest(req) | ||
if err != nil { | ||
|
@@ -1451,6 +1474,12 @@ func (s *Server) Serve() { | |
Capabilities: []string{LocalDBCapability}, | ||
HandlerFunc: s.jsonJobBugsFromDB, | ||
}, | ||
{ | ||
EndpointPath: "/api/job_variants", | ||
Description: "Reports all job variants defined in BigQuery", | ||
Capabilities: []string{ComponentReadinessCapability}, | ||
HandlerFunc: s.jsonJobVariantsFromBigQuery, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like all other apis under /api/jobs/ are specific to a job. This new one is not. Maybe not worth worrying about, but we could do /api/job_variants/ or /api/variants to designate that we're operating on a different resource/? We could also end up colliding with our wish to have an API to fetch the variants for a specific job. Probably should try to find another path to move it to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /api/variants is already taken. :) Let me do /api/job_variants/ for now. We need to clean up on those old variants API later. |
||
{ | ||
EndpointPath: "/api/pull_requests", | ||
Description: "Reports on pull requests", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive sorting.