mirror of https://github.com/perkeep/perkeep.git
all: fix or disable staticcheck deprecations
(Originally from https://github.com/perkeep/perkeep/pull/1648)
This commit is contained in:
parent
bc9fbcd89e
commit
a911bc8060
|
@ -265,10 +265,10 @@ func (zh *zipHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
zh := zip.FileHeader{
|
zh := zip.FileHeader{
|
||||||
Name: file.path,
|
Name: file.path,
|
||||||
Method: zip.Store,
|
Method: zip.Store,
|
||||||
|
Modified: fr.ModTime().UTC(),
|
||||||
}
|
}
|
||||||
zh.SetModTime(fr.ModTime())
|
|
||||||
f, err := zw.CreateHeader(&zh)
|
f, err := zw.CreateHeader(&zh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Could not create %q in zip: %v", file.path, err)
|
log.Printf("Could not create %q in zip: %v", file.path, err)
|
||||||
|
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"golang.org/x/oauth2/google"
|
"golang.org/x/oauth2/google"
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
"google.golang.org/api/googleapi"
|
"google.golang.org/api/googleapi"
|
||||||
|
"google.golang.org/api/option"
|
||||||
"perkeep.org/internal/osutil"
|
"perkeep.org/internal/osutil"
|
||||||
"perkeep.org/pkg/env"
|
"perkeep.org/pkg/env"
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ func gceInstance() (*gceInst, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting a default http client: %v", err)
|
return nil, fmt.Errorf("error getting a default http client: %v", err)
|
||||||
}
|
}
|
||||||
cs, err := compute.New(hc)
|
cs, err := compute.NewService(ctx, option.WithHTTPClient(hc))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting a compute service: %v", err)
|
return nil, fmt.Errorf("error getting a compute service: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ func ProjectTokenSource(proj string, scopes ...string) (oauth2.TokenSource, erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("reading JSON config from %s: %v", fileName, err)
|
return nil, fmt.Errorf("reading JSON config from %s: %v", fileName, err)
|
||||||
}
|
}
|
||||||
return conf.TokenSource(oauth2.NoContext), nil
|
return conf.TokenSource(context.TODO()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var bucketProject = map[string]string{
|
var bucketProject = map[string]string{
|
||||||
|
|
|
@ -924,7 +924,7 @@ func ProjectTokenSource(proj string, scopes ...string) (oauth2.TokenSource, erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("reading JSON config from %s: %v", fileName, err)
|
return nil, fmt.Errorf("reading JSON config from %s: %v", fileName, err)
|
||||||
}
|
}
|
||||||
return conf.TokenSource(oauth2.NoContext), nil
|
return conf.TokenSource(context.TODO()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var bucketProject = map[string]string{
|
var bucketProject = map[string]string{
|
||||||
|
|
|
@ -94,7 +94,7 @@ func testServeBlobContents(t *testing.T, contents, wantType string) {
|
||||||
if rr.Code != 200 {
|
if rr.Code != 200 {
|
||||||
t.Errorf("Response code = %d; want 200", rr.Code)
|
t.Errorf("Response code = %d; want 200", rr.Code)
|
||||||
}
|
}
|
||||||
if g, w := rr.HeaderMap.Get("Content-Type"), wantType; g != w {
|
if g, w := rr.Result().Header.Get("Content-Type"), wantType; g != w {
|
||||||
t.Errorf("Content-Type = %q; want %q", g, w)
|
t.Errorf("Content-Type = %q; want %q", g, w)
|
||||||
}
|
}
|
||||||
if rr.Body.String() != contents {
|
if rr.Body.String() != contents {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
"google.golang.org/api/drive/v3"
|
"google.golang.org/api/drive/v3"
|
||||||
"google.golang.org/api/googleapi"
|
"google.golang.org/api/googleapi"
|
||||||
|
"google.golang.org/api/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
var scopeURLs = []string{drive.DriveReadonlyScope}
|
var scopeURLs = []string{drive.DriveReadonlyScope}
|
||||||
|
@ -50,7 +51,7 @@ const (
|
||||||
// The permission ID becomes the "userID" (AcctAttrUserID) value on the
|
// The permission ID becomes the "userID" (AcctAttrUserID) value on the
|
||||||
// account's "importerAccount" permanode.
|
// account's "importerAccount" permanode.
|
||||||
func getUser(ctx context.Context, client *http.Client) (*drive.User, error) {
|
func getUser(ctx context.Context, client *http.Client) (*drive.User, error) {
|
||||||
srv, err := drive.New(client)
|
srv, err := drive.NewService(ctx, option.WithHTTPClient(client))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -75,8 +76,8 @@ type downloader struct {
|
||||||
//
|
//
|
||||||
// The client must be authenticated for drive.DrivePhotosReadonlyScope
|
// The client must be authenticated for drive.DrivePhotosReadonlyScope
|
||||||
// ("https://www.googleapis.com/auth/drive.photos.readonly")..
|
// ("https://www.googleapis.com/auth/drive.photos.readonly")..
|
||||||
func newDownloader(client *http.Client) (*downloader, error) {
|
func newDownloader(ctx context.Context, client *http.Client) (*downloader, error) {
|
||||||
srv, err := drive.New(client)
|
srv, err := drive.NewService(ctx, option.WithHTTPClient(client))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ func (imp) Run(rctx *importer.RunContext) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dl, err := newDownloader(ctxutil.Client(ctx))
|
dl, err := newDownloader(ctx, ctxutil.Client(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,6 @@ func TestImportRootPageHTML(t *testing.T) {
|
||||||
r := httptest.NewRequest("GET", "/importer/", nil)
|
r := httptest.NewRequest("GET", "/importer/", nil)
|
||||||
h.serveImportersRoot(w, r)
|
h.serveImportersRoot(w, r)
|
||||||
if w.Code != 200 || !strings.Contains(w.Body.String(), "dummy1") {
|
if w.Code != 200 || !strings.Contains(w.Body.String(), "dummy1") {
|
||||||
t.Errorf("Got %d response with header %v, body %s", w.Code, w.HeaderMap, w.Body.String())
|
t.Errorf("Got %d response with header %v, body %s", w.Code, w.Result().Header, w.Body.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,10 +325,9 @@ func (im *imp) LongPoll(rctx *importer.RunContext) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
form := url.Values{"with": {"user"}}
|
form := url.Values{"with": {"user"}}
|
||||||
req, _ := http.NewRequest("GET", "https://userstream.twitter.com/1.1/user.json", nil)
|
req, _ := http.NewRequestWithContext(rctx.Context(), "GET", "https://userstream.twitter.com/1.1/user.json", nil)
|
||||||
req.Header.Set("Authorization", oauthClient.AuthorizationHeader(accessCreds, "GET", req.URL, form))
|
req.Header.Set("Authorization", oauthClient.AuthorizationHeader(accessCreds, "GET", req.URL, form))
|
||||||
req.URL.RawQuery = form.Encode()
|
req.URL.RawQuery = form.Encode()
|
||||||
req.Cancel = rctx.Context().Done()
|
|
||||||
|
|
||||||
log.Printf("twitter: beginning long poll, awaiting new tweets...")
|
log.Printf("twitter: beginning long poll, awaiting new tweets...")
|
||||||
res, err := http.DefaultClient.Do(req)
|
res, err := http.DefaultClient.Do(req)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"cloud.google.com/go/compute/metadata"
|
"cloud.google.com/go/compute/metadata"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"golang.org/x/oauth2/google"
|
"golang.org/x/oauth2/google"
|
||||||
|
"google.golang.org/api/option"
|
||||||
sqladmin "google.golang.org/api/sqladmin/v1beta4"
|
sqladmin "google.golang.org/api/sqladmin/v1beta4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -45,7 +46,8 @@ func maybeRemapCloudSQL(host string) (out string, err error) {
|
||||||
return "", fmt.Errorf("Failed to lookup GCE project ID: %v", err)
|
return "", fmt.Errorf("Failed to lookup GCE project ID: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
admin, _ := sqladmin.New(oauth2.NewClient(context.Background(), google.ComputeTokenSource("")))
|
ctx := context.TODO()
|
||||||
|
admin, _ := sqladmin.NewService(ctx, option.WithHTTPClient(oauth2.NewClient(ctx, google.ComputeTokenSource(""))))
|
||||||
listRes, err := admin.Instances.List(proj).Do()
|
listRes, err := admin.Instances.List(proj).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error enumerating Cloud SQL instances: %v", err)
|
return "", fmt.Errorf("error enumerating Cloud SQL instances: %v", err)
|
||||||
|
|
|
@ -76,7 +76,7 @@ func maybeSetupGoogleCloudLogging() io.Closer {
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
logc, err := logging.NewClient(ctx,
|
logc, err := logging.NewClient(ctx,
|
||||||
flagGCEProjectID, option.WithServiceAccountFile(flagGCEJWTFile))
|
flagGCEProjectID, option.WithCredentialsFile(flagGCEJWTFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exitf("Error creating GCL client: %v", err)
|
exitf("Error creating GCL client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue