From 40c25c0cae9b8602e1ddf36786c289207856b947 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 24 Nov 2019 19:10:09 +0000 Subject: [PATCH] app/appengine: remove unused tagHandler, document others, remove auth from init tagHandler isn't used by anything. Delete. Less code to update. And document who calls the other handlers. Also, remove the auth requirement from the /init handler. It's harmless to call without auth, and the login restriction went away with the Go 1.12+ runtime anyway, so deleting it gets us closer to being able to use the Go 1.12/Go 1.13 runtimes. (The plan is to delete most the code, port the small remaining bit to the cloud.google.com/go libraries so we can update to Go 1.12/Go 1.13+, and then at that point, since the cloud.google.com/go code will run anywhere, we can just run it in the same process as the coordinator.) Updates golang/go#34744 Change-Id: I929c70945a3e9e27b38b1d5899c7860470361927 Reviewed-on: https://go-review.googlesource.com/c/build/+/208678 Reviewed-by: Bryan C. Mills --- app/appengine/app.yaml | 4 ---- app/appengine/dash.go | 15 +++++++++------ app/appengine/handler.go | 23 ----------------------- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/app/appengine/app.yaml b/app/appengine/app.yaml index 6a84ec44..efbdf1ea 100644 --- a/app/appengine/app.yaml +++ b/app/appengine/app.yaml @@ -5,10 +5,6 @@ handlers: - url: /static static_dir: app/appengine/static secure: always - - url: /init - script: auto - login: admin - secure: always - url: /.* script: auto secure: always diff --git a/app/appengine/dash.go b/app/appengine/dash.go index 0e84386c..39de7225 100644 --- a/app/appengine/dash.go +++ b/app/appengine/dash.go @@ -18,12 +18,15 @@ func main() { handleFunc("/init", initHandler) // authenticated handlers - handleFunc("/building", AuthHandler(buildingHandler)) - handleFunc("/clear-results", AuthHandler(clearResultsHandler)) - handleFunc("/commit", AuthHandler(commitHandler)) - handleFunc("/packages", AuthHandler(packagesHandler)) - handleFunc("/result", AuthHandler(resultHandler)) - handleFunc("/tag", AuthHandler(tagHandler)) + handleFunc("/building", AuthHandler(buildingHandler)) // called by coordinator during builds + handleFunc("/clear-results", AuthHandler(clearResultsHandler)) // called by x/build/cmd/retrybuilds + handleFunc("/result", AuthHandler(resultHandler)) // called by coordinator after build + + // TODO: once we use maintner for finding the git history + // instead of having gitmirror mirror it into the dashboard, + // then we can delete these two handlers: + handleFunc("/commit", AuthHandler(commitHandler)) // called by gitmirror + handleFunc("/packages", AuthHandler(packagesHandler)) // called by gitmirror // public handlers handleFunc("/", uiHandler) diff --git a/app/appengine/handler.go b/app/appengine/handler.go index c60335a3..1fb75c16 100644 --- a/app/appengine/handler.go +++ b/app/appengine/handler.go @@ -205,29 +205,6 @@ func addCommit(c context.Context, com *Commit) error { return nil } -// tagHandler records a new tag. It reads a JSON-encoded Tag value from the -// request body and updates the Tag entity for the Kind of tag provided. -// -// This handler is used by a gobuilder process in -commit mode. -func tagHandler(r *http.Request) (interface{}, error) { - if r.Method != "POST" { - return nil, errBadMethod(r.Method) - } - - t := new(Tag) - defer r.Body.Close() - if err := json.NewDecoder(r.Body).Decode(t); err != nil { - return nil, err - } - if err := t.Valid(); err != nil { - return nil, err - } - c := contextForRequest(r) - defer cache.Tick(c) - _, err := datastore.Put(c, t.Key(c), t) - return nil, err -} - // packagesHandler returns a list of the non-Go Packages monitored // by the dashboard. func packagesHandler(r *http.Request) (interface{}, error) {