go.tools/dashboard/app: require version=2 for commit updates
This will prevent older, buggy builders from posting commits. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/153930043
This commit is contained in:
parent
cccd43354a
commit
8f69c6b2df
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
|
@ -26,6 +27,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const commitsPerPage = 30
|
const commitsPerPage = 30
|
||||||
|
const watcherVersion = 2
|
||||||
|
|
||||||
// commitHandler retrieves commit data or records a new commit.
|
// commitHandler retrieves commit data or records a new commit.
|
||||||
//
|
//
|
||||||
|
|
@ -71,6 +73,16 @@ func commitHandler(r *http.Request) (interface{}, error) {
|
||||||
return nil, errors.New("can only POST commits with master key")
|
return nil, errors.New("can only POST commits with master key")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For now, the commit watcher doesn't support gccgo,
|
||||||
|
// so only do this check for Go commits.
|
||||||
|
// TODO(adg,cmang): remove this check when gccgo is supported.
|
||||||
|
if dashboardForRequest(r) == goDash {
|
||||||
|
v, _ := strconv.Atoi(r.FormValue("version"))
|
||||||
|
if v != watcherVersion {
|
||||||
|
return nil, fmt.Errorf("rejecting POST from commit watcher; need version %v", watcherVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// POST request
|
// POST request
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue