From 7ee34f7422b358b8ac0ffb90c964de28d6058253 Mon Sep 17 00:00:00 2001 From: Martin Cervenka Date: Fri, 24 Jun 2022 09:33:06 +0200 Subject: [PATCH] [repolist.go] Manual build trigger button Closes #45 The button is added directly to the template --- cmd/ginvalid/main.go | 1 + internal/resources/templates/repolist.go | 5 +++++ internal/web/validate.go | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/ginvalid/main.go b/cmd/ginvalid/main.go index 82d65a4..d804ce5 100644 --- a/cmd/ginvalid/main.go +++ b/cmd/ginvalid/main.go @@ -41,6 +41,7 @@ func registerRoutes(r *mux.Router) { r.HandleFunc("/", web.Root) r.HandleFunc("/pubvalidate", web.PubValidateGet).Methods("GET") r.HandleFunc("/pubvalidate", web.PubValidatePost).Methods("POST") + r.HandleFunc("/privalidate", web.PriValidatePost).Methods("POST") r.HandleFunc("/validate/{validator}/{user}/{repo}", web.Validate).Methods("POST") r.HandleFunc("/status/{validator}/{user}/{repo}", web.Status).Methods("GET") r.HandleFunc("/results/{validator}/{user}/{repo}", web.Results).Methods("GET") diff --git a/internal/resources/templates/repolist.go b/internal/resources/templates/repolist.go index bc0dcbd..cd7d46a 100644 --- a/internal/resources/templates/repolist.go +++ b/internal/resources/templates/repolist.go @@ -84,6 +84,11 @@ const RepoPage = ` {{range $hookname, $hook := .Hooks}} {{$hookname | ToUpper}} +
+ + + +
{{if eq $hook.State 0}} RESULTS DEACTIVATE diff --git a/internal/web/validate.go b/internal/web/validate.go index ab373b2..bc8706f 100644 --- a/internal/web/validate.go +++ b/internal/web/validate.go @@ -635,6 +635,17 @@ func PubValidateGet(w http.ResponseWriter, r *http.Request) { // PubValidatePost parses the POST data from the root form and calls the // validator using the built-in ServiceWaiter. func PubValidatePost(w http.ResponseWriter, r *http.Request) { + validatePost(w, r, true) +} + +// PriValidatePost parses the POST data from the root form and calls the +// validator using the built-in ServiceWaiter. Private repositories are +// allowed here +func PriValidatePost(w http.ResponseWriter, r *http.Request) { + validatePost(w, r, false) +} + +func validatePost(w http.ResponseWriter, r *http.Request, private bool) { srvcfg := config.Read() ginuser := srvcfg.Settings.GINUser @@ -665,7 +676,7 @@ func PubValidatePost(w http.ResponseWriter, r *http.Request) { fail(w, http.StatusNotFound, err.Error()) return } - if repoinfo.Private { + if repoinfo.Private && private { // We (the built in ServiceWaiter) have access, but the repository is // marked private. This can happen if an owner of the private // repository adds the user as a collaborator to the repository. We