mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
@@ -13,7 +13,6 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -323,7 +322,7 @@ func NewGoogleInstanceIdentity(t *testing.T, instanceID string, expired bool) (*
|
||||
require.NoError(t, err)
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(bytes.NewReader(data)),
|
||||
Body: io.NopCloser(bytes.NewReader(data)),
|
||||
Header: make(http.Header),
|
||||
}, nil
|
||||
}),
|
||||
@@ -334,7 +333,7 @@ func NewGoogleInstanceIdentity(t *testing.T, instanceID string, expired bool) (*
|
||||
Transport: roundTripper(func(r *http.Request) (*http.Response, error) {
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte(signedKey))),
|
||||
Body: io.NopCloser(bytes.NewReader([]byte(signedKey))),
|
||||
Header: make(http.Header),
|
||||
}, nil
|
||||
}),
|
||||
@@ -379,19 +378,19 @@ func NewAWSInstanceIdentity(t *testing.T, instanceID string) (awsidentity.Certif
|
||||
case "/latest/api/token":
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(bytes.NewReader([]byte("faketoken"))),
|
||||
Body: io.NopCloser(bytes.NewReader([]byte("faketoken"))),
|
||||
Header: make(http.Header),
|
||||
}, nil
|
||||
case "/latest/dynamic/instance-identity/signature":
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(bytes.NewReader(signature)),
|
||||
Body: io.NopCloser(bytes.NewReader(signature)),
|
||||
Header: make(http.Header),
|
||||
}, nil
|
||||
case "/latest/dynamic/instance-identity/document":
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(bytes.NewReader(document)),
|
||||
Body: io.NopCloser(bytes.NewReader(document)),
|
||||
Header: make(http.Header),
|
||||
}, nil
|
||||
default:
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -81,7 +80,7 @@ func main() {
|
||||
if !ok {
|
||||
panic("couldn't get caller path")
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(mainPath, "..", "..", "dump.sql"), []byte(dump), 0600)
|
||||
err = os.WriteFile(filepath.Join(mainPath, "..", "..", "dump.sql"), []byte(dump), 0600)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package postgres
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"sync"
|
||||
@@ -48,10 +47,12 @@ func Open() (string, func(), error) {
|
||||
if err != nil {
|
||||
return "", nil, xerrors.Errorf("create pool: %w", err)
|
||||
}
|
||||
tempDir, err := ioutil.TempDir(os.TempDir(), "postgres")
|
||||
|
||||
tempDir, err := os.MkdirTemp(os.TempDir(), "postgres")
|
||||
if err != nil {
|
||||
return "", nil, xerrors.Errorf("create tempdir: %w", err)
|
||||
}
|
||||
|
||||
openPortMutex.Lock()
|
||||
// Pick an explicit port on the host to connect to 5432.
|
||||
// This is necessary so we can configure the port to only use ipv4.
|
||||
|
||||
Reference in New Issue
Block a user