1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

go: google.golang.org/api upgrade => v0.22.0

This commit is contained in:
Tom Limoncelli
2020-04-22 10:34:24 -04:00
parent 3b058eae65
commit 26abff8884
17 changed files with 1363 additions and 57 deletions

8
go.mod
View File

@ -47,12 +47,14 @@ require (
github.com/urfave/cli/v2 v2.2.0
github.com/vultr/govultr v0.2.0
golang.org/x/crypto v0.0.0-20200320181102-891825fb96df // indirect
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/tools v0.0.0-20200309202150-20ab64c0d93f // indirect
google.golang.org/api v0.20.0
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e // indirect
google.golang.org/api v0.22.0
gopkg.in/ini.v1 v1.42.0 // indirect
gopkg.in/ns1/ns1-go.v2 v2.0.0-20170502175150-c563826f4cbe
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.2.8
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
)

20
go.sum
View File

@ -119,6 +119,7 @@ github.com/google/go-querystring v1.0.1-0.20190318165438-c8c88dbee036/go.mod h1:
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
@ -169,6 +170,7 @@ github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeY
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@ -213,6 +215,7 @@ github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOe
github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU=
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff h1:+6NUiITWwE5q1KO6SAfUX918c+Tab0+tGAM/mtdlUyA=
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
@ -248,10 +251,12 @@ github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/vultr/govultr v0.2.0 h1:CZSNNCk+PHz9hzmfH2PFGkDgc3qNetwZqtcaqL8shlg=
github.com/vultr/govultr v0.2.0/go.mod h1:glSLa57Jdj5s860EEc6+DEBbb/t3aUOKnB4gVPmDVlQ=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g=
@ -267,7 +272,10 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
@ -289,6 +297,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZ
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd h1:QPwSajcTUrFriMF1nJ3XzgoqakqQEsnZf9LdXdi2nkI=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
@ -340,9 +350,13 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190624190245-7f2218787638 h1:uIfBkD8gLczr4XDgYpt/qJYds2YJwZRNw4zs7wSnNhk=
golang.org/x/tools v0.0.0-20190624190245-7f2218787638/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200309202150-20ab64c0d93f h1:NbrfHxef+IfdI86qCgO/1Siq1BuMH2xG0NqgvCguRhQ=
golang.org/x/tools v0.0.0-20200309202150-20ab64c0d93f/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e h1:3Dzrrxi54Io7Aoyb0PYLsI47K2TxkRQg+cqUn+m04do=
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -353,6 +367,8 @@ google.golang.org/api v0.7.0 h1:9sdfJOzWlkqPltHAuzT2Cp+yrBeY1KRVYgms8soxMwM=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.20.0 h1:jz2KixHX7EcCPiQrySzPdnYT7DbINAypCqKZ1Z7GM40=
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.22.0 h1:J1Pl9P2lnmYFSJvgs70DKELqHNh8CNWXPbud4njEE2s=
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@ -387,8 +403,10 @@ google.golang.org/protobuf v1.21.0 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zim
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ns1/ns1-go.v2 v2.0.0-20170502175150-c563826f4cbe h1:fuu3vZ8C6O8mk8Ich8YfkDv/Zpnx1HUotQk8JocBcSw=
@ -407,4 +425,6 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=

View File

