зеркало из https://github.com/golang/build.git
all: clean up obsolete +build lines and io/ioutil uses [generated]
The module go directive is at 1.20, so modernize it a bit by applying changes generated by the script below with go1.21.1. [git-generate] go fix ./... gofmt -r 'ioutil.Discard -> io.Discard' -w . gofmt -r 'ioutil.NopCloser -> io.NopCloser' -w . gofmt -r 'ioutil.ReadAll -> io.ReadAll' -w . gofmt -r '"ioutil.ReadAll: %v" -> "io.ReadAll: %v"' -w . gofmt -r 'ioutil.ReadDir -> os.ReadDir' -w . gofmt -r 'ioutil.ReadFile -> os.ReadFile' -w . gofmt -r 'ioutil.TempDir -> os.MkdirTemp' -w . gofmt -r 'ioutil.TempFile -> os.CreateTemp' -w . gofmt -r 'ioutil.WriteFile -> os.WriteFile' -w . goimports -w . Change-Id: I145b27756e7c6101e992747ee822e7237df4cb91 Reviewed-on: https://go-review.googlesource.com/c/build/+/527016 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Родитель
3a081fc9ee
Коммит
1ee051bb32
|
@ -8,7 +8,7 @@ package autocertcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
|
|
||||||
"cloud.google.com/go/storage"
|
"cloud.google.com/go/storage"
|
||||||
"golang.org/x/crypto/acme/autocert"
|
"golang.org/x/crypto/acme/autocert"
|
||||||
|
@ -40,7 +40,7 @@ func (c *gcsAutocertCache) Get(ctx context.Context, key string) ([]byte, error)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rd.Close()
|
defer rd.Close()
|
||||||
return ioutil.ReadAll(rd)
|
return io.ReadAll(rd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *gcsAutocertCache) Put(ctx context.Context, key string, data []byte) error {
|
func (c *gcsAutocertCache) Put(ctx context.Context, key string, data []byte) error {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -139,7 +139,7 @@ func probeBuildlet(ctx context.Context, buildletURL string, opts *VMOpts) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error probe buildlet %s: %w", buildletURL, err)
|
return fmt.Errorf("error probe buildlet %s: %w", buildletURL, err)
|
||||||
}
|
}
|
||||||
ioutil.ReadAll(res.Body)
|
io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
return fmt.Errorf("buildlet returned HTTP status code %d for %s", res.StatusCode, buildletURL)
|
return fmt.Errorf("buildlet returned HTTP status code %d for %s", res.StatusCode, buildletURL)
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -279,7 +278,7 @@ func (c *client) ProxyTCP(port int) (io.ReadWriteCloser, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusSwitchingProtocols {
|
if res.StatusCode != http.StatusSwitchingProtocols {
|
||||||
slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 4<<10))
|
slurp, _ := io.ReadAll(io.LimitReader(res.Body, 4<<10))
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
return nil, fmt.Errorf("wanted 101 Switching Protocols; unexpected response: %v, %q", res.Status, slurp)
|
return nil, fmt.Errorf("wanted 101 Switching Protocols; unexpected response: %v, %q", res.Status, slurp)
|
||||||
}
|
}
|
||||||
|
@ -397,7 +396,7 @@ func (c *client) doOK(req *http.Request) error {
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 4<<10))
|
slurp, _ := io.ReadAll(io.LimitReader(res.Body, 4<<10))
|
||||||
return fmt.Errorf("%v; body: %s", res.Status, slurp)
|
return fmt.Errorf("%v; body: %s", res.Status, slurp)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -459,7 +458,7 @@ func (c *client) GetTar(ctx context.Context, dir string) (io.ReadCloser, error)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 4<<10))
|
slurp, _ := io.ReadAll(io.LimitReader(res.Body, 4<<10))
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
return nil, fmt.Errorf("%v; body: %s", res.Status, slurp)
|
return nil, fmt.Errorf("%v; body: %s", res.Status, slurp)
|
||||||
}
|
}
|
||||||
|
@ -574,7 +573,7 @@ func (c *client) Exec(ctx context.Context, cmd string, opts ExecOpts) (remoteErr
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 4<<10))
|
slurp, _ := io.ReadAll(io.LimitReader(res.Body, 4<<10))
|
||||||
return nil, fmt.Errorf("buildlet: HTTP status %v: %s", res.Status, slurp)
|
return nil, fmt.Errorf("buildlet: HTTP status %v: %s", res.Status, slurp)
|
||||||
}
|
}
|
||||||
condRun(opts.OnStartExec)
|
condRun(opts.OnStartExec)
|
||||||
|
@ -587,7 +586,7 @@ func (c *client) Exec(ctx context.Context, cmd string, opts ExecOpts) (remoteErr
|
||||||
// Stream the output:
|
// Stream the output:
|
||||||
out := opts.Output
|
out := opts.Output
|
||||||
if out == nil {
|
if out == nil {
|
||||||
out = ioutil.Discard
|
out = io.Discard
|
||||||
}
|
}
|
||||||
if _, err := io.Copy(out, res.Body); err != nil {
|
if _, err := io.Copy(out, res.Body); err != nil {
|
||||||
resc <- errs{execErr: fmt.Errorf("error copying response: %w", err)}
|
resc <- errs{execErr: fmt.Errorf("error copying response: %w", err)}
|
||||||
|
@ -673,7 +672,7 @@ func (c *client) Status(ctx context.Context) (Status, error) {
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return Status{}, errors.New(resp.Status)
|
return Status{}, errors.New(resp.Status)
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
b, err := io.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Status{}, err
|
return Status{}, err
|
||||||
|
@ -699,7 +698,7 @@ func (c *client) WorkDir(ctx context.Context) (string, error) {
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return "", errors.New(resp.Status)
|
return "", errors.New(resp.Status)
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
b, err := io.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -792,7 +791,7 @@ func (c *client) ListDir(ctx context.Context, dir string, opts ListDirOpts, fn f
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
slurp, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<10))
|
slurp, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<10))
|
||||||
return fmt.Errorf("%s: %s", resp.Status, slurp)
|
return fmt.Errorf("%s: %s", resp.Status, slurp)
|
||||||
}
|
}
|
||||||
sc := bufio.NewScanner(resp.Body)
|
sc := bufio.NewScanner(resp.Body)
|
||||||
|
@ -853,7 +852,7 @@ func (c *client) ConnectSSH(user, authorizedPubKey string) (net.Conn, error) {
|
||||||
return nil, fmt.Errorf("reading /connect-ssh response: %v", err)
|
return nil, fmt.Errorf("reading /connect-ssh response: %v", err)
|
||||||
}
|
}
|
||||||
if res.StatusCode != http.StatusSwitchingProtocols {
|
if res.StatusCode != http.StatusSwitchingProtocols {
|
||||||
slurp, _ := ioutil.ReadAll(res.Body)
|
slurp, _ := io.ReadAll(res.Body)
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return nil, fmt.Errorf("unexpected /connect-ssh response: %v, %s", res.Status, slurp)
|
return nil, fmt.Errorf("unexpected /connect-ssh response: %v, %s", res.Status, slurp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -112,7 +112,7 @@ func (cc *CoordinatorClient) CreateBuildletWithStatus(builderType string, status
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode != 200 {
|
if res.StatusCode != 200 {
|
||||||
slurp, _ := ioutil.ReadAll(res.Body)
|
slurp, _ := io.ReadAll(res.Body)
|
||||||
return nil, fmt.Errorf("%s: %s", res.Status, slurp)
|
return nil, fmt.Errorf("%s: %s", res.Status, slurp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ func (cc *CoordinatorClient) RemoteBuildlets() ([]RemoteBuildlet, error) {
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode != 200 {
|
if res.StatusCode != 200 {
|
||||||
slurp, _ := ioutil.ReadAll(res.Body)
|
slurp, _ := io.ReadAll(res.Body)
|
||||||
return nil, fmt.Errorf("%s: %s", res.Status, slurp)
|
return nil, fmt.Errorf("%s: %s", res.Status, slurp)
|
||||||
}
|
}
|
||||||
var ret []RemoteBuildlet
|
var ret []RemoteBuildlet
|
||||||
|
@ -256,7 +256,7 @@ func userToken() (string, error) {
|
||||||
}
|
}
|
||||||
keyDir := configDir()
|
keyDir := configDir()
|
||||||
userPath := filepath.Join(keyDir, "user-"+gomoteUserFlag+".user")
|
userPath := filepath.Join(keyDir, "user-"+gomoteUserFlag+".user")
|
||||||
b, err := ioutil.ReadFile(userPath)
|
b, err := os.ReadFile(userPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
gomoteUserFlag = string(bytes.TrimSpace(b))
|
gomoteUserFlag = string(bytes.TrimSpace(b))
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ func userToken() (string, error) {
|
||||||
baseFile = "staging-" + baseFile
|
baseFile = "staging-" + baseFile
|
||||||
}
|
}
|
||||||
tokenFile := filepath.Join(keyDir, baseFile)
|
tokenFile := filepath.Join(keyDir, baseFile)
|
||||||
slurp, err := ioutil.ReadFile(tokenFile)
|
slurp, err := os.ReadFile(tokenFile)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return "", fmt.Errorf("Missing file %s for user %q. Change --user or obtain a token and place it there.",
|
return "", fmt.Errorf("Missing file %s for user %q. Change --user or obtain a token and place it there.",
|
||||||
tokenFile, gomoteUserFlag)
|
tokenFile, gomoteUserFlag)
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -412,7 +411,7 @@ func metadataValue(key string) string {
|
||||||
v := os.Getenv(envKey)
|
v := os.Getenv(envKey)
|
||||||
// Respect curl-style '@' prefix to mean the rest is a filename.
|
// Respect curl-style '@' prefix to mean the rest is a filename.
|
||||||
if strings.HasPrefix(v, "@") {
|
if strings.HasPrefix(v, "@") {
|
||||||
slurp, err := ioutil.ReadFile(v[1:])
|
slurp, err := os.ReadFile(v[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error reading file for GCEMETA_%v: %v", key, err)
|
log.Fatalf("Error reading file for GCEMETA_%v: %v", key, err)
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1612,7 @@ func waitLocalSSH() {
|
||||||
|
|
||||||
func numProcs() int {
|
func numProcs() int {
|
||||||
n := 0
|
n := 0
|
||||||
fis, _ := ioutil.ReadDir("/proc")
|
fis, _ := os.ReadDir("/proc")
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
if _, err := strconv.Atoi(fi.Name()); err == nil {
|
if _, err := strconv.Atoi(fi.Name()); err == nil {
|
||||||
n++
|
n++
|
||||||
|
@ -1810,7 +1809,7 @@ func appendSSHAuthorizedKey(sshUser, authKey string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
authFile := filepath.Join(sshDir, "authorized_keys")
|
authFile := filepath.Join(sshDir, "authorized_keys")
|
||||||
exist, err := ioutil.ReadFile(authFile)
|
exist, err := os.ReadFile(authFile)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build netbsd || openbsd
|
//go:build netbsd || openbsd
|
||||||
// +build netbsd openbsd
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
// (We only care about Linux on GKE for now)
|
// (We only care about Linux on GKE for now)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -37,7 +36,7 @@ func keyForMode(mode string) (string, error) {
|
||||||
if v := os.Getenv("GO_BUILD_KEY_PATH"); v != "" {
|
if v := os.Getenv("GO_BUILD_KEY_PATH"); v != "" {
|
||||||
keyPath = v
|
keyPath = v
|
||||||
}
|
}
|
||||||
key, err := ioutil.ReadFile(keyPath)
|
key, err := os.ReadFile(keyPath)
|
||||||
if ok, _ := strconv.ParseBool(os.Getenv("GO_BUILD_KEY_DELETE_AFTER_READ")); ok {
|
if ok, _ := strconv.ParseBool(os.Getenv("GO_BUILD_KEY_DELETE_AFTER_READ")); ok {
|
||||||
os.Remove(keyPath)
|
os.Remove(keyPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
// Same requirements as internal/coordinator/pool/reverse.go.
|
// Same requirements as internal/coordinator/pool/reverse.go.
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
@ -129,7 +128,7 @@ func genKey() (pubKey, privateKeyPath string) {
|
||||||
log.Fatalf("ssh-keygen: %v, %s", err, out)
|
log.Fatalf("ssh-keygen: %v, %s", err, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadFile(pubKeyPath)
|
slurp, err := os.ReadFile(pubKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
// The coordinator runs the majority of the Go build system.
|
// The coordinator runs the majority of the Go build system.
|
||||||
//
|
//
|
||||||
|
@ -27,7 +25,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -2013,7 +2010,7 @@ func newBuildLogBlob(objName string) (obj io.WriteCloser, url_ string) {
|
||||||
io.Closer
|
io.Closer
|
||||||
}{
|
}{
|
||||||
os.Stderr,
|
os.Stderr,
|
||||||
ioutil.NopCloser(nil),
|
io.NopCloser(nil),
|
||||||
}, "devmode://build-log/" + objName
|
}, "devmode://build-log/" + objName
|
||||||
}
|
}
|
||||||
if pool.NewGCEConfiguration().StorageClient() == nil {
|
if pool.NewGCEConfiguration().StorageClient() == nil {
|
||||||
|
|
|
@ -3,14 +3,12 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -138,9 +136,9 @@ func TestTryStatusJSON(t *testing.T) {
|
||||||
t.Errorf("response status code: got %d; want %d", got, want)
|
t.Errorf("response status code: got %d; want %d", got, want)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
b, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ioutil.ReadAll: %v", err)
|
t.Fatalf("io.ReadAll: %v", err)
|
||||||
}
|
}
|
||||||
if got, want := string(b), tc.body; got != want {
|
if got, want := string(b), tc.body; got != want {
|
||||||
t.Errorf("body: got\n%v\nwant\n%v", got, want)
|
t.Errorf("body: got\n%v\nwant\n%v", got, want)
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
// Code interacting with build.golang.org ("the dashboard").
|
// Code interacting with build.golang.org ("the dashboard").
|
||||||
|
|
||||||
|
@ -19,10 +17,10 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -163,7 +161,7 @@ func builderKey(builder string) string {
|
||||||
|
|
||||||
func loadKey(sc *secret.Client) {
|
func loadKey(sc *secret.Client) {
|
||||||
if *masterKeyFile != "" {
|
if *masterKeyFile != "" {
|
||||||
b, err := ioutil.ReadFile(*masterKeyFile)
|
b, err := os.ReadFile(*masterKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
// Package dashboard contains the implementation of the build dashboard for the Coordinator.
|
// Package dashboard contains the implementation of the build dashboard for the Coordinator.
|
||||||
package dashboard
|
package dashboard
|
||||||
|
|
|
@ -3,13 +3,12 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -54,7 +53,7 @@ func TestHandlerServeHTTP(t *testing.T) {
|
||||||
dh.ServeHTTP(w, req)
|
dh.ServeHTTP(w, req)
|
||||||
resp := w.Result()
|
resp := w.Result()
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
ioutil.ReadAll(resp.Body)
|
io.ReadAll(resp.Body)
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
t.Errorf("resp.StatusCode = %d, wanted %d", resp.StatusCode, http.StatusOK)
|
t.Errorf("resp.StatusCode = %d, wanted %d", resp.StatusCode, http.StatusOK)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package legacydash
|
package legacydash
|
||||||
|
|
||||||
|
@ -14,7 +13,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
pathpkg "path"
|
pathpkg "path"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -444,7 +442,7 @@ func (l *Log) Text() ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("reading log data: %v", err)
|
return nil, fmt.Errorf("reading log data: %v", err)
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(d)
|
b, err := io.ReadAll(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("reading log data: %v", err)
|
return nil, fmt.Errorf("reading log data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
// Package legacydash holds the serving code for the build dashboard
|
// Package legacydash holds the serving code for the build dashboard
|
||||||
// (build.golang.org) and its remaining HTTP API endpoints.
|
// (build.golang.org) and its remaining HTTP API endpoints.
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package legacydash
|
package legacydash
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package legacydash
|
package legacydash
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package legacydash
|
package legacydash
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,12 @@ package protos
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
|
math "math"
|
||||||
|
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
math "math"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
// Code related to the Build Results API.
|
// Code related to the Build Results API.
|
||||||
|
|
||||||
|
@ -13,7 +11,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -77,7 +75,7 @@ func (g *gRPCServer) clearFromDashboard(ctx context.Context, builder, hash, key
|
||||||
log.Printf("gRPCServer.ClearResults: error performing wipe for %q/%q: %v", builder, hash, err)
|
log.Printf("gRPCServer.ClearResults: error performing wipe for %q/%q: %v", builder, hash, err)
|
||||||
return grpcstatus.Error(codes.Internal, codes.Internal.String())
|
return grpcstatus.Error(codes.Internal, codes.Internal.String())
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("gRPCServer.ClearResults: error reading response body for %q/%q: %v", builder, hash, err)
|
log.Printf("gRPCServer.ClearResults: error reading response body for %q/%q: %v", builder, hash, err)
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -62,7 +61,7 @@ func main() {
|
||||||
|
|
||||||
checkDeps()
|
checkDeps()
|
||||||
|
|
||||||
mntDir, err := ioutil.TempDir("", "docker2boot")
|
mntDir, err := os.MkdirTemp("", "docker2boot")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failf("Failed to create mount temp dir: %v", err)
|
failf("Failed to create mount temp dir: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -152,7 +151,7 @@ func main() {
|
||||||
writeFile(filepath.Join(mntDir, "etc", "resolv.conf"), "nameserver 8.8.8.8\n")
|
writeFile(filepath.Join(mntDir, "etc", "resolv.conf"), "nameserver 8.8.8.8\n")
|
||||||
|
|
||||||
// Append the source image id & docker version to /etc/issue.
|
// Append the source image id & docker version to /etc/issue.
|
||||||
issue, err := ioutil.ReadFile("/etc/issue")
|
issue, err := os.ReadFile("/etc/issue")
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
failf("Failed to read /etc/issue: %v", err)
|
failf("Failed to read /etc/issue: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -252,7 +251,7 @@ func httpGet(u string) io.Reader {
|
||||||
}
|
}
|
||||||
|
|
||||||
func slurpFile(file string) string {
|
func slurpFile(file string) string {
|
||||||
v, err := ioutil.ReadFile(file)
|
v, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failf("Failed to read %s: %v", file, err)
|
failf("Failed to read %s: %v", file, err)
|
||||||
}
|
}
|
||||||
|
@ -260,7 +259,7 @@ func slurpFile(file string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeFile(file, contents string) {
|
func writeFile(file, contents string) {
|
||||||
if err := ioutil.WriteFile(file, []byte(contents), 0644); err != nil {
|
if err := os.WriteFile(file, []byte(contents), 0644); err != nil {
|
||||||
failf("writeFile %s: %v", file, err)
|
failf("writeFile %s: %v", file, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -57,7 +56,7 @@ func getMasterKey() []byte {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return []byte(strings.TrimSpace(v))
|
return []byte(strings.TrimSpace(v))
|
||||||
}
|
}
|
||||||
key, err := ioutil.ReadFile(filepath.Join(os.Getenv("HOME"), "keys/gobuilder-master.key"))
|
key, err := os.ReadFile(filepath.Join(os.Getenv("HOME"), "keys/gobuilder-master.key"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return bytes.TrimSpace(key)
|
return bytes.TrimSpace(key)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -110,7 +109,7 @@ func writeCookiesFile(sc *secret.Client) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("secret.Retrieve(ctx, %q): %q, %w", secret.NameGerritbotGitCookies, cookies, err)
|
return fmt.Errorf("secret.Retrieve(ctx, %q): %q, %w", secret.NameGerritbotGitCookies, cookies, err)
|
||||||
}
|
}
|
||||||
return ioutil.WriteFile(*gitcookiesFile, []byte(cookies), 0600)
|
return os.WriteFile(*gitcookiesFile, []byte(cookies), 0600)
|
||||||
}
|
}
|
||||||
|
|
||||||
func githubClient(sc *secret.Client) (*github.Client, error) {
|
func githubClient(sc *secret.Client) (*github.Client, error) {
|
||||||
|
@ -144,7 +143,7 @@ func githubToken(sc *secret.Client) (string, error) {
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadFile(*githubTokenFile)
|
slurp, err := os.ReadFile(*githubTokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -176,7 +175,7 @@ func gerritAuth(sc *secret.Client) (string, string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(slurp) == 0 {
|
if len(slurp) == 0 {
|
||||||
slurpBytes, err := ioutil.ReadFile(*gerritTokenFile)
|
slurpBytes, err := os.ReadFile(*gerritTokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -68,7 +67,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("creating cache dir: %v", err)
|
log.Fatalf("creating cache dir: %v", err)
|
||||||
}
|
}
|
||||||
credsDir, err := ioutil.TempDir("", "gitmirror-credentials")
|
credsDir, err := os.MkdirTemp("", "gitmirror-credentials")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("creating credentials dir: %v", err)
|
log.Fatalf("creating credentials dir: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,7 @@ func writeCredentials(home string) error {
|
||||||
return fmt.Errorf("reading github key from secret manager: %v", err)
|
return fmt.Errorf("reading github key from secret manager: %v", err)
|
||||||
}
|
}
|
||||||
privKeyPath := filepath.Join(home, secret.NameGitHubSSHKey)
|
privKeyPath := filepath.Join(home, secret.NameGitHubSSHKey)
|
||||||
if err := ioutil.WriteFile(privKeyPath, []byte(privKey+"\n"), 0600); err != nil {
|
if err := os.WriteFile(privKeyPath, []byte(privKey+"\n"), 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(sshConfig, "Host github.com\n IdentityFile %v\n", privKeyPath)
|
fmt.Fprintf(sshConfig, "Host github.com\n IdentityFile %v\n", privKeyPath)
|
||||||
|
@ -147,10 +146,10 @@ func writeCredentials(home string) error {
|
||||||
fmt.Fprintf(gitConfig, "[credential \"https://source.developers.google.com\"]\n helper=gcloud.sh\n")
|
fmt.Fprintf(gitConfig, "[credential \"https://source.developers.google.com\"]\n helper=gcloud.sh\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(filepath.Join(home, ".gitconfig"), gitConfig.Bytes(), 0600); err != nil {
|
if err := os.WriteFile(filepath.Join(home, ".gitconfig"), gitConfig.Bytes(), 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(sshConfigPath, sshConfig.Bytes(), 0600); err != nil {
|
if err := os.WriteFile(sshConfigPath, sshConfig.Bytes(), 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +158,7 @@ func writeCredentials(home string) error {
|
||||||
|
|
||||||
func retrieveSecret(ctx context.Context, name string) (string, error) {
|
func retrieveSecret(ctx context.Context, name string) (string, error) {
|
||||||
if *flagSecretsDir != "" {
|
if *flagSecretsDir != "" {
|
||||||
secret, err := ioutil.ReadFile(filepath.Join(*flagSecretsDir, name))
|
secret, err := os.ReadFile(filepath.Join(*flagSecretsDir, name))
|
||||||
return string(secret), err
|
return string(secret), err
|
||||||
}
|
}
|
||||||
sc := secret.MustNewClient()
|
sc := secret.MustNewClient()
|
||||||
|
@ -169,7 +168,7 @@ func retrieveSecret(ctx context.Context, name string) (string, error) {
|
||||||
|
|
||||||
func createCacheDir() (string, error) {
|
func createCacheDir() (string, error) {
|
||||||
if *flagCacheDir == "" {
|
if *flagCacheDir == "" {
|
||||||
dir, err := ioutil.TempDir("", "gitmirror")
|
dir, err := os.MkdirTemp("", "gitmirror")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -467,7 +466,7 @@ func (r *repo) addRemote(name, url, pushOption string) error {
|
||||||
remote := "URL: " + url + "\n" +
|
remote := "URL: " + url + "\n" +
|
||||||
"Push: +refs/heads/*:refs/heads/*\n" +
|
"Push: +refs/heads/*:refs/heads/*\n" +
|
||||||
"Push: +refs/tags/*:refs/tags/*\n"
|
"Push: +refs/tags/*:refs/tags/*\n"
|
||||||
return ioutil.WriteFile(filepath.Join(r.root, "remotes", name), []byte(remote), 0777)
|
return os.WriteFile(filepath.Join(r.root, "remotes", name), []byte(remote), 0777)
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop continuously runs "git fetch" in the repo, checks for new
|
// loop continuously runs "git fetch" in the repo, checks for new
|
||||||
|
|
|
@ -6,7 +6,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
@ -195,7 +195,7 @@ func (tm *testMirror) loopOnce() {
|
||||||
|
|
||||||
func (tm *testMirror) commit(content string) {
|
func (tm *testMirror) commit(content string) {
|
||||||
tm.t.Helper()
|
tm.t.Helper()
|
||||||
if err := ioutil.WriteFile(filepath.Join(tm.gerrit, "README"), []byte(content), 0777); err != nil {
|
if err := os.WriteFile(filepath.Join(tm.gerrit, "README"), []byte(content), 0777); err != nil {
|
||||||
tm.t.Fatal(err)
|
tm.t.Fatal(err)
|
||||||
}
|
}
|
||||||
tm.git(tm.gerrit, "add", ".")
|
tm.git(tm.gerrit, "add", ".")
|
||||||
|
@ -219,7 +219,7 @@ func (tm *testMirror) get(path string) string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tm.t.Fatal(err)
|
tm.t.Fatal(err)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tm.t.Fatal(err)
|
tm.t.Fatal(err)
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -102,7 +101,7 @@ func writeCertificateToDisk(b []byte) (string, error) {
|
||||||
if err := os.MkdirAll(tmpDir, 0700); err != nil {
|
if err := os.MkdirAll(tmpDir, 0700); err != nil {
|
||||||
return "", fmt.Errorf("unable to create temp directory for certficates: %w", err)
|
return "", fmt.Errorf("unable to create temp directory for certficates: %w", err)
|
||||||
}
|
}
|
||||||
tf, err := ioutil.TempFile(tmpDir, "id_ed25519-*-cert.pub")
|
tf, err := os.CreateTemp(tmpDir, "id_ed25519-*-cert.pub")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -123,7 +122,7 @@ func getGitHubToken(ctx context.Context, sc *secret.Client) (string, error) {
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadFile(*githubTokenFile)
|
slurp, err := os.ReadFile(*githubTokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -147,7 +146,7 @@ func getGerritAuth(ctx context.Context, sc *secret.Client) (username string, pas
|
||||||
}
|
}
|
||||||
|
|
||||||
var slurpBytes []byte
|
var slurpBytes []byte
|
||||||
slurpBytes, err = ioutil.ReadFile(*gerritTokenFile)
|
slurpBytes, err = os.ReadFile(*gerritTokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -141,7 +140,7 @@ func main() {
|
||||||
var stripDir string
|
var stripDir string
|
||||||
if *flagDashboard {
|
if *flagDashboard {
|
||||||
revDir := filepath.Join(xdgCacheDir(), "fetchlogs", "rev")
|
revDir := filepath.Join(xdgCacheDir(), "fetchlogs", "rev")
|
||||||
fis, err := ioutil.ReadDir(revDir)
|
fis, err := os.ReadDir(revDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s: %s\n", revDir, err)
|
fmt.Fprintf(os.Stderr, "%s: %s\n", revDir, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -235,7 +234,7 @@ func process(path, nicePath string) (found bool, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use streaming if possible.
|
// TODO: Use streaming if possible.
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -96,7 +96,7 @@ func validateGithubRequest(w http.ResponseWriter, r *http.Request) (body []byte,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err = ioutil.ReadAll(http.MaxBytesReader(w, r.Body, 5<<20))
|
body, err = io.ReadAll(http.MaxBytesReader(w, r.Body, 5<<20))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -491,7 +490,7 @@ func (p *Platform) Build(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the script.
|
// Execute the script.
|
||||||
script, err := ioutil.TempFile("", "racebuild")
|
script, err := os.CreateTemp("", "racebuild")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create temp file: %v", err)
|
return fmt.Errorf("failed to create temp file: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -572,7 +571,7 @@ func (p *Platform) UpdateReadme() error {
|
||||||
defer readmeMu.Unlock()
|
defer readmeMu.Unlock()
|
||||||
|
|
||||||
readmeFile := filepath.Join(*flagGoroot, "src", "runtime", "race", "README")
|
readmeFile := filepath.Join(*flagGoroot, "src", "runtime", "race", "README")
|
||||||
readme, err := ioutil.ReadFile(readmeFile)
|
readme, err := os.ReadFile(readmeFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("bad -goroot? %v", err)
|
log.Fatalf("bad -goroot? %v", err)
|
||||||
}
|
}
|
||||||
|
@ -597,7 +596,7 @@ func (p *Platform) UpdateReadme() error {
|
||||||
readme = append(append(readme, []byte(updatedLine)...), '\n')
|
readme = append(append(readme, []byte(updatedLine)...), '\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.WriteFile(readmeFile, readme, 0640)
|
return os.WriteFile(readmeFile, readme, 0640)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Platform) Gomote(ctx context.Context, args ...string) ([]byte, error) {
|
func (p *Platform) Gomote(ctx context.Context, args ...string) ([]byte, error) {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -319,7 +318,7 @@ func publishFile(uploadURL string, auth buildlet.UserPass, f task.WebsiteFile) e
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
b, _ := ioutil.ReadAll(resp.Body)
|
b, _ := io.ReadAll(resp.Body)
|
||||||
return fmt.Errorf("upload failed to %q: %v\n%s", uploadURL, resp.Status, b)
|
return fmt.Errorf("upload failed to %q: %v\n%s", uploadURL, resp.Status, b)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -147,7 +147,7 @@ func foreachFailure(fn func(f Failure, failLog string)) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error fetching %s: %v", f.LogURL, err)
|
log.Fatalf("Error fetching %s: %v", f.LogURL, err)
|
||||||
}
|
}
|
||||||
failLog, err := ioutil.ReadAll(res.Body)
|
failLog, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error reading %s: %v", f.LogURL, err)
|
log.Fatalf("Error reading %s: %v", f.LogURL, err)
|
||||||
|
@ -290,7 +290,7 @@ func (c *client) wipe(builder, hash string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -327,7 +327,7 @@ func builderKey(builder string) string {
|
||||||
if *keyFile == "" {
|
if *keyFile == "" {
|
||||||
log.Fatalf("No --key specified for builder %s", builder)
|
log.Fatalf("No --key specified for builder %s", builder)
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadFile(*keyFile)
|
slurp, err := os.ReadFile(*keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error reading builder key %s: %v", builder, err)
|
log.Fatalf("Error reading builder key %s: %v", builder, err)
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ func builderKey(builder string) string {
|
||||||
func builderKeyFromMaster(builder string) (key string, ok bool) {
|
func builderKeyFromMaster(builder string) (key string, ok bool) {
|
||||||
masterKey, err := getMasterKeyFromSecretManager()
|
masterKey, err := getMasterKeyFromSecretManager()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slurp, err := ioutil.ReadFile(*masterKeyFile)
|
slurp, err := os.ReadFile(*masterKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ func failures() (ret []Failure) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadAll(res.Body)
|
slurp, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -105,7 +104,7 @@ func onEC2() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBuildKey() []byte {
|
func getBuildKey() []byte {
|
||||||
key, err := ioutil.ReadFile(*keyFile)
|
key, err := os.ReadFile(*keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error reading build key from --key=%s: %v", *keyFile, err)
|
log.Fatalf("error reading build key from --key=%s: %v", *keyFile, err)
|
||||||
}
|
}
|
||||||
|
@ -187,7 +186,7 @@ func checkFix() error {
|
||||||
if err := os.MkdirAll(filepath.Dir(keyFile), 0700); err != nil {
|
if err := os.MkdirAll(filepath.Dir(keyFile), 0700); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(keyFile, buildKey, 0600); err != nil {
|
if err := os.WriteFile(keyFile, buildKey, 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd := exec.Command("docker", "run",
|
cmd := exec.Command("docker", "run",
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
// Binary runqemubuildlet runs a single VM-based buildlet in a loop.
|
// Binary runqemubuildlet runs a single VM-based buildlet in a loop.
|
||||||
package main
|
package main
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16
|
//go:build go1.16
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -102,7 +101,7 @@ func (gitCookiesAuth) setAuth(c *Client, r *http.Request) error {
|
||||||
// got so long that old versions of curl couldn't handle them.
|
// got so long that old versions of curl couldn't handle them.
|
||||||
host := url.Host
|
host := url.Host
|
||||||
netrc := netrcPath()
|
netrc := netrcPath()
|
||||||
data, _ := ioutil.ReadFile(netrc)
|
data, _ := os.ReadFile(netrc)
|
||||||
for _, line := range strings.Split(string(data), "\n") {
|
for _, line := range strings.Split(string(data), "\n") {
|
||||||
if i := strings.Index(line, "#"); i >= 0 {
|
if i := strings.Index(line, "#"); i >= 0 {
|
||||||
line = line[:i]
|
line = line[:i]
|
||||||
|
@ -125,7 +124,7 @@ type gitCookieFileAuth struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *gitCookieFileAuth) loadCookieFileOnce() {
|
func (a *gitCookieFileAuth) loadCookieFileOnce() {
|
||||||
data, err := ioutil.ReadFile(a.file)
|
data, err := os.ReadFile(a.file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.err = fmt.Errorf("Error loading cookie file: %v", err)
|
a.err = fmt.Errorf("Error loading cookie file: %v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build ignore
|
//go:build ignore
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// The demo command shows and tests usage of the gerrit package.
|
// The demo command shows and tests usage of the gerrit package.
|
||||||
package main
|
package main
|
||||||
|
@ -11,7 +10,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -22,7 +20,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gobotPass, err := ioutil.ReadFile(filepath.Join(os.Getenv("HOME"), "keys", "gobot-golang-org.cookie"))
|
gobotPass, err := os.ReadFile(filepath.Join(os.Getenv("HOME"), "keys", "gobot-golang-org.cookie"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
"cloud.google.com/go/compute/metadata"
|
"cloud.google.com/go/compute/metadata"
|
||||||
secretmanager "cloud.google.com/go/secretmanager/apiv1"
|
secretmanager "cloud.google.com/go/secretmanager/apiv1"
|
||||||
"github.com/influxdata/influxdb-client-go/v2"
|
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||||
"github.com/influxdata/influxdb-client-go/v2/domain"
|
"github.com/influxdata/influxdb-client-go/v2/domain"
|
||||||
"golang.org/x/build/internal/https"
|
"golang.org/x/build/internal/https"
|
||||||
"golang.org/x/build/internal/influx"
|
"golang.org/x/build/internal/influx"
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
// Code interacting with Google Compute Engine (GCE) and
|
// Code interacting with Google Compute Engine (GCE) and
|
||||||
// a GCE implementation of the BuildletPool interface.
|
// a GCE implementation of the BuildletPool interface.
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package remote
|
package remote
|
||||||
|
|
||||||
|
@ -19,7 +17,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
@ -330,7 +327,7 @@ func (ss *SSHServer) setupRemoteSSHEnv(bconf *dashboard.BuildConfig, workDir str
|
||||||
// WriteSSHPrivateKeyToTempFile writes a key to a temporary file on the local file system. It also
|
// WriteSSHPrivateKeyToTempFile writes a key to a temporary file on the local file system. It also
|
||||||
// sets the permissions on the file to what is expected by OpenSSH implementations of SSH.
|
// sets the permissions on the file to what is expected by OpenSSH implementations of SSH.
|
||||||
func WriteSSHPrivateKeyToTempFile(key []byte) (path string, err error) {
|
func WriteSSHPrivateKeyToTempFile(key []byte) (path string, err error) {
|
||||||
tf, err := ioutil.TempFile("", "ssh-priv-key")
|
tf, err := os.CreateTemp("", "ssh-priv-key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.16 && (linux || darwin)
|
//go:build go1.16 && (linux || darwin)
|
||||||
// +build go1.16
|
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package remote
|
package remote
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package schedule
|
package schedule
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package schedule
|
package schedule
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package schedule
|
package schedule
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package schedule
|
package schedule
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package schedule
|
package schedule
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -82,7 +81,7 @@ func TestDirFSWrite(t *testing.T) {
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadFile(filepath.Join(temp, "fsystest.txt"))
|
b, err := os.ReadFile(filepath.Join(temp, "fsystest.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -49,7 +48,7 @@ func Init() error {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
fmt.Fprintf(&buf, "go.googlesource.com\tFALSE\t/\tTRUE\t2147483647\to\tgit-gobot.gmail.com=%s\n", slurp)
|
fmt.Fprintf(&buf, "go.googlesource.com\tFALSE\t/\tTRUE\t2147483647\to\tgit-gobot.gmail.com=%s\n", slurp)
|
||||||
fmt.Fprintf(&buf, "go-review.googlesource.com\tFALSE\t/\tTRUE\t2147483647\to\tgit-gobot.gmail.com=%s\n", slurp)
|
fmt.Fprintf(&buf, "go-review.googlesource.com\tFALSE\t/\tTRUE\t2147483647\to\tgit-gobot.gmail.com=%s\n", slurp)
|
||||||
return ioutil.WriteFile(cookieFile, buf.Bytes(), 0644)
|
return os.WriteFile(cookieFile, buf.Bytes(), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
func homeDir() string {
|
func homeDir() string {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package gomote
|
package gomote
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package gomote
|
package gomote
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
package protos
|
package protos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -8,6 +8,7 @@ package protos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package gomote
|
package gomote
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package gomote
|
package gomote
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package httpdl
|
package httpdl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
@ -26,7 +25,7 @@ func TestDownload(t *testing.T) {
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", "dl")
|
tmpDir, err := os.MkdirTemp("", "dl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +69,7 @@ func TestDownload(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check re-download on size change.
|
// Also check re-download on size change.
|
||||||
ioutil.WriteFile(dstFile, []byte(someContent+someContent), 0644)
|
os.WriteFile(dstFile, []byte(someContent+someContent), 0644)
|
||||||
os.Chtimes(dstFile, someTime, someTime)
|
os.Chtimes(dstFile, someTime, someTime)
|
||||||
if err := Download(dstFile, ts.URL+"/foo.txt"); err != nil {
|
if err := Download(dstFile, ts.URL+"/foo.txt"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux || darwin
|
//go:build linux || darwin
|
||||||
// +build linux darwin
|
|
||||||
|
|
||||||
package releasetargets
|
package releasetargets
|
||||||
|
|
||||||
|
@ -12,7 +11,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -29,13 +28,13 @@ func TestReleaseTargets(t *testing.T) {
|
||||||
printRelease(out, release, TargetsForGo1Point(release))
|
printRelease(out, release, TargetsForGo1Point(release))
|
||||||
}
|
}
|
||||||
if *update {
|
if *update {
|
||||||
if err := ioutil.WriteFile("releases.txt", out.Bytes(), 0); err != nil {
|
if err := os.WriteFile("releases.txt", out.Bytes(), 0); err != nil {
|
||||||
t.Fatalf("updating golden: %v", err)
|
t.Fatalf("updating golden: %v", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
golden, err := ioutil.ReadFile("releases.txt")
|
golden, err := os.ReadFile("releases.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("reading golden: %v", err)
|
t.Fatalf("reading golden: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
@ -676,7 +675,7 @@ func checkTGZ(t *testing.T, dlURL string, files map[string]task.WebsiteFile, fil
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(tr)
|
b, err := io.ReadAll(tr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -706,7 +705,7 @@ func checkZip(t *testing.T, dlURL string, files map[string]task.WebsiteFile, fil
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(r)
|
b, err := io.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,11 @@
|
||||||
package protos
|
package protos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -4,6 +4,7 @@ package protos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -83,7 +82,7 @@ func TestFileServerHandler(t *testing.T) {
|
||||||
if resp.StatusCode != c.wantCode {
|
if resp.StatusCode != c.wantCode {
|
||||||
t.Errorf("rep.StatusCode = %d, wanted %d", resp.StatusCode, c.wantCode)
|
t.Errorf("rep.StatusCode = %d, wanted %d", resp.StatusCode, c.wantCode)
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(resp.Body)
|
b, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("resp.Body = _, %v, wanted no error", err)
|
t.Errorf("resp.Body = _, %v, wanted no error", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ func TestFlag(t *testing.T) {
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.flagVal, func(t *testing.T) {
|
t.Run(tt.flagVal, func(t *testing.T) {
|
||||||
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
fs.SetOutput(ioutil.Discard)
|
fs.SetOutput(io.Discard)
|
||||||
flagVal := r.Flag(fs, "testflag", "usage")
|
flagVal := r.Flag(fs, "testflag", "usage")
|
||||||
err := fs.Parse([]string{"--testflag", tt.flagVal})
|
err := fs.Parse([]string{"--testflag", tt.flagVal})
|
||||||
if tt.wantErr {
|
if tt.wantErr {
|
||||||
|
@ -214,7 +214,7 @@ func TestJSONFlag(t *testing.T) {
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.flagVal, func(t *testing.T) {
|
t.Run(tt.flagVal, func(t *testing.T) {
|
||||||
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
fs.SetOutput(ioutil.Discard)
|
fs.SetOutput(io.Discard)
|
||||||
value := &jsonValue{}
|
value := &jsonValue{}
|
||||||
r.JSONVarFlag(fs, value, "testflag", "usage")
|
r.JSONVarFlag(fs, value, "testflag", "usage")
|
||||||
err := fs.Parse([]string{"--testflag", tt.flagVal})
|
err := fs.Parse([]string{"--testflag", tt.flagVal})
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -145,11 +144,11 @@ func getSourceTgzFromURL(hc *http.Client, service, repo, rev, url string) (sourc
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode/100 != 2 {
|
if res.StatusCode/100 != 2 {
|
||||||
slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 4<<10))
|
slurp, _ := io.ReadAll(io.LimitReader(res.Body, 4<<10))
|
||||||
return source{}, fmt.Errorf("fetching %s/%s from %s: %v; body: %s", repo, rev, service, res.Status, slurp)
|
return source{}, fmt.Errorf("fetching %s/%s from %s: %v; body: %s", repo, rev, service, res.Status, slurp)
|
||||||
}
|
}
|
||||||
// See golang.org/issue/11224 for a discussion on tree filtering.
|
// See golang.org/issue/11224 for a discussion on tree filtering.
|
||||||
b, err := ioutil.ReadAll(io.LimitReader(res.Body, maxSize(repo)+1))
|
b, err := io.ReadAll(io.LimitReader(res.Body, maxSize(repo)+1))
|
||||||
if int64(len(b)) > maxSize(repo) && err == nil {
|
if int64(len(b)) > maxSize(repo) && err == nil {
|
||||||
return source{TooBig: true}, nil
|
return source{TooBig: true}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -270,7 +269,7 @@ func (b *fakeBuildlet) GetTar(ctx context.Context, dir string) (io.ReadCloser, e
|
||||||
if err := zw.Close(); err != nil {
|
if err := zw.Close(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return ioutil.NopCloser(buf), nil
|
return io.NopCloser(buf), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *fakeBuildlet) ListDir(ctx context.Context, dir string, opts buildlet.ListDirOpts, fn func(buildlet.DirEntry)) error {
|
func (b *fakeBuildlet) ListDir(ctx context.Context, dir string, opts buildlet.ListDirOpts, fn func(buildlet.DirEntry)) error {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -90,7 +89,7 @@ func (c *Client) RunLongLivedPod(ctx context.Context, pod *api.Pod) (*api.PodSta
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to make request: POST %q: %v", postURL, err)
|
return nil, fmt.Errorf("failed to make request: POST %q: %v", postURL, err)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read request body for POST %q: %v", postURL, err)
|
return nil, fmt.Errorf("failed to read request body for POST %q: %v", postURL, err)
|
||||||
|
@ -142,7 +141,7 @@ func (c *Client) do(ctx context.Context, method, urlStr string, dst interface{})
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
body, _ := ioutil.ReadAll(res.Body)
|
body, _ := io.ReadAll(res.Body)
|
||||||
return fmt.Errorf("%v %s: %v, %s", method, urlStr, res.Status, body)
|
return fmt.Errorf("%v %s: %v, %s", method, urlStr, res.Status, body)
|
||||||
}
|
}
|
||||||
if dst != nil {
|
if dst != nil {
|
||||||
|
@ -223,7 +222,7 @@ func (c *Client) DeletePod(ctx context.Context, podName string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to make request: DELETE %q: %v", url, err)
|
return fmt.Errorf("failed to make request: DELETE %q: %v", url, err)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read response body: DELETE %q: %v", url, err)
|
return fmt.Errorf("failed to read response body: DELETE %q: %v", url, err)
|
||||||
|
@ -389,7 +388,7 @@ func (c *Client) PodStatus(ctx context.Context, podName string) (*api.PodStatus,
|
||||||
return nil, fmt.Errorf("failed to make request: GET %q: %v", getURL, err)
|
return nil, fmt.Errorf("failed to make request: GET %q: %v", getURL, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read request body for GET %q: %v", getURL, err)
|
return nil, fmt.Errorf("failed to read request body for GET %q: %v", getURL, err)
|
||||||
|
@ -418,7 +417,7 @@ func (c *Client) PodLog(ctx context.Context, podName string) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to make request: GET %q: %v", url, err)
|
return "", fmt.Errorf("failed to make request: GET %q: %v", url, err)
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to read response body: GET %q: %v", url, err)
|
return "", fmt.Errorf("failed to read response body: GET %q: %v", url, err)
|
||||||
|
|
|
@ -8,9 +8,10 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -568,7 +569,7 @@ func TestParseGithubEvents(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseMultipleGithubEvents(t *testing.T) {
|
func TestParseMultipleGithubEvents(t *testing.T) {
|
||||||
content, err := ioutil.ReadFile(filepath.Join("testdata", "TestParseMultipleGithubEvents.json"))
|
content, err := os.ReadFile(filepath.Join("testdata", "TestParseMultipleGithubEvents.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error while loading testdata: %s\n", err.Error())
|
t.Errorf("error while loading testdata: %s\n", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -626,13 +627,13 @@ func (c *ClientMock) Do(req *http.Request) (*http.Response, error) {
|
||||||
c.testdata = "TestParseMultipleGithubEvents.json"
|
c.testdata = "TestParseMultipleGithubEvents.json"
|
||||||
}
|
}
|
||||||
timesDoWasCalled++
|
timesDoWasCalled++
|
||||||
content, _ := ioutil.ReadFile(filepath.Join("testdata", c.testdata))
|
content, _ := os.ReadFile(filepath.Join("testdata", c.testdata))
|
||||||
headers := make(http.Header, 0)
|
headers := make(http.Header, 0)
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
var b []byte
|
var b []byte
|
||||||
headers["Date"] = []string{string(t.AppendFormat(b, "Mon Jan _2 15:04:05 2006"))}
|
headers["Date"] = []string{string(t.AppendFormat(b, "Mon Jan _2 15:04:05 2006"))}
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
Body: ioutil.NopCloser(bytes.NewReader(content)),
|
Body: io.NopCloser(bytes.NewReader(content)),
|
||||||
Status: c.status,
|
Status: c.status,
|
||||||
StatusCode: c.statusCode,
|
StatusCode: c.statusCode,
|
||||||
Header: headers,
|
Header: headers,
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build windows || darwin
|
//go:build windows || darwin
|
||||||
// +build windows darwin
|
|
||||||
|
|
||||||
package robustio
|
package robustio
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build !windows && !darwin
|
//go:build !windows && !darwin
|
||||||
// +build !windows,!darwin
|
|
||||||
|
|
||||||
package robustio
|
package robustio
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,11 @@
|
||||||
package apipb
|
package apipb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -4,6 +4,7 @@ package apipb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -327,7 +326,7 @@ func getGithubToken(ctx context.Context) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenFile := filepath.Join(os.Getenv("HOME"), ".github-issue-token")
|
tokenFile := filepath.Join(os.Getenv("HOME"), ".github-issue-token")
|
||||||
slurp, err := ioutil.ReadFile(tokenFile)
|
slurp, err := os.ReadFile(tokenFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -391,11 +390,11 @@ func syncProdToDevMutationLogs() {
|
||||||
|
|
||||||
for name := range want {
|
for name := range want {
|
||||||
log.Printf("syncing %s from %s to %s", name, src, dst)
|
log.Printf("syncing %s from %s to %s", name, src, dst)
|
||||||
slurp, err := ioutil.ReadFile(filepath.Join(src, strings.TrimPrefix(name, "maintner-")))
|
slurp, err := os.ReadFile(filepath.Join(src, strings.TrimPrefix(name, "maintner-")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(filepath.Join(dst, name), slurp, 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(dst, name), slurp, 0644); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,15 @@ It has these top-level messages:
|
||||||
*/
|
*/
|
||||||
package maintpb
|
package maintpb
|
||||||
|
|
||||||
import proto "github.com/golang/protobuf/proto"
|
import (
|
||||||
import fmt "fmt"
|
fmt "fmt"
|
||||||
import math "math"
|
|
||||||
import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
|
||||||
|
math "math"
|
||||||
|
|
||||||
|
google_protobuf "github.com/golang/protobuf/ptypes/timestamp"
|
||||||
|
)
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
var _ = proto.Marshal
|
var _ = proto.Marshal
|
||||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче