vcs-test: delete
Thank you vcs-test for the service.
For golang/go#27494.
Fixes golang/go#61425.
Change-Id: I02fa14017dfeae28ebaf02d2a68ec467f14b2466
Co-authored-by: Heschi Kreinick <heschi@google.com>
Reviewed-on: https://go-review.googlesource.com/c/build/+/510896
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
diff --git a/cmd/buildlet/buildlet.go b/cmd/buildlet/buildlet.go
index b18e317..abe8268 100644
--- a/cmd/buildlet/buildlet.go
+++ b/cmd/buildlet/buildlet.go
@@ -1949,10 +1949,6 @@
return
}
}
- const vcsTestGolangOrgIPOnVM = "35.184.38.56" // vcs-test.golang.org, on previous VM
- runOrLog(exec.Command(iptables, "-I", "OUTPUT", "1", "-m", "state", "--state", "NEW", "-d", vcsTestGolangOrgIPOnVM, "-p", "tcp", "-j", "ACCEPT"))
- const vcsTestGolangOrgIP = "34.110.184.62" // vcs-test.golang.org, on GKE
- runOrLog(exec.Command(iptables, "-I", "OUTPUT", "1", "-m", "state", "--state", "NEW", "-d", vcsTestGolangOrgIP, "-p", "tcp", "-j", "ACCEPT"))
runOrLog(exec.Command(iptables, "-I", "OUTPUT", "2", "-m", "state", "--state", "NEW", "-d", "10.0.0.0/8", "-p", "tcp", "-j", "ACCEPT"))
runOrLog(exec.Command(iptables, "-I", "OUTPUT", "3", "-m", "state", "--state", "NEW", "-p", "tcp", "--dport", "443", "-j", "REJECT", "--reject-with", "icmp-host-prohibited"))
runOrLog(exec.Command(iptables, "-I", "OUTPUT", "3", "-m", "state", "--state", "NEW", "-p", "tcp", "--dport", "80", "-j", "REJECT", "--reject-with", "icmp-host-prohibited"))
diff --git a/vcs-test/Dockerfile b/vcs-test/Dockerfile
deleted file mode 100644
index d8c3fa7..0000000
--- a/vcs-test/Dockerfile
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2022 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-FROM golang:1.20-bookworm AS build
-LABEL maintainer="golang-dev@googlegroups.com"
-
-RUN mkdir /gocache
-ENV GOCACHE /gocache
-
-COPY go.mod /go/src/golang.org/x/build/go.mod
-COPY go.sum /go/src/golang.org/x/build/go.sum
-
-WORKDIR /go/src/golang.org/x/build
-
-# Download module dependencies to improve speed of re-building the
-# Docker image during minor code changes.
-RUN go mod download
-
-COPY . /go/src/golang.org/x/build/
-
-RUN go install golang.org/x/build/vcs-test/vcweb
-
-FROM debian:bookworm
-LABEL maintainer="golang-dev@googlegroups.com"
-
-# Commands necessary to run various VCS servers.
-# Subversion is handled by the Apache sidecar pod.
-RUN apt-get update && apt-get install -y \
- --no-install-recommends \
- ca-certificates \
- mercurial \
- fossil \
- bzr \
- git \
- tini \
- && rm -rf /var/lib/apt/lists/*
-
-COPY --from=build /go/bin/vcweb /
-ENTRYPOINT ["/usr/bin/tini", "--", "/vcweb"]
diff --git a/vcs-test/Dockerfile.apache b/vcs-test/Dockerfile.apache
deleted file mode 100644
index 467c216..0000000
--- a/vcs-test/Dockerfile.apache
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2022 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-FROM debian:stable
-LABEL maintainer="golang-dev@googlegroups.com"
-
-# For interacting with the Go source & subrepos
-RUN apt-get update && apt-get install -y \
- --no-install-recommends \
- apache2 \
- libapache2-mod-svn \
- subversion \
- && rm -rf /var/lib/apt/lists/*
-
-RUN sed -i 's/80/8888/' /etc/apache2/ports.conf
-
-COPY vcs-test/dav_svn.conf /etc/apache2/mods-enabled/dav_svn.conf
-
-ENTRYPOINT ["apachectl", "-D", "FOREGROUND"]
\ No newline at end of file
diff --git a/vcs-test/Makefile b/vcs-test/Makefile
deleted file mode 100644
index 706399c..0000000
--- a/vcs-test/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2022 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-MUTABLE_VERSION ?= latest
-VERSION ?= $(shell git rev-parse --short HEAD)
-
-IMAGE_PROD := gcr.io/symbolic-datum-552/vcs-test
-IMAGE_PROD_APACHE := gcr.io/symbolic-datum-552/vcs-test-apache
-
-docker-prod: Dockerfile Dockerfile.apache
- docker build --force-rm -f Dockerfile --tag=$(IMAGE_PROD):$(VERSION) ../
- docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_PROD):$(MUTABLE_VERSION)
- docker build --force-rm -f Dockerfile.apache --tag=$(IMAGE_PROD_APACHE):$(VERSION) ../
- docker tag $(IMAGE_PROD_APACHE):$(VERSION) $(IMAGE_PROD_APACHE):$(MUTABLE_VERSION)
-
-push-prod: docker-prod
- docker push $(IMAGE_PROD):$(VERSION)
- docker push $(IMAGE_PROD):$(MUTABLE_VERSION)
- docker push $(IMAGE_PROD_APACHE):$(VERSION)
- docker push $(IMAGE_PROD_APACHE):$(MUTABLE_VERSION)
-
-
-deploy-prod: push-prod
- go install golang.org/x/build/cmd/xb
- xb --prod kubectl --namespace prod set image deployment/vcs-test-deployment vcs-test=$(IMAGE_PROD):$(VERSION) apache=$(IMAGE_PROD_APACHE):$(VERSION)
diff --git a/vcs-test/README.md b/vcs-test/README.md
deleted file mode 100644
index a0dc30c..0000000
--- a/vcs-test/README.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# vcs-test
-
-We run a version control server for testing at `vcs-test.golang.org`.
-
-## Repositories
-
-The server can serve Bazaar, Fossil, Git, Mercurial, and Subversion repositories.
-The root of each repository is `https://vcs-test.golang.org/VCS/REPONAME`,
-where `VCS` is the version control system's command name (`bzr` for Bazaar, and so on),
-and `REPONAME` is the repository name.
-
-To serve a particular repository, the server downloads
-`gs://vcs-test/VCS/REPONAME.zip` from Google Cloud Storage and unzips it
-into an empty directory.
-The result should be a valid repository directory for the given version control system.
-If the needed format of the zip file is unclear, download and inspect `gs://vcs-test/VCS/hello.zip`
-from `https://vcs-test.storage.googleapis.com/VCS/hello.zip`.
-
-Google Cloud Storage imposes a default `Cache-Control` policy of 3600 seconds for
-publicly-readable objects; for instructions to disable caching per object, see
-[`gsutil setmeta`](https://cloud.google.com/storage/docs/gsutil/commands/setmeta).
-`vcweb` itself may serve stale data for up to five minutes after a zip file is updated.
-To force a rescan of Google Cloud Storage, fetch
-`https://vcs-test.golang.org/VCS/REPONAME?vcweb-force-reload=1`.
-
-## Static files
-
-The URL space `https://vcs-test.golang.org/go/NAME` is served by static files,
-fetched from `gs://vcs-test/go/NAME.zip`.
-The main use for static files is to write redirect HTML.
-See `gs://vcs-test/go/hello.zip` for examples.
-Note that because the server uses `http.DetectContentType` to deduce
-the content type from file data, it is not necessary to
-name HTML files with a `.html` suffix.
-
-## HTTPS
-
-The server fetches an HTTPS certificate on demand from Let's Encrypt,
-using `golang.org/x/crypto/acme/autocert`.
-It caches the certificates in `gs://vcs-test-autocert` using
-`golang.org/x/build/autocertcache`.
-
diff --git a/vcs-test/dav_svn.conf b/vcs-test/dav_svn.conf
deleted file mode 100644
index 2de29c8..0000000
--- a/vcs-test/dav_svn.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-<Location /svn>
- DAV svn
- SVNParentPath /home/vcweb/svn
- <LimitExcept GET PROPFIND OPTIONS REPORT>
- Require all denied
- </LimitExcept>
-</Location>
diff --git a/vcs-test/deployment.yaml b/vcs-test/deployment.yaml
deleted file mode 100644
index b9f0924..0000000
--- a/vcs-test/deployment.yaml
+++ /dev/null
@@ -1,115 +0,0 @@
-# Copyright 2022 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- namespace: prod
- name: vcs-test-deployment
-spec:
- # Because of the shared disk there can only be one instance.
- replicas: 1
- strategy:
- type: Recreate
-
- selector:
- matchLabels:
- app: vcs-test
- template:
- metadata:
- labels:
- app: vcs-test
- spec:
- serviceAccountName: vcs-test
- volumes:
- - name: vcs-test-cache
- persistentVolumeClaim:
- claimName: vcs-test-cache-claim
- containers:
- - name: vcs-test
- image: gcr.io/symbolic-datum-552/vcs-test:latest
- imagePullPolicy: Always
- command: ["/usr/bin/tini", "--", "/vcweb", "-d=/home/vcweb", "-listen-https-selfsigned=:444"]
- volumeMounts:
- - mountPath: /home/vcweb
- name: vcs-test-cache
- ports:
- - containerPort: 444
- resources:
- requests:
- cpu: "1"
- memory: "2Gi"
- - name: apache
- image: gcr.io/symbolic-datum-552/vcs-test-apache:latest
- imagePullPolicy: Always
- volumeMounts:
- - mountPath: /home/vcweb
- name: vcs-test-cache
- ports:
- - containerPort: 8888
- resources:
- requests:
- cpu: "1"
- memory: "1Gi"
----
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- namespace: prod
- name: vcs-test-cache-claim
-spec:
- storageClassName: standard-rwo
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 10Gi
----
-apiVersion: v1
-kind: Service
-metadata:
- namespace: prod
- name: vcs-test-internal
- annotations:
- cloud.google.com/neg: '{"ingress": false}'
- cloud.google.com/app-protocols: '{"https":"HTTP2"}'
-spec:
- ports:
- - port: 444
- targetPort: 444
- name: https
- selector:
- app: vcs-test
- type: NodePort
----
-apiVersion: networking.k8s.io/v1
-kind: Ingress
-metadata:
- namespace: prod
- name: vcs-test-ingress
- annotations:
- kubernetes.io/ingress.global-static-ip-name: vcs-test-global
- networking.gke.io/managed-certificates: vcs-test-cert
- kubernetes.io/ingress.class: "gce"
-spec:
- rules:
- - host: vcs-test.golang.org
- http:
- paths:
- - pathType: ImplementationSpecific
- path: /*
- backend:
- service:
- name: vcs-test-internal
- port:
- number: 444
----
-apiVersion: networking.gke.io/v1
-kind: ManagedCertificate
-metadata:
- namespace: prod
- name: vcs-test-cert
-spec:
- domains:
- - vcs-test.golang.org
diff --git a/vcs-test/vcweb/auth.go b/vcs-test/vcweb/auth.go
deleted file mode 100644
index a8d2198..0000000
--- a/vcs-test/vcweb/auth.go
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "log"
- "net/http"
- "os"
- pathpkg "path"
- "strings"
-)
-
-type accessToken struct {
- Username, Password string
- StatusCode int // defaults to 401.
- Message string
-}
-
-// newAuthHandler serves authenticated data from within dir.
-//
-// For each request, the handler looks for a file in a parent directory (still
-// within dir) named ".access" and parses it as a JSON-serialized accessToken.
-// If the credentials from the request match the accessToken, the file is served
-// normally; otherwise, it is rejected with the StatusCode and Message provided
-// by the token.
-func newAuthHandler(dir http.FileSystem) http.Handler {
- return &authHandler{dir}
-}
-
-type authHandler struct {
- dir http.FileSystem
-}
-
-func (h *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if !strings.HasPrefix(r.URL.Path, "/auth/") {
- http.Error(w, "path does not start with /auth/", http.StatusInternalServerError)
- return
- }
-
- path := strings.TrimPrefix(r.URL.Path, "/auth/")
- if path == "" {
- http.NotFound(w, r)
- return
- }
- if strings.HasPrefix(pathpkg.Base(path), ".") {
- http.Error(w, "filename contains leading dot", http.StatusBadRequest)
- return
- }
-
- f, err := h.dir.Open(path)
- if err != nil {
- if os.IsNotExist(err) {
- http.NotFound(w, r)
- } else {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- }
- return
- }
-
- accessDir := path
- if fi, err := f.Stat(); err == nil && !fi.IsDir() {
- accessDir = pathpkg.Dir(path)
- }
- f.Close()
-
- var accessFile http.File
- for {
- var err error
- accessFile, err = h.dir.Open(pathpkg.Join(accessDir, ".access"))
- if err == nil {
- break
- }
-
- if !os.IsNotExist(err) {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- if accessDir == "." {
- http.Error(w, "failed to locate access file", http.StatusInternalServerError)
- return
- }
- accessDir = pathpkg.Dir(accessDir)
- }
-
- data, err := io.ReadAll(accessFile)
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
-
- var token accessToken
- if err := json.Unmarshal(data, &token); err != nil {
- log.Print(err)
- http.Error(w, "malformed access file", http.StatusInternalServerError)
- return
- }
- if username, password, ok := r.BasicAuth(); !ok || username != token.Username || password != token.Password {
- code := token.StatusCode
- if code == 0 {
- code = http.StatusUnauthorized
- }
- if code == http.StatusUnauthorized {
- w.Header().Add("WWW-Authenticate", fmt.Sprintf("basic realm=%s", accessDir))
- }
- http.Error(w, token.Message, code)
- return
- }
-
- http.StripPrefix("/auth/", http.FileServer(h.dir)).ServeHTTP(w, r)
-}
diff --git a/vcs-test/vcweb/bzr.go b/vcs-test/vcweb/bzr.go
deleted file mode 100644
index 224ef4e..0000000
--- a/vcs-test/vcweb/bzr.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "net/http"
- "path/filepath"
-)
-
-func bzrHandler() http.Handler {
- return http.StripPrefix("/bzr/", http.FileServer(http.Dir(filepath.Join(*dir, "bzr"))))
-}
diff --git a/vcs-test/vcweb/deathclock_go121_test.go b/vcs-test/vcweb/deathclock_go121_test.go
deleted file mode 100644
index b2a502b..0000000
--- a/vcs-test/vcweb/deathclock_go121_test.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build go1.23
-
-package main_test
-
-func init() {
- // By the time development begins for the Go 1.23 cycle, no matter how early
- // it happens, Go 1.19 will definitely be unsupported.
- go119Unsupported = true
-}
diff --git a/vcs-test/vcweb/deathclock_test.go b/vcs-test/vcweb/deathclock_test.go
deleted file mode 100644
index 421cc65..0000000
--- a/vcs-test/vcweb/deathclock_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main_test
-
-import "testing"
-
-var go119Unsupported = false
-
-var turndownMsg = `
-Since Go 1.19 is definitely not longer supported by now,
-vcs-test.golang.org is no longer needed for testing any release branch and should have been turned
-down, and x/build/vcs-test/... should have been deleted.
-(See https://go.dev/issue/61425.)`
-
-func TestTurnDownVCSTest(t *testing.T) {
- if !go119Unsupported {
- return
- }
-
- if testing.Short() {
- t.Log(turndownMsg)
- } else {
- t.Fatal(turndownMsg)
- }
-}
diff --git a/vcs-test/vcweb/fossil.go b/vcs-test/vcweb/fossil.go
deleted file mode 100644
index 3baf4be..0000000
--- a/vcs-test/vcweb/fossil.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "net/http"
- "net/http/cgi"
- "os"
- "path/filepath"
- "strings"
-)
-
-func fossilHandler() http.Handler {
- return http.HandlerFunc(fossilDispatch)
-}
-
-func fossilDispatch(w http.ResponseWriter, r *http.Request) {
- if !strings.HasPrefix(r.URL.Path, "/fossil/") {
- w.WriteHeader(404)
- return
- }
- name := strings.TrimPrefix(r.URL.Path, "/fossil/")
- if i := strings.Index(name, "/"); i >= 0 {
- name = name[:i]
- }
-
- db := filepath.Join(*dir, "fossil/"+name+"/"+name+".fossil")
- _, err := os.Stat(db)
- if err != nil {
- w.WriteHeader(404)
- }
- if _, err := os.Stat(db + ".cgi"); err != nil {
- os.WriteFile(db+".cgi", []byte("#!/usr/bin/fossil\nrepository: "+db+"\n"), 0777)
- }
-
- h := &cgi.Handler{
- Path: db + ".cgi",
- Root: "/fossil/" + name,
- Dir: filepath.Join(*dir, "fossil"),
- }
- h.ServeHTTP(w, r)
-}
diff --git a/vcs-test/vcweb/git.go b/vcs-test/vcweb/git.go
deleted file mode 100644
index 35df622..0000000
--- a/vcs-test/vcweb/git.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "log"
- "net/http"
- "net/http/cgi"
- "os"
- "os/exec"
- "path/filepath"
-)
-
-func gitHandler() http.Handler {
- os.Mkdir(filepath.Join(*dir, "git"), 0777)
- path, err := exec.LookPath("git")
- if err != nil {
- log.Fatal(err)
- }
- return &cgi.Handler{
- Path: path,
- Args: []string{"http-backend"},
- Dir: filepath.Join(*dir, "git"),
- Env: []string{
- "GIT_PROJECT_ROOT=" + filepath.Join(*dir),
- "GIT_HTTP_EXPORT_ALL=1",
- },
- }
-}
diff --git a/vcs-test/vcweb/hg.go b/vcs-test/vcweb/hg.go
deleted file mode 100644
index c9ff849..0000000
--- a/vcs-test/vcweb/hg.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "log"
- "net/http"
- "net/http/cgi"
- "os"
- "path/filepath"
- "strings"
-)
-
-var hgwebPy = `#!/usr/bin/env python3
-config = b"../hgweb.cfg"
-
-import cgitb; cgitb.enable()
-
-from mercurial import demandimport
-
-demandimport.enable()
-from mercurial.hgweb import hgweb, wsgicgi
-
-application = hgweb(config)
-wsgicgi.launch(application)
-`
-
-var hgwebCfg = `
-[paths]
-/hg/ = /DIR/hg/*
-`
-
-func hgHandler() http.Handler {
- py := filepath.Join(*dir, "hgweb.py")
- if err := os.WriteFile(py, []byte(hgwebPy), 0777); err != nil {
- log.Fatal(err)
- }
- if err := os.WriteFile(filepath.Join(*dir, "hgweb.cfg"), []byte(strings.Replace(hgwebCfg, "DIR", *dir, -1)), 0777); err != nil {
- log.Fatal(err)
- }
- os.Mkdir(filepath.Join(*dir, "hg"), 0777)
-
- return &cgi.Handler{
- Path: py,
- Dir: filepath.Join(*dir, "hg"),
- }
-}
diff --git a/vcs-test/vcweb/insecure.go b/vcs-test/vcweb/insecure.go
deleted file mode 100644
index 3cf83b7..0000000
--- a/vcs-test/vcweb/insecure.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "net/http"
- "strings"
-)
-
-func insecureRedirectHandler() http.Handler {
- return http.HandlerFunc(insecureRedirectDispatch)
-}
-
-func insecureRedirectDispatch(w http.ResponseWriter, r *http.Request) {
- if !strings.HasPrefix(r.URL.Path, "/insecure/") {
- http.Error(w, "path does not start with /insecure/", http.StatusInternalServerError)
- return
- }
-
- url := *r.URL
- url.Scheme = "http" // not "https"
- if url.Host == "" {
- url.Host = r.Host
- }
- url.Path = strings.TrimPrefix(url.Path, "/insecure")
- http.Redirect(w, r, url.String(), http.StatusMovedPermanently)
-}
diff --git a/vcs-test/vcweb/load.go b/vcs-test/vcweb/load.go
deleted file mode 100644
index 2420191..0000000
--- a/vcs-test/vcweb/load.go
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "archive/zip"
- "bytes"
- "context"
- "crypto/md5"
- "fmt"
- "io"
- "log"
- "os"
- "path/filepath"
- "sync"
- "time"
-
- "cloud.google.com/go/storage"
-)
-
-var (
- bucket *storage.BucketHandle
-)
-
-var cache = struct {
- sync.Mutex
- entry map[string]*cacheEntry
-}{entry: make(map[string]*cacheEntry)}
-
-type cacheEntry struct {
- sync.Mutex
- expire time.Time
- md5 []byte
-}
-
-func loadFS(dir1, dir2 string, force bool) {
- name := dir1 + "/" + dir2
- defer func() {
- if err := recover(); err != nil {
- log.Printf("%s: %v", name, err)
- }
- }()
- check := func(err error) {
- if err != nil {
- panic(err)
- }
- }
-
- check(os.MkdirAll(filepath.Join(*dir, dir1), 0777))
-
- cache.Lock()
- entry := cache.entry[name]
- if entry == nil {
- entry = new(cacheEntry)
- cache.entry[name] = entry
- }
- cache.Unlock()
-
- entry.Lock()
- defer entry.Unlock()
-
- if time.Now().Before(entry.expire) && !force {
- return
- }
-
- entry.expire = time.Now().Add(5 * time.Minute)
-
- obj := bucket.Object(name + ".zip")
- attrs, err := obj.Attrs(context.Background())
- check(err)
- if bytes.Equal(attrs.MD5, entry.md5) {
- return
- }
-
- r, err := obj.NewReader(context.Background())
- check(err)
- defer r.Close()
-
- zipFile := filepath.Join(*dir, name+".zip")
- zf, err := os.Create(zipFile)
- check(err)
-
- h := md5.New()
- _, err = io.Copy(io.MultiWriter(zf, h), r)
- check(zf.Close())
- check(err)
- sum := h.Sum(nil)
-
- if !bytes.Equal(attrs.MD5, sum) {
- panic(fmt.Sprintf("load: unexpected md5 %x != %x", sum, attrs.MD5))
- }
-
- zf, err = os.Open(zipFile)
- check(err)
- info, err := zf.Stat()
- check(err)
- zr, err := zip.NewReader(zf, info.Size())
- check(err)
-
- tmp := filepath.Join(*dir, dir1+"/_"+dir2)
- check(os.RemoveAll(tmp))
- check(os.MkdirAll(tmp, 0777))
-
- for _, f := range zr.File {
- if f.FileInfo().IsDir() {
- check(os.MkdirAll(filepath.Join(tmp, f.Name), 0777))
- continue
- }
- check(os.MkdirAll(filepath.Join(tmp, filepath.Dir(f.Name)), 0777))
- w, err := os.Create(filepath.Join(tmp, f.Name))
- check(err)
- r, err := f.Open()
- check(err)
- _, err = io.Copy(w, r)
- check(err)
- check(w.Close())
- }
-
- real := filepath.Join(*dir, dir1+"/"+dir2)
- check(os.RemoveAll(real))
- check(os.Rename(tmp, real))
- entry.md5 = sum
-}
diff --git a/vcs-test/vcweb/main.go b/vcs-test/vcweb/main.go
deleted file mode 100644
index 2054a17..0000000
--- a/vcs-test/vcweb/main.go
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "context"
- "flag"
- "fmt"
- "html"
- "log"
- "net/http"
- "os"
- "path/filepath"
- "regexp"
- "sort"
- "strings"
- "text/tabwriter"
- "time"
-
- "cloud.google.com/go/storage"
- "golang.org/x/build/internal/https"
-)
-
-var (
- dir = flag.String("d", "/tmp/vcweb", "directory holding vcweb data")
- staging = flag.Bool("staging", false, "use staging letsencrypt server")
-)
-
-var buildInfo string
-
-func usage() {
- fmt.Fprintf(os.Stderr, "usage: vcsweb [-d dir] [-staging]\n")
- os.Exit(2)
-}
-
-var isLoadDir = map[string]bool{
- "auth": true,
- "go": true,
- "git": true,
- "hg": true,
- "svn": true,
- "fossil": true,
- "bzr": true,
-}
-
-func main() {
- flag.Usage = usage
- https.RegisterFlags(flag.CommandLine)
- flag.Parse()
- if flag.NArg() != 0 {
- usage()
- }
-
- if err := os.MkdirAll(*dir, 0777); err != nil {
- log.Fatal(err)
- }
- cl, err := storage.NewClient(context.Background())
- if err != nil {
- log.Fatalln("storage.NewClient:", err)
- }
- bucket = cl.Bucket("vcs-test")
-
- http.Handle("/go/", http.StripPrefix("/go/", http.FileServer(http.Dir(filepath.Join(*dir, "go")))))
- http.Handle("/git/", gitHandler())
- http.Handle("/hg/", hgHandler())
- http.Handle("/svn/", svnHandler())
- http.Handle("/fossil/", fossilHandler())
- http.Handle("/bzr/", bzrHandler())
- http.Handle("/insecure/", insecureRedirectHandler())
- http.Handle("/auth/", newAuthHandler(http.Dir(filepath.Join(*dir, "auth"))))
-
- handler := logger(http.HandlerFunc(loadAndHandle))
- log.Fatal(https.ListenAndServe(context.Background(), handler))
-}
-
-var nameRE = regexp.MustCompile(`^[a-zA-Z0-9_\-]+$`)
-
-func loadAndHandle(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path == "/" {
- overview(w, r)
- return
- }
- elem := strings.Split(r.URL.Path, "/")
- if len(elem) >= 3 && elem[0] == "" && isLoadDir[elem[1]] && nameRE.MatchString(elem[2]) {
- loadFS(elem[1], elem[2], r.URL.Query().Get("vcweb-force-reload") == "1" || r.URL.Query().Get("go-get") == "1")
- }
- http.DefaultServeMux.ServeHTTP(w, r)
-}
-
-func overview(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "<html>\n")
- fmt.Fprintf(w, "<title>vcs-test.golang.org</title>\n<pre>\n")
- fmt.Fprintf(w, "<b>vcs-test.golang.org</b>\n\n")
- fmt.Fprintf(w, "This server serves various version control repos for testing the go command.\n\n")
-
- fmt.Fprintf(w, "Date: %s\n", time.Now().Format(time.UnixDate))
- fmt.Fprintf(w, "Build: %s\n\n", html.EscapeString(buildInfo))
-
- fmt.Fprintf(w, "<b>cache</b>\n")
-
- var all []string
- cache.Lock()
- for name, entry := range cache.entry {
- all = append(all, fmt.Sprintf("%s\t%x\t%s\n", name, entry.md5, entry.expire.Format(time.UnixDate)))
- }
- cache.Unlock()
- sort.Strings(all)
- tw := tabwriter.NewWriter(w, 1, 8, 1, '\t', 0)
- for _, line := range all {
- tw.Write([]byte(line))
- }
- tw.Flush()
-}
-
-type loggingResponseWriter struct {
- code int
- size int64
- http.ResponseWriter
-}
-
-func (l *loggingResponseWriter) WriteHeader(code int) {
- l.code = code
- l.ResponseWriter.WriteHeader(code)
-}
-
-func (l *loggingResponseWriter) Write(data []byte) (int, error) {
- n, err := l.ResponseWriter.Write(data)
- l.size += int64(n)
- return n, err
-}
-
-func dashOr(s string) string {
- if s == "" {
- return "-"
- }
- return s
-}
-
-func logger(h http.Handler) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- l := &loggingResponseWriter{
- code: 200,
- ResponseWriter: w,
- }
- startTime := time.Now().Format("02/Jan/2006:15:04:05 -0700")
- defer func() {
- err := recover()
- if err != nil {
- l.code = 999
- }
- fmt.Fprintf(os.Stderr, "%s - - [%s] %q %03d %d %q %q %q\n",
- dashOr(r.RemoteAddr),
- startTime,
- r.Method+" "+r.URL.String()+" "+r.Proto,
- l.code,
- l.size,
- r.Header.Get("Referer"),
- r.Header.Get("User-Agent"),
- r.Host)
- if err != nil {
- panic(err)
- }
- }()
- h.ServeHTTP(l, r)
- }
-}
diff --git a/vcs-test/vcweb/svn.go b/vcs-test/vcweb/svn.go
deleted file mode 100644
index 7d3601d..0000000
--- a/vcs-test/vcweb/svn.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux
-
-package main
-
-import (
- "log"
- "net/http"
- "net/http/httputil"
- "net/url"
-)
-
-// Subversion is so complicated it can only run from inside Apache.
-// Assume an appropriately configured Apache is on 8888.
-func svnHandler() http.Handler {
- u, err := url.Parse("http://127.0.0.1:8888/")
- if err != nil {
- log.Fatal(err)
- }
- return httputil.NewSingleHostReverseProxy(u)
-}