@ -1,3 +1,7 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package gocommand is a helper for calling the go command.
package gocommand
@ -5,12 +9,73 @@ import (
"bytes"
"context"
"fmt"
"io"
"os"
"os/exec"
"regexp"
"strings"
"sync"
"time"
"golang.org/x/tools/internal/telemetry/event"
)
// An Runner will run go command invocations and serialize
// them if it sees a concurrency error.
type Runner struct {
// LoadMu guards packages.Load calls and associated state.
loadMu sync.Mutex
serializeLoads int
}
// 1.13: go: updates to go.mod needed, but contents have changed
// 1.14: go: updating go.mod: existing contents have changed since last read
var modConcurrencyError = regexp.MustCompile(`go:.*go.mod.*contents have changed`)
// Run calls Runner.RunRaw, serializing requests if they fight over
// go.mod changes.
func (runner *Runner) Run(ctx context.Context, inv Invocation) (*bytes.Buffer, error) {
stdout, _, friendly, _ := runner.RunRaw(ctx, inv)
return stdout, friendly
}
// Run calls Innvocation.RunRaw, serializing requests if they fight over
// go.mod changes.
func (runner *Runner) RunRaw(ctx context.Context, inv Invocation) (*bytes.Buffer, *bytes.Buffer, error, error) {
// We want to run invocations concurrently as much as possible. However,
// if go.mod updates are needed, only one can make them and the others will
// fail. We need to retry in those cases, but we don't want to thrash so
// badly we never recover. To avoid that, once we've seen one concurrency
// error, start serializing everything until the backlog has cleared out.
runner.loadMu.Lock()
var locked bool // If true, we hold the mutex and have incremented.
if runner.serializeLoads == 0 {
runner.loadMu.Unlock()
} else {
locked = true
runner.serializeLoads++
}
defer func() {
if locked {
runner.serializeLoads--
runner.loadMu.Unlock()
}
}()
for {
stdout, stderr, friendlyErr, err := inv.runRaw(ctx)
if friendlyErr == nil || !modConcurrencyError.MatchString(friendlyErr.Error()) {
return stdout, stderr, friendlyErr, err
}
event.Error(ctx, "Load concurrency error, will retry serially", err)
if !locked {
runner.loadMu.Lock()
runner.serializeLoads++
locked = true
}
}
}
// An Invocation represents a call to the go command.
type Invocation struct {
Verb string
@ -21,16 +86,27 @@ type Invocation struct {
Logf func(format string, args ...interface{})
}
// Run runs the invocation, returning its stdout and an error suitable for
// human consumption, including stderr.
func (i *Invocation) Run(ctx context.Context) (*bytes.Buffer, error) {
stdout, _, friendly, _ := i.RunRaw(ctx)
return stdout, friendly
// RunRaw is like RunPiped, but also returns the raw stderr and error for callers
// that want to do low-level error handling/recovery.
func (i *Invocation) runRaw(ctx context.Context) (stdout *bytes.Buffer, stderr *bytes.Buffer, friendlyError error, rawError error) {
stdout = &bytes.Buffer{}
stderr = &bytes.Buffer{}
rawError = i.RunPiped(ctx, stdout, stderr)
if rawError != nil {
// Check for 'go' executable not being found.
if ee, ok := rawError.(*exec.Error); ok && ee.Err == exec.ErrNotFound {
friendlyError = fmt.Errorf("go command required, not found: %v", ee)
}
if ctx.Err() != nil {
friendlyError = ctx.Err()
}
friendlyError = fmt.Errorf("err: %v: stderr: %s", rawError, stderr)
}
return
}
// RunRaw is like Run, but also returns the raw stderr and error for callers
// that want to do low-level error handling/recovery.
func (i *Invocation) RunRaw(ctx context.Context) (stdout *bytes.Buffer, stderr *bytes.Buffer, friendlyError error, rawError error) {
// RunPiped is like Run, but relies on the given stdout/stderr
func (i *Invocation) RunPiped(ctx context.Context, stdout, stderr io.Writer) error {
log := i.Logf
if log == nil {
log = func(string, ...interface{}) {}
@ -51,8 +127,6 @@ func (i *Invocation) RunRaw(ctx context.Context) (stdout *bytes.Buffer, stderr *
goArgs = append(goArgs, i.Args...)
}
cmd := exec.Command("go", goArgs...)
stdout = &bytes.Buffer{}
stderr = &bytes.Buffer{}
cmd.Stdout = stdout
cmd.Stderr = stderr
// On darwin the cwd gets resolved to the real path, which breaks anything that
@ -61,24 +135,15 @@ func (i *Invocation) RunRaw(ctx context.Context) (stdout *bytes.Buffer, stderr *
// The Go stdlib has a special feature where if the cwd and the PWD are the
// same node then it trusts the PWD, so by setting it in the env for the child
// process we fix up all the paths returned by the go command.
cmd.Env = append(append([]string{}, i.Env...), "PWD="+i.WorkingDir)
cmd.Dir = i.WorkingDir
cmd.Env = append(os.Environ(), i.Env...)
if i.WorkingDir != "" {
cmd.Env = append(cmd.Env, "PWD="+i.WorkingDir)
cmd.Dir = i.WorkingDir
}
defer func(start time.Time) { log("%s for %v", time.Since(start), cmdDebugStr(cmd)) }(time.Now())
rawError = runCmdContext(ctx, cmd)
friendlyError = rawError
if rawError != nil {
// Check for 'go' executable not being found.
if ee, ok := rawError.(*exec.Error); ok && ee.Err == exec.ErrNotFound {
friendlyError = fmt.Errorf("go command required, not found: %v", ee)
}
if ctx.Err() != nil {
friendlyError = ctx.Err()
}
friendlyError = fmt.Errorf("err: %v: stderr: %s", rawError, stderr)
}
return
return runCmdContext(ctx, cmd)
}
// runCmdContext is like exec.CommandContext except it sends os.Interrupt

View File

@ -747,6 +747,8 @@ func getPackageExports(ctx context.Context, wrapped func(PackageExport), searchP
type ProcessEnv struct {
LocalPrefix string
GocmdRunner *gocommand.Runner
BuildFlags []string
// If non-empty, these will be used instead of the
@ -830,7 +832,7 @@ func (e *ProcessEnv) invokeGo(ctx context.Context, verb string, args ...string)
Logf: e.Logf,
WorkingDir: e.WorkingDir,
}
return inv.Run(ctx)
return e.GocmdRunner.Run(ctx, inv)
}
func addStdlibCandidates(pass *pass, refs references) {

View File

@ -27,6 +27,7 @@ import (
"strings"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/internal/gocommand"
)
// Options is golang.org/x/tools/imports.Options with extra internal-only options.
@ -154,6 +155,10 @@ func initialize(filename string, src []byte, opt *Options) ([]byte, *Options, er
GOSUMDB: os.Getenv("GOSUMDB"),
}
}
// Set the gocmdRunner if the user has not provided it.
if opt.Env.GocmdRunner == nil {
opt.Env.GocmdRunner = &gocommand.Runner{}
}
if src == nil {
b, err := ioutil.ReadFile(filename)
if err != nil {

View File

@ -415,6 +415,9 @@ var stdlib = map[string][]string{
"crypto/tls": []string{
"Certificate",
"CertificateRequestInfo",
"CipherSuite",
"CipherSuiteName",
"CipherSuites",
"Client",
"ClientAuthType",
"ClientHelloInfo",
@ -434,6 +437,7 @@ var stdlib = map[string][]string{
"ECDSAWithP521AndSHA512",
"ECDSAWithSHA1",
"Ed25519",
"InsecureCipherSuites",
"Listen",
"LoadX509KeyPair",
"NewLRUClientSessionCache",
@ -465,6 +469,7 @@ var stdlib = map[string][]string{
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
@ -473,6 +478,7 @@ var stdlib = map[string][]string{
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_RC4_128_SHA",
"TLS_FALLBACK_SCSV",
"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
@ -698,36 +704,65 @@ var stdlib = map[string][]string{
"Attr",
"AttrAbstractOrigin",
"AttrAccessibility",
"AttrAddrBase",
"AttrAddrClass",
"AttrAlignment",
"AttrAllocated",
"AttrArtificial",
"AttrAssociated",
"AttrBaseTypes",
"AttrBinaryScale",
"AttrBitOffset",
"AttrBitSize",
"AttrByteSize",
"AttrCallAllCalls",
"AttrCallAllSourceCalls",
"AttrCallAllTailCalls",
"AttrCallColumn",
"AttrCallDataLocation",
"AttrCallDataValue",
"AttrCallFile",
"AttrCallLine",
"AttrCallOrigin",
"AttrCallPC",
"AttrCallParameter",
"AttrCallReturnPC",
"AttrCallTailCall",
"AttrCallTarget",
"AttrCallTargetClobbered",
"AttrCallValue",
"AttrCalling",
"AttrCommonRef",
"AttrCompDir",
"AttrConstExpr",
"AttrConstValue",
"AttrContainingType",
"AttrCount",
"AttrDataBitOffset",
"AttrDataLocation",
"AttrDataMemberLoc",
"AttrDecimalScale",
"AttrDecimalSign",
"AttrDeclColumn",
"AttrDeclFile",
"AttrDeclLine",
"AttrDeclaration",
"AttrDefaultValue",
"AttrDefaulted",
"AttrDeleted",
"AttrDescription",
"AttrDigitCount",
"AttrDiscr",
"AttrDiscrList",
"AttrDiscrValue",
"AttrDwoName",
"AttrElemental",
"AttrEncoding",
"AttrEndianity",
"AttrEntrypc",
"AttrEnumClass",
"AttrExplicit",
"AttrExportSymbols",
"AttrExtension",
"AttrExternal",
"AttrFrameBase",
@ -738,27 +773,47 @@ var stdlib = map[string][]string{
"AttrInline",
"AttrIsOptional",
"AttrLanguage",
"AttrLinkageName",
"AttrLocation",
"AttrLoclistsBase",
"AttrLowerBound",
"AttrLowpc",
"AttrMacroInfo",
"AttrMacros",
"AttrMainSubprogram",
"AttrMutable",
"AttrName",
"AttrNamelistItem",
"AttrNoreturn",
"AttrObjectPointer",
"AttrOrdering",
"AttrPictureString",
"AttrPriority",
"AttrProducer",
"AttrPrototyped",
"AttrPure",
"AttrRanges",
"AttrRank",
"AttrRecursive",
"AttrReference",
"AttrReturnAddr",
"AttrRnglistsBase",
"AttrRvalueReference",
"AttrSegment",
"AttrSibling",
"AttrSignature",
"AttrSmall",
"AttrSpecification",
"AttrStartScope",
"AttrStaticLink",
"AttrStmtList",
"AttrStrOffsetsBase",
"AttrStride",
"AttrStrideSize",
"AttrStringLength",
"AttrStringLengthBitSize",
"AttrStringLengthByteSize",
"AttrThreadsScaled",
"AttrTrampoline",
"AttrType",
"AttrUpperBound",
@ -772,18 +827,23 @@ var stdlib = map[string][]string{
"BoolType",
"CharType",
"Class",
"ClassAddrPtr",
"ClassAddress",
"ClassBlock",
"ClassConstant",
"ClassExprLoc",
"ClassFlag",
"ClassLinePtr",
"ClassLocList",
"ClassLocListPtr",
"ClassMacPtr",
"ClassRangeListPtr",
"ClassReference",
"ClassReferenceAlt",
"ClassReferenceSig",
"ClassRngList",
"ClassRngListsPtr",
"ClassStrOffsetsPtr",
"ClassString",
"ClassStringAlt",
"ClassUnknown",
@ -814,9 +874,13 @@ var stdlib = map[string][]string{
"Tag",
"TagAccessDeclaration",
"TagArrayType",
"TagAtomicType",
"TagBaseType",
"TagCallSite",
"TagCallSiteParameter",
"TagCatchDwarfBlock",
"TagClassType",
"TagCoarrayType",
"TagCommonDwarfBlock",
"TagCommonInclusion",
"TagCompileUnit",
@ -824,12 +888,15 @@ var stdlib = map[string][]string{
"TagConstType",
"TagConstant",
"TagDwarfProcedure",
"TagDynamicType",
"TagEntryPoint",
"TagEnumerationType",
"TagEnumerator",
"TagFileType",
"TagFormalParameter",
"TagFriend",
"TagGenericSubrange",
"TagImmutableType",
"TagImportedDeclaration",
"TagImportedModule",
"TagImportedUnit",
@ -853,6 +920,7 @@ var stdlib = map[string][]string{
"TagRvalueReferenceType",
"TagSetType",
"TagSharedType",
"TagSkeletonUnit",
"TagStringType",
"TagStructType",
"TagSubprogram",
@ -2359,6 +2427,7 @@ var stdlib = map[string][]string{
"RawValue",
"StructuralError",
"SyntaxError",
"TagBMPString",
"TagBitString",
"TagBoolean",
"TagEnum",
@ -2787,6 +2856,7 @@ var stdlib = map[string][]string{
"IsPredeclared",
"Mode",
"New",
"NewFromFiles",
"Note",
"Package",
"PreserveAST",
@ -3115,6 +3185,11 @@ var stdlib = map[string][]string{
"New64",
"New64a",
},
"hash/maphash": []string{
"Hash",
"MakeSeed",
"Seed",
},
"html": []string{
"EscapeString",
"UnescapeString",
@ -3367,6 +3442,7 @@ var stdlib = map[string][]string{
"Ldate",
"Llongfile",
"Lmicroseconds",
"Lmsgprefix",
"Logger",
"Lshortfile",
"LstdFlags",
@ -3443,6 +3519,7 @@ var stdlib = map[string][]string{
"Exp",
"Exp2",
"Expm1",
"FMA",
"Float32bits",
"Float32frombits",
"Float64bits",
@ -3567,6 +3644,9 @@ var stdlib = map[string][]string{
"OnesCount32",
"OnesCount64",
"OnesCount8",
"Rem",
"Rem32",
"Rem64",
"Reverse",
"Reverse16",
"Reverse32",
@ -5140,7 +5220,10 @@ var stdlib = map[string][]string{
"CTL_NET",
"CTL_QUERY",
"CTRL_BREAK_EVENT",
"CTRL_CLOSE_EVENT",
"CTRL_C_EVENT",
"CTRL_LOGOFF_EVENT",
"CTRL_SHUTDOWN_EVENT",
"CancelIo",
"CancelIoEx",
"CertAddCertificateContextToStore",
@ -10112,6 +10195,7 @@ var stdlib = map[string][]string{
"Duployan",
"Egyptian_Hieroglyphs",
"Elbasan",
"Elymaic",
"Ethiopic",
"Extender",
"FoldCategory",
@ -10215,6 +10299,7 @@ var stdlib = map[string][]string{
"Myanmar",
"N",
"Nabataean",
"Nandinagari",
"Nd",
"New_Tai_Lue",
"Newa",
@ -10224,6 +10309,7 @@ var stdlib = map[string][]string{
"Noncharacter_Code_Point",
"Number",
"Nushu",
"Nyiakeng_Puachue_Hmong",
"Ogham",
"Ol_Chiki",
"Old_Hungarian",
@ -10331,6 +10417,7 @@ var stdlib = map[string][]string{
"Vai",
"Variation_Selector",
"Version",
"Wancho",
"Warang_Citi",
"White_Space",
"Yi",

View File

@ -0,0 +1,113 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package event provides support for event based telemetry.
package event
import (
"fmt"
"time"
)
type eventType uint8
const (
invalidType = eventType(iota)
LogType // an event that should be recorded in a log
StartSpanType // the start of a span of time
EndSpanType // the end of a span of time
LabelType // some values that should be noted for later events
DetachType // an event that causes a context to detach
RecordType // a value that should be tracked
)
// sTags is used to hold a small number of tags inside an event whichout
// requiring a separate allocation.
// As tags are often on the stack, this avoids an allocation at all for
// the very common cases of simple events.
// The length needs to be large enough to cope with the majority of events
// but no so large as to cause undue stack pressure.
// A log message with two values will use 3 tags (one for each value and
// one for the message itself).
type sTags [3]Tag
// Event holds the information about an event of note that ocurred.
type Event struct {
At time.Time
typ eventType
static sTags // inline storage for the first few tags
dynamic []Tag // dynamically sized storage for remaining tags
}
// eventTagMap implements TagMap for a the tags of an Event.
type eventTagMap struct {
event Event
}
func (ev Event) IsLog() bool { return ev.typ == LogType }
func (ev Event) IsEndSpan() bool { return ev.typ == EndSpanType }
func (ev Event) IsStartSpan() bool { return ev.typ == StartSpanType }
func (ev Event) IsLabel() bool { return ev.typ == LabelType }
func (ev Event) IsDetach() bool { return ev.typ == DetachType }
func (ev Event) IsRecord() bool { return ev.typ == RecordType }
func (ev Event) Format(f fmt.State, r rune) {
tagMap := TagMap(ev)
if !ev.At.IsZero() {
fmt.Fprint(f, ev.At.Format("2006/01/02 15:04:05 "))
}
msg := Msg.Get(tagMap)
err := Err.Get(tagMap)
fmt.Fprint(f, msg)
if err != nil {
if f.Flag('+') {
fmt.Fprintf(f, ": %+v", err)
} else {
fmt.Fprintf(f, ": %v", err)
}
}
for index := 0; ev.Valid(index); index++ {
tag := ev.Tag(index)
// msg and err were both already printed above, so we skip them to avoid
// double printing
if !tag.Valid() || tag.Key() == Msg || tag.Key() == Err {
continue
}
fmt.Fprintf(f, "\n\t%v", tag)
}
}
func (ev Event) Valid(index int) bool {
return index >= 0 && index < len(ev.static)+len(ev.dynamic)
}
func (ev Event) Tag(index int) Tag {
if index < len(ev.static) {
return ev.static[index]
}
return ev.dynamic[index-len(ev.static)]
}
func (ev Event) Find(key Key) Tag {
for _, tag := range ev.static {
if tag.Key() == key {
return tag
}
}
for _, tag := range ev.dynamic {
if tag.Key() == key {
return tag
}
}
return Tag{}
}
func makeEvent(typ eventType, static sTags, tags []Tag) Event {
return Event{
typ: typ,
static: static,
dynamic: tags,
}
}

View File

@ -0,0 +1,68 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"context"
"sync/atomic"
"time"
"unsafe"
)
// Exporter is a function that handles events.
// It may return a modified context and event.
type Exporter func(context.Context, Event, TagMap) context.Context
var (
exporter unsafe.Pointer
)
// SetExporter sets the global exporter function that handles all events.
// The exporter is called synchronously from the event call site, so it should
// return quickly so as not to hold up user code.
func SetExporter(e Exporter) {
p := unsafe.Pointer(&e)
if e == nil {
// &e is always valid, and so p is always valid, but for the early abort
// of ProcessEvent to be efficient it needs to make the nil check on the
// pointer without having to dereference it, so we make the nil function
// also a nil pointer
p = nil
}
atomic.StorePointer(&exporter, p)
}
// deliver is called to deliver an event to the supplied exporter.
// it will fill in the time and generate the basic tag source.
func deliver(ctx context.Context, exporter Exporter, ev Event) context.Context {
// add the current time to the event
ev.At = time.Now()
// hand the event off to the current exporter
return exporter(ctx, ev, ev)
}
// dispatch is called to deliver an event to the global exporter if set.
func dispatch(ctx context.Context, ev Event) context.Context {
// get the global exporter and abort early if there is not one
exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter))
if exporterPtr == nil {
return ctx
}
return deliver(ctx, *exporterPtr, ev)
}
// dispatchPair is called to deliver a start event to the supplied exporter.
// It also returns a function that will deliver the end event to the same
// exporter.
// it will fill in the time and generate the basic tag source.
func dispatchPair(ctx context.Context, begin, end Event) (context.Context, func()) {
// get the global exporter and abort early if there is not one
exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter))
if exporterPtr == nil {
return ctx, func() {}
}
ctx = deliver(ctx, *exporterPtr, begin)
return ctx, func() { deliver(ctx, *exporterPtr, end) }
}

View File

@ -0,0 +1,565 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"fmt"
"io"
"math"
"strconv"
)
var (
// Msg is a key used to add message strings to tag lists.
Msg = NewStringKey("message", "a readable message")
// Name is used for things like traces that have a name.
Name = NewStringKey("name", "an entity name")
// Err is a key used to add error values to tag lists.
Err = NewErrorKey("error", "an error that occurred")
)
// Key is used as the identity of a Tag.
// Keys are intended to be compared by pointer only, the name should be unique
// for communicating with external systems, but it is not required or enforced.
type Key interface {
// Name returns the key name.
Name() string
// Description returns a string that can be used to describe the value.
Description() string
// Format is used in formatting to append the value of the tag to the
// supplied buffer.
// The formatter may use the supplied buf as a scratch area to avoid
// allocations.
Format(w io.Writer, buf []byte, tag Tag)
}
// ValueKey represents a key for untyped values.
type ValueKey struct {
name string
description string
}
// NewKey creates a new Key for untyped values.
func NewKey(name, description string) *ValueKey {
return &ValueKey{name: name, description: description}
}
func (k *ValueKey) Name() string { return k.name }
func (k *ValueKey) Description() string { return k.description }
func (k *ValueKey) Format(w io.Writer, buf []byte, tag Tag) {
fmt.Fprint(w, k.From(tag))
}
// Get can be used to get a tag for the key from a TagMap.
func (k *ValueKey) Get(tags TagMap) interface{} {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return nil
}
// From can be used to get a value from a Tag.
func (k *ValueKey) From(t Tag) interface{} { return t.UnpackValue() }
// Of creates a new Tag with this key and the supplied value.
func (k *ValueKey) Of(value interface{}) Tag { return TagOfValue(k, value) }
// IntKey represents a key
type IntKey struct {
name string
description string
}
// NewIntKey creates a new Key for int values.
func NewIntKey(name, description string) *IntKey {
return &IntKey{name: name, description: description}
}
func (k *IntKey) Name() string { return k.name }
func (k *IntKey) Description() string { return k.description }
func (k *IntKey) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *IntKey) Of(v int) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *IntKey) Get(tags TagMap) int {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *IntKey) From(t Tag) int { return int(t.Unpack64()) }
// Int8Key represents a key
type Int8Key struct {
name string
description string
}
// NewInt8Key creates a new Key for int8 values.
func NewInt8Key(name, description string) *Int8Key {
return &Int8Key{name: name, description: description}
}
func (k *Int8Key) Name() string { return k.name }
func (k *Int8Key) Description() string { return k.description }
func (k *Int8Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *Int8Key) Of(v int8) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *Int8Key) Get(tags TagMap) int8 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *Int8Key) From(t Tag) int8 { return int8(t.Unpack64()) }
// Int16Key represents a key
type Int16Key struct {
name string
description string
}
// NewInt16Key creates a new Key for int16 values.
func NewInt16Key(name, description string) *Int16Key {
return &Int16Key{name: name, description: description}
}
func (k *Int16Key) Name() string { return k.name }
func (k *Int16Key) Description() string { return k.description }
func (k *Int16Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *Int16Key) Of(v int16) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *Int16Key) Get(tags TagMap) int16 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *Int16Key) From(t Tag) int16 { return int16(t.Unpack64()) }
// Int32Key represents a key
type Int32Key struct {
name string
description string
}
// NewInt32Key creates a new Key for int32 values.
func NewInt32Key(name, description string) *Int32Key {
return &Int32Key{name: name, description: description}
}
func (k *Int32Key) Name() string { return k.name }
func (k *Int32Key) Description() string { return k.description }
func (k *Int32Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendInt(buf, int64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *Int32Key) Of(v int32) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *Int32Key) Get(tags TagMap) int32 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *Int32Key) From(t Tag) int32 { return int32(t.Unpack64()) }
// Int64Key represents a key
type Int64Key struct {
name string
description string
}
// NewInt64Key creates a new Key for int64 values.
func NewInt64Key(name, description string) *Int64Key {
return &Int64Key{name: name, description: description}
}
func (k *Int64Key) Name() string { return k.name }
func (k *Int64Key) Description() string { return k.description }
func (k *Int64Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendInt(buf, k.From(tag), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *Int64Key) Of(v int64) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *Int64Key) Get(tags TagMap) int64 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *Int64Key) From(t Tag) int64 { return int64(t.Unpack64()) }
// UIntKey represents a key
type UIntKey struct {
name string
description string
}
// NewUIntKey creates a new Key for uint values.
func NewUIntKey(name, description string) *UIntKey {
return &UIntKey{name: name, description: description}
}
func (k *UIntKey) Name() string { return k.name }
func (k *UIntKey) Description() string { return k.description }
func (k *UIntKey) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *UIntKey) Of(v uint) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *UIntKey) Get(tags TagMap) uint {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *UIntKey) From(t Tag) uint { return uint(t.Unpack64()) }
// UInt8Key represents a key
type UInt8Key struct {
name string
description string
}
// NewUInt8Key creates a new Key for uint8 values.
func NewUInt8Key(name, description string) *UInt8Key {
return &UInt8Key{name: name, description: description}
}
func (k *UInt8Key) Name() string { return k.name }
func (k *UInt8Key) Description() string { return k.description }
func (k *UInt8Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *UInt8Key) Of(v uint8) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *UInt8Key) Get(tags TagMap) uint8 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *UInt8Key) From(t Tag) uint8 { return uint8(t.Unpack64()) }
// UInt16Key represents a key
type UInt16Key struct {
name string
description string
}
// NewUInt16Key creates a new Key for uint16 values.
func NewUInt16Key(name, description string) *UInt16Key {
return &UInt16Key{name: name, description: description}
}
func (k *UInt16Key) Name() string { return k.name }
func (k *UInt16Key) Description() string { return k.description }
func (k *UInt16Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *UInt16Key) Of(v uint16) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *UInt16Key) Get(tags TagMap) uint16 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *UInt16Key) From(t Tag) uint16 { return uint16(t.Unpack64()) }
// UInt32Key represents a key
type UInt32Key struct {
name string
description string
}
// NewUInt32Key creates a new Key for uint32 values.
func NewUInt32Key(name, description string) *UInt32Key {
return &UInt32Key{name: name, description: description}
}
func (k *UInt32Key) Name() string { return k.name }
func (k *UInt32Key) Description() string { return k.description }
func (k *UInt32Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendUint(buf, uint64(k.From(tag)), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *UInt32Key) Of(v uint32) Tag { return TagOf64(k, uint64(v)) }
// Get can be used to get a tag for the key from a TagMap.
func (k *UInt32Key) Get(tags TagMap) uint32 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *UInt32Key) From(t Tag) uint32 { return uint32(t.Unpack64()) }
// UInt64Key represents a key
type UInt64Key struct {
name string
description string
}
// NewUInt64Key creates a new Key for uint64 values.
func NewUInt64Key(name, description string) *UInt64Key {
return &UInt64Key{name: name, description: description}
}
func (k *UInt64Key) Name() string { return k.name }
func (k *UInt64Key) Description() string { return k.description }
func (k *UInt64Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendUint(buf, k.From(tag), 10))
}
// Of creates a new Tag with this key and the supplied value.
func (k *UInt64Key) Of(v uint64) Tag { return TagOf64(k, v) }
// Get can be used to get a tag for the key from a TagMap.
func (k *UInt64Key) Get(tags TagMap) uint64 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *UInt64Key) From(t Tag) uint64 { return t.Unpack64() }
// Float32Key represents a key
type Float32Key struct {
name string
description string
}
// NewFloat32Key creates a new Key for float32 values.
func NewFloat32Key(name, description string) *Float32Key {
return &Float32Key{name: name, description: description}
}
func (k *Float32Key) Name() string { return k.name }
func (k *Float32Key) Description() string { return k.description }
func (k *Float32Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendFloat(buf, float64(k.From(tag)), 'E', -1, 32))
}
// Of creates a new Tag with this key and the supplied value.
func (k *Float32Key) Of(v float32) Tag {
return TagOf64(k, uint64(math.Float32bits(v)))
}
// Get can be used to get a tag for the key from a TagMap.
func (k *Float32Key) Get(tags TagMap) float32 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *Float32Key) From(t Tag) float32 {
return math.Float32frombits(uint32(t.Unpack64()))
}
// Float64Key represents a key
type Float64Key struct {
name string
description string
}
// NewFloat64Key creates a new Key for int64 values.
func NewFloat64Key(name, description string) *Float64Key {
return &Float64Key{name: name, description: description}
}
func (k *Float64Key) Name() string { return k.name }
func (k *Float64Key) Description() string { return k.description }
func (k *Float64Key) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendFloat(buf, k.From(tag), 'E', -1, 64))
}
// Of creates a new Tag with this key and the supplied value.
func (k *Float64Key) Of(v float64) Tag {
return TagOf64(k, math.Float64bits(v))
}
// Get can be used to get a tag for the key from a TagMap.
func (k *Float64Key) Get(tags TagMap) float64 {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return 0
}
// From can be used to get a value from a Tag.
func (k *Float64Key) From(t Tag) float64 {
return math.Float64frombits(t.Unpack64())
}
// StringKey represents a key
type StringKey struct {
name string
description string
}
// NewStringKey creates a new Key for int64 values.
func NewStringKey(name, description string) *StringKey {
return &StringKey{name: name, description: description}
}
func (k *StringKey) Name() string { return k.name }
func (k *StringKey) Description() string { return k.description }
func (k *StringKey) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendQuote(buf, k.From(tag)))
}
// Of creates a new Tag with this key and the supplied value.
func (k *StringKey) Of(v string) Tag { return TagOfString(k, v) }
// Get can be used to get a tag for the key from a TagMap.
func (k *StringKey) Get(tags TagMap) string {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return ""
}
// From can be used to get a value from a Tag.
func (k *StringKey) From(t Tag) string { return t.UnpackString() }
// BooleanKey represents a key
type BooleanKey struct {
name string
description string
}
// NewBooleanKey creates a new Key for bool values.
func NewBooleanKey(name, description string) *BooleanKey {
return &BooleanKey{name: name, description: description}
}
func (k *BooleanKey) Name() string { return k.name }
func (k *BooleanKey) Description() string { return k.description }
func (k *BooleanKey) Format(w io.Writer, buf []byte, tag Tag) {
w.Write(strconv.AppendBool(buf, k.From(tag)))
}
// Of creates a new Tag with this key and the supplied value.
func (k *BooleanKey) Of(v bool) Tag {
if v {
return TagOf64(k, 1)
}
return TagOf64(k, 0)
}
// Get can be used to get a tag for the key from a TagMap.
func (k *BooleanKey) Get(tags TagMap) bool {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return false
}
// From can be used to get a value from a Tag.
func (k *BooleanKey) From(t Tag) bool { return t.Unpack64() > 0 }
// ErrorKey represents a key
type ErrorKey struct {
name string
description string
}
// NewErrorKey creates a new Key for int64 values.
func NewErrorKey(name, description string) *ErrorKey {
return &ErrorKey{name: name, description: description}
}
func (k *ErrorKey) Name() string { return k.name }
func (k *ErrorKey) Description() string { return k.description }
func (k *ErrorKey) Format(w io.Writer, buf []byte, tag Tag) {
io.WriteString(w, k.From(tag).Error())
}
// Of creates a new Tag with this key and the supplied value.
func (k *ErrorKey) Of(v error) Tag { return TagOfValue(k, v) }
// Get can be used to get a tag for the key from a TagMap.
func (k *ErrorKey) Get(tags TagMap) error {
if t := tags.Find(k); t.Valid() {
return k.From(t)
}
return nil
}
// From can be used to get a value from a Tag.
func (k *ErrorKey) From(t Tag) error {
err, _ := t.UnpackValue().(error)
return err
}

View File

@ -0,0 +1,29 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"context"
)
// Label sends a label event to the exporter with the supplied tags.
func Label(ctx context.Context, tags ...Tag) context.Context {
return dispatch(ctx, makeEvent(LabelType, sTags{}, tags))
}
// Label1 sends a label event to the exporter with the supplied tags.
func Label1(ctx context.Context, t1 Tag) context.Context {
return dispatch(ctx, makeEvent(LabelType, sTags{t1}, nil))
}
// Label2 sends a label event to the exporter with the supplied tags.
func Label2(ctx context.Context, t1, t2 Tag) context.Context {
return dispatch(ctx, makeEvent(LabelType, sTags{t1, t2}, nil))
}
// Label3 sends a label event to the exporter with the supplied tags.
func Label3(ctx context.Context, t1, t2, t3 Tag) context.Context {
return dispatch(ctx, makeEvent(LabelType, sTags{t1, t2, t3}, nil))
}

