mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
testutil/fakestorage: inline go code and remove contrib/httpserver
It's 12 lines of code total; we may as well write it as part of building; it looks to be the only place this is used, so we can remove the contrib directory, which should not be used by anyone. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
FROM busybox
|
||||
EXPOSE 80/tcp
|
||||
COPY httpserver .
|
||||
CMD ["./httpserver"]
|
||||
@@ -1,12 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fs := http.FileServer(http.Dir("/static"))
|
||||
http.Handle("/", fs)
|
||||
log.Panic(http.ListenAndServe(":80", nil)) // #nosec G114 -- Ignoring for test-code: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
|
||||
}
|
||||
@@ -40,7 +40,24 @@ func ensureHTTPServerImage(t testing.TB) {
|
||||
assert.NilError(t, err, "could not find go executable to build http server")
|
||||
|
||||
tmp := t.TempDir()
|
||||
cmd := exec.Command(goCmd, "build", "-o", filepath.Join(tmp, "httpserver"), "../contrib/httpserver")
|
||||
const httpServer = `package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fs := http.FileServer(http.Dir("/static"))
|
||||
http.Handle("/", fs)
|
||||
log.Panic(http.ListenAndServe(":80", nil)) // #nosec G114 -- Ignoring for test-code: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
|
||||
}
|
||||
`
|
||||
src := filepath.Join(tmp, "main.go")
|
||||
err = os.WriteFile(filepath.Join(tmp, "main.go"), []byte(httpServer), 0o0644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
cmd := exec.Command(goCmd, "build", "-o", filepath.Join(tmp, "httpserver"), src)
|
||||
cmd.Env = append(os.Environ(), []string{
|
||||
"CGO_ENABLED=0",
|
||||
"GOOS=" + goos,
|
||||
|
||||
Reference in New Issue
Block a user