Skip to content

Commit

Permalink
[repolist.go] Manual build trigger button
Browse files Browse the repository at this point in the history
Closes #45

The button is added directly to the template
  • Loading branch information
cervenkam committed Jun 27, 2022
1 parent 31234a3 commit 7ee34f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/ginvalid/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions internal/resources/templates/repolist.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const RepoPage = `
{{range $hookname, $hook := .Hooks}}
<tr>
<td class="name text bold four wide"><a href="">{{$hookname | ToUpper}}</a></td>
<td class="name four wide"><form action="/privalidate" method="post">
<input type="hidden" name="validator" value="{{$hookname}}" />
<input type="hidden" name="repopath" value="{{$.FullName}}" />
<input type="submit" value="Run validation" />
</form></td>
{{if eq $hook.State 0}}
<td class="name nine wide"><a href="/results/{{$hookname | ToLower}}/{{$.FullName}}">RESULTS</a></td>
<td class="name three wide"><a href="/repos/{{$.FullName}}/{{$hook.ID}}/disable">DEACTIVATE</a></td>
Expand Down
13 changes: 12 additions & 1 deletion internal/web/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7ee34f7

Please sign in to comment.