View File

@ -0,0 +1,68 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"context"
"errors"
"fmt"
)
// Log sends a log event with the supplied tag list to the exporter.
func Log(ctx context.Context, tags ...Tag) {
dispatch(ctx, makeEvent(LogType, sTags{}, tags))
}
// Log1 sends a label event to the exporter with the supplied tags.
func Log1(ctx context.Context, t1 Tag) context.Context {
return dispatch(ctx, makeEvent(LogType, sTags{t1}, nil))
}
// Log2 sends a label event to the exporter with the supplied tags.
func Log2(ctx context.Context, t1, t2 Tag) context.Context {
return dispatch(ctx, makeEvent(LogType, sTags{t1, t2}, nil))
}
// Log3 sends a label event to the exporter with the supplied tags.
func Log3(ctx context.Context, t1, t2, t3 Tag) context.Context {
return dispatch(ctx, makeEvent(LogType, sTags{t1, t2, t3}, nil))
}
// Print takes a message and a tag list and combines them into a single event
// before delivering them to the exporter.
func Print(ctx context.Context, message string, tags ...Tag) {
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message)}, tags))
}
// Print1 takes a message and one tag delivers a log event to the exporter.
// It is a customized version of Print that is faster and does no allocation.
func Print1(ctx context.Context, message string, t1 Tag) {
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), t1}, nil))
}
// Print2 takes a message and two tags and delivers a log event to the exporter.
// It is a customized version of Print that is faster and does no allocation.
func Print2(ctx context.Context, message string, t1 Tag, t2 Tag) {
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), t1, t2}, nil))
}
// Error takes a message and a tag list and combines them into a single event
// before delivering them to the exporter. It captures the error in the
// delivered event.
func Error(ctx context.Context, message string, err error, tags ...Tag) {
if err == nil {
err = errors.New(message)
message = ""
}
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), Err.Of(err)}, tags))
}
// Debugf sends a log event with the supplied message to the exporter.
// This is intended only for temporary debugging lines, and usage should not
// normally be checked in, preffering structured log events for things
// that have to be used in production.
func Debugf(ctx context.Context, message string, args ...interface{}) {
dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(fmt.Sprintf(message, args...))}, nil))
}

