summaryrefslogtreecommitdiffhomepage
path: root/cmd/gvisor-website
diff options
context:
space:
mode:
authorIan Lewis <ianmlewis@gmail.com>2019-10-18 01:37:17 -0400
committerIan Lewis <ianlewis@google.com>2019-11-19 14:14:46 -0800
commit00471432c45e215081020b0fac54a27f4bcbf565 (patch)
treead458ba107d38d61b9fc259381d97f60501093e3 /cmd/gvisor-website
parent8c89ebd4315d24dfdf6afd79ba4838791e7228a7 (diff)
Update to Go 1.12 runtime.
Update to the Go 1.12 runtime. - The login option in app.yaml is no longer supported. Check the X-Appengine-Cron http header instead. - Add a 'stage' make target that allows you to easily stage a change.
Diffstat (limited to 'cmd/gvisor-website')
-rw-r--r--cmd/gvisor-website/app.yaml3
-rw-r--r--cmd/gvisor-website/main.go16
2 files changed, 16 insertions, 3 deletions
diff --git a/cmd/gvisor-website/app.yaml b/cmd/gvisor-website/app.yaml
index cc51c0462..b3e8782ee 100644
--- a/cmd/gvisor-website/app.yaml
+++ b/cmd/gvisor-website/app.yaml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-runtime: go111
+runtime: go112
handlers:
- url: /.*
@@ -21,4 +21,3 @@ handlers:
- url: /rebuild
secure: always
script: auto
- login: admin
diff --git a/cmd/gvisor-website/main.go b/cmd/gvisor-website/main.go
index f4354f943..01ad9153a 100644
--- a/cmd/gvisor-website/main.go
+++ b/cmd/gvisor-website/main.go
@@ -71,6 +71,20 @@ var (
goGetHTML5 = `<!doctype html><html><head><meta charset=utf-8>` + goGetHeader + `<title>Go-get</title></head><body></html>`
)
+// cronHandler wraps an http.Handler to check that the request is from the App
+// Engine Cron service.
+// See: https://cloud.google.com/appengine/docs/standard/go112/scheduling-jobs-with-cron-yaml#validating_cron_requests
+func cronHandler(h http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Header.Get("X-Appengine-Cron") != "true" {
+ http.NotFound(w, r)
+ return
+ }
+ // Fallthrough.
+ h.ServeHTTP(w, r)
+ })
+}
+
// wrappedHandler wraps an http.Handler.
//
// If the query parameters include go-get=1, then we redirect to a single
@@ -174,7 +188,7 @@ func registerRebuild(mux *http.ServeMux) {
mux = http.DefaultServeMux
}
- mux.Handle("/rebuild", wrappedHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mux.Handle("/rebuild", cronHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.Background()
credentials, err := google.FindDefaultCredentials(ctx, cloudbuild.CloudPlatformScope)
if err != nil {