View File

@ -0,0 +1,29 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"context"
)
// Record sends a label event to the exporter with the supplied tags.
func Record(ctx context.Context, tags ...Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{}, tags))
}
// Record1 sends a label event to the exporter with the supplied tags.
func Record1(ctx context.Context, t1 Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{t1}, nil))
}
// Record2 sends a label event to the exporter with the supplied tags.
func Record2(ctx context.Context, t1, t2 Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2}, nil))
}
// Record3 sends a label event to the exporter with the supplied tags.
func Record3(ctx context.Context, t1, t2, t3 Tag) context.Context {
return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2, t3}, nil))
}

View File

@ -0,0 +1,197 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"fmt"
"io"
"reflect"
"unsafe"
)
// Tag holds a key and value pair.
// It is normally used when passing around lists of tags.
type Tag struct {
key Key
packed uint64
untyped interface{}
}
// TagMap is the interface to a collection of Tags indexed by key.
type TagMap interface {
// Find returns the tag that matches the supplied key.
Find(key Key) Tag
}
// TagList is the interface to something that provides an iterable
// list of tags.
// Iteration should start from 0 and continue until Valid returns false.
type TagList interface {
// Valid returns true if the index is within range for the list.
// It does not imply the tag at that index will itself be valid.
Valid(index int) bool
// Tag returns the tag at the given index.
Tag(index int) Tag
}
// tagList implements TagList for a list of Tags.
type tagList struct {
tags []Tag
}
// tagFilter wraps a TagList filtering out specific tags.
type tagFilter struct {
keys []Key
underlying TagList
}
// tagMap implements TagMap for a simple list of tags.
type tagMap struct {
tags []Tag
}
// tagMapChain implements TagMap for a list of underlying TagMap.
type tagMapChain struct {
maps []TagMap
}
// TagOfValue creates a new tag from the key and value.
// This method is for implementing new key types, tag creation should
// normally be done with the Of method of the key.
func TagOfValue(k Key, value interface{}) Tag { return Tag{key: k, untyped: value} }
// UnpackValue assumes the tag was built using TagOfValue and returns the value
// that was passed to that constructor.
// This method is for implementing new key types, for type safety normal
// access should be done with the From method of the key.
func (t Tag) UnpackValue() interface{} { return t.untyped }
// TagOf64 creates a new tag from a key and a uint64. This is often
// used for non uint64 values that can be packed into a uint64.
// This method is for implementing new key types, tag creation should
// normally be done with the Of method of the key.
func TagOf64(k Key, v uint64) Tag { return Tag{key: k, packed: v} }
// Unpack64 assumes the tag was built using TagOf64 and returns the value that
// was passed to that constructor.
// This method is for implementing new key types, for type safety normal
// access should be done with the From method of the key.
func (t Tag) Unpack64() uint64 { return t.packed }
// TagOfString creates a new tag from a key and a string.
// This method is for implementing new key types, tag creation should
// normally be done with the Of method of the key.
func TagOfString(k Key, v string) Tag {
hdr := (*reflect.StringHeader)(unsafe.Pointer(&v))
return Tag{
key: k,
packed: uint64(hdr.Len),
untyped: unsafe.Pointer(hdr.Data),
}
}
// UnpackString assumes the tag was built using TagOfString and returns the
// value that was passed to that constructor.
// This method is for implementing new key types, for type safety normal
// access should be done with the From method of the key.
func (t Tag) UnpackString() string {
var v string
hdr := (*reflect.StringHeader)(unsafe.Pointer(&v))
hdr.Data = uintptr(t.untyped.(unsafe.Pointer))
hdr.Len = int(t.packed)
return *(*string)(unsafe.Pointer(hdr))
}
// Valid returns true if the Tag is a valid one (it has a key).
func (t Tag) Valid() bool { return t.key != nil }
// Key returns the key of this Tag.
func (t Tag) Key() Key { return t.key }
// Format is used for debug printing of tags.
func (t Tag) Format(f fmt.State, r rune) {
if !t.Valid() {
io.WriteString(f, `nil`)
return
}
io.WriteString(f, t.Key().Name())
io.WriteString(f, "=")
var buf [128]byte
t.Key().Format(f, buf[:0], t)
}
func (l *tagList) Valid(index int) bool {
return index >= 0 && index < len(l.tags)
}
func (l *tagList) Tag(index int) Tag {
return l.tags[index]
}
func (f *tagFilter) Valid(index int) bool {
return f.underlying.Valid(index)
}
func (f *tagFilter) Tag(index int) Tag {
tag := f.underlying.Tag(index)
for _, f := range f.keys {
if tag.Key() == f {
return Tag{}
}
}
return tag
}
func (l tagMap) Find(key Key) Tag {
for _, tag := range l.tags {
if tag.Key() == key {
return tag
}
}
return Tag{}
}
func (c tagMapChain) Find(key Key) Tag {
for _, src := range c.maps {
tag := src.Find(key)
if tag.Valid() {
return tag
}
}
return Tag{}
}
var emptyList = &tagList{}
func NewTagList(tags ...Tag) TagList {
if len(tags) == 0 {
return emptyList
}
return &tagList{tags: tags}
}
func Filter(l TagList, keys ...Key) TagList {
if len(keys) == 0 {
return l
}
return &tagFilter{keys: keys, underlying: l}
}
func NewTagMap(tags ...Tag) TagMap {
return tagMap{tags: tags}
}
func MergeTagMaps(srcs ...TagMap) TagMap {
var nonNil []TagMap
for _, src := range srcs {
if src != nil {
nonNil = append(nonNil, src)
}
}
if len(nonNil) == 1 {
return nonNil[0]
}
return tagMapChain{maps: nonNil}
}

View File

@ -0,0 +1,42 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package event
import (
"context"
)
// StartSpan sends a span start event with the supplied tag list to the exporter.
// It also returns a function that will end the span, which should normally be
// deferred.
func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) {
return dispatchPair(ctx,
makeEvent(StartSpanType, sTags{Name.Of(name)}, tags),
makeEvent(EndSpanType, sTags{}, nil))
}
// StartSpan1 sends a span start event with the supplied tag list to the exporter.
// It also returns a function that will end the span, which should normally be
// deferred.
func StartSpan1(ctx context.Context, name string, t1 Tag) (context.Context, func()) {
return dispatchPair(ctx,
makeEvent(StartSpanType, sTags{Name.Of(name), t1}, nil),
makeEvent(EndSpanType, sTags{}, nil))
}
// StartSpan2 sends a span start event with the supplied tag list to the exporter.
// It also returns a function that will end the span, which should normally be
// deferred.
func StartSpan2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func()) {
return dispatchPair(ctx,
makeEvent(StartSpanType, sTags{Name.Of(name), t1, t2}, nil),
makeEvent(EndSpanType, sTags{}, nil))
}
// Detach returns a context without an associated span.
// This allows the creation of spans that are not children of the current span.
func Detach(ctx context.Context) context.Context {
return dispatch(ctx, makeEvent(DetachType, sTags{}, nil))
}

View File

@ -1757,7 +1757,7 @@ func (c *ChangesCreateCall) Header() http.Header {
func (c *ChangesCreateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -1931,7 +1931,7 @@ func (c *ChangesGetCall) Header() http.Header {
func (c *ChangesGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -2132,7 +2132,7 @@ func (c *ChangesListCall) Header() http.Header {
func (c *ChangesListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -2356,7 +2356,7 @@ func (c *DnsKeysGetCall) Header() http.Header {
func (c *DnsKeysGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -2554,7 +2554,7 @@ func (c *DnsKeysListCall) Header() http.Header {
func (c *DnsKeysListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -2757,7 +2757,7 @@ func (c *ManagedZoneOperationsGetCall) Header() http.Header {
func (c *ManagedZoneOperationsGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -2952,7 +2952,7 @@ func (c *ManagedZoneOperationsListCall) Header() http.Header {
func (c *ManagedZoneOperationsListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -3152,7 +3152,7 @@ func (c *ManagedZonesCreateCall) Header() http.Header {
func (c *ManagedZonesCreateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -3305,7 +3305,7 @@ func (c *ManagedZonesDeleteCall) Header() http.Header {
func (c *ManagedZonesDeleteCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -3441,7 +3441,7 @@ func (c *ManagedZonesGetCall) Header() http.Header {
func (c *ManagedZonesGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -3623,7 +3623,7 @@ func (c *ManagedZonesListCall) Header() http.Header {
func (c *ManagedZonesListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -3807,7 +3807,7 @@ func (c *ManagedZonesPatchCall) Header() http.Header {
func (c *ManagedZonesPatchCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -3970,7 +3970,7 @@ func (c *ManagedZonesUpdateCall) Header() http.Header {
func (c *ManagedZonesUpdateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -4131,7 +4131,7 @@ func (c *PoliciesCreateCall) Header() http.Header {
func (c *PoliciesCreateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -4285,7 +4285,7 @@ func (c *PoliciesDeleteCall) Header() http.Header {
func (c *PoliciesDeleteCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -4421,7 +4421,7 @@ func (c *PoliciesGetCall) Header() http.Header {
func (c *PoliciesGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -4595,7 +4595,7 @@ func (c *PoliciesListCall) Header() http.Header {
func (c *PoliciesListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -4774,7 +4774,7 @@ func (c *PoliciesPatchCall) Header() http.Header {
func (c *PoliciesPatchCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -4937,7 +4937,7 @@ func (c *PoliciesUpdateCall) Header() http.Header {
func (c *PoliciesUpdateCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -5107,7 +5107,7 @@ func (c *ProjectsGetCall) Header() http.Header {
func (c *ProjectsGetCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}
@ -5291,7 +5291,7 @@ func (c *ResourceRecordSetsListCall) Header() http.Header {
func (c *ResourceRecordSetsListCall) doRequest(alt string) (*http.Response, error) {
reqHeaders := make(http.Header)
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200302")
reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200410")
for k, v := range c.header_ {
reqHeaders[k] = v
}

View File

@ -202,10 +202,19 @@ func addOCTransport(trans http.RoundTripper, settings *internal.DialSettings) ht
// We would like to avoid introducing client-side logic that parses whether the
// endpoint override is an mTLS url, since the url pattern may change at anytime.
func getClientCertificateSource(settings *internal.DialSettings) (cert.Source, error) {
if settings.ClientCertSource != nil {
return settings.ClientCertSource, nil
}
return cert.DefaultSource()
return settings.ClientCertSource, nil
// TODO(andyzhao): Currently, many services including compute, storage, and bigquery
// do not have working mTLS endpoints, so we will disable the ADC for DCA logic
// until we can confirm that all services have working mTLS endpoints.
/*
if settings.HTTPClient != nil {
return nil, nil // HTTPClient is incompatible with ClientCertificateSource
} else if settings.ClientCertSource != nil {
return settings.ClientCertSource, nil
} else {
return cert.DefaultSoure()
}
*/
}
// getEndpoint returns the endpoint for the service, taking into account the

11
vendor/modules.txt vendored
View File

@ -315,10 +315,12 @@ golang.org/x/crypto/ocsp
golang.org/x/crypto/pbkdf2
golang.org/x/crypto/pkcs12
golang.org/x/crypto/pkcs12/internal/rc2
# golang.org/x/lint v0.0.0-20200302205851-738671d3881b
## explicit
# golang.org/x/mod v0.2.0
golang.org/x/mod/module
golang.org/x/mod/semver
# golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
# golang.org/x/net v0.0.0-20200421231249-e086a090c8fd
## explicit
golang.org/x/net/bpf
golang.org/x/net/context
@ -358,7 +360,7 @@ golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm
# golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
golang.org/x/time/rate
# golang.org/x/tools v0.0.0-20200309202150-20ab64c0d93f
# golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e
## explicit
golang.org/x/tools/go/ast/astutil
golang.org/x/tools/imports
@ -366,10 +368,11 @@ golang.org/x/tools/internal/fastwalk
golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/imports
golang.org/x/tools/internal/telemetry/event
# golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
golang.org/x/xerrors
golang.org/x/xerrors/internal
# google.golang.org/api v0.20.0
# google.golang.org/api v0.22.0
## explicit
google.golang.org/api/dns/v1
google.golang.org/api/googleapi
@ -486,3 +489,5 @@ gopkg.in/square/go-jose.v2/jwt
# gopkg.in/yaml.v2 v2.2.8
## explicit
gopkg.in/yaml.v2
# honnef.co/go/tools v0.0.1-2020.1.3
## explicit