vendor: make vendor-update

This commit is contained in:
Aliaksandr Valialkin 2023-03-15 13:24:12 -07:00
parent 91cbb9063d
commit ddbbc9a86d
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
38 changed files with 2271 additions and 2171 deletions

12
go.mod
View file

@ -3,7 +3,7 @@ module github.com/VictoriaMetrics/VictoriaMetrics
go 1.19 go 1.19
require ( require (
cloud.google.com/go/storage v1.29.0 cloud.google.com/go/storage v1.30.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0
github.com/VictoriaMetrics/fastcache v1.12.1 github.com/VictoriaMetrics/fastcache v1.12.1
@ -21,7 +21,7 @@ require (
github.com/cheggaaa/pb/v3 v3.1.2 github.com/cheggaaa/pb/v3 v3.1.2
github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf v1.3.2
github.com/golang/snappy v0.0.4 github.com/golang/snappy v0.0.4
github.com/googleapis/gax-go/v2 v2.7.1 github.com/googleapis/gax-go/v2 v2.8.0
github.com/influxdata/influxdb v1.11.0 github.com/influxdata/influxdb v1.11.0
github.com/klauspost/compress v1.16.3 github.com/klauspost/compress v1.16.3
github.com/prometheus/prometheus v0.42.0 github.com/prometheus/prometheus v0.42.0
@ -35,7 +35,7 @@ require (
golang.org/x/net v0.8.0 golang.org/x/net v0.8.0
golang.org/x/oauth2 v0.6.0 golang.org/x/oauth2 v0.6.0
golang.org/x/sys v0.6.0 golang.org/x/sys v0.6.0
google.golang.org/api v0.112.0 google.golang.org/api v0.113.0
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
) )
@ -43,11 +43,11 @@ require (
cloud.google.com/go v0.110.0 // indirect cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.12.0 // indirect cloud.google.com/go/iam v0.13.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect github.com/VividCortex/ewma v1.2.0 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/aws/aws-sdk-go v1.44.221 // indirect github.com/aws/aws-sdk-go v1.44.222 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.17 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.17 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.0 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.0 // indirect
@ -106,7 +106,7 @@ require (
go.opentelemetry.io/otel/trace v1.14.0 // indirect go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.10.0 // indirect go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect go.uber.org/goleak v1.2.1 // indirect
golang.org/x/exp v0.0.0-20230314191032-db074128a8ec // indirect golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
golang.org/x/sync v0.1.0 // indirect golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.8.0 // indirect golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect golang.org/x/time v0.3.0 // indirect

24
go.sum
View file

@ -27,8 +27,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
cloud.google.com/go/iam v0.12.0 h1:DRtTY29b75ciH6Ov1PHb4/iat2CLCvrOm40Q0a6DFpE= cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k=
cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0=
cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
@ -39,8 +39,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.29.0 h1:6weCgzRvMg7lzuUurI4697AqIRPU1SvzHhynwpW31jI= cloud.google.com/go/storage v1.30.0 h1:g1yrbxAWOrvg/594228pETWkOi00MLTrOWfh56veU5o=
cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4= cloud.google.com/go/storage v1.30.0/go.mod h1:xAVretHSROm1BQX4IIsoVgJqw0LqOyX+I/O2GzRAzdE=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/azure-sdk-for-go v65.0.0+incompatible h1:HzKLt3kIwMm4KeJYTdx9EbjRYTySD/t8i1Ee/W5EGXw= github.com/Azure/azure-sdk-for-go v65.0.0+incompatible h1:HzKLt3kIwMm4KeJYTdx9EbjRYTySD/t8i1Ee/W5EGXw=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY=
@ -86,8 +86,8 @@ github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu
github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo=
github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.44.221 h1:yndn4uvLolKXPoXIwKHhO5XtwlTnJfXLBKXs84C5+hQ= github.com/aws/aws-sdk-go v1.44.222 h1:hagcC+MrGo60DKEbX0g6/ge4pIj7vBbsIb+vrhA/54I=
github.com/aws/aws-sdk-go v1.44.221/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.222/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0= github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0=
github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs=
@ -268,8 +268,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9
github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gax-go/v2 v2.7.1 h1:gF4c0zjUP2H/s/hEGyLA3I0fA2ZWjzYiONAD6cvPr8A= github.com/googleapis/gax-go/v2 v2.8.0 h1:UBtEZqx1bjXtOQ5BVTkuYghXrr3N4V123VKJK67vJZc=
github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= github.com/googleapis/gax-go/v2 v2.8.0/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI=
github.com/gophercloud/gophercloud v1.1.1 h1:MuGyqbSxiuVBqkPZ3+Nhbytk1xZxhmfCB2Rg1cJWFWM= github.com/gophercloud/gophercloud v1.1.1 h1:MuGyqbSxiuVBqkPZ3+Nhbytk1xZxhmfCB2Rg1cJWFWM=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww= github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww=
@ -479,8 +479,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230314191032-db074128a8ec h1:pAv+d8BM2JNnNctsLJ6nnZ6NqXT8N4+eauvZSb3P0I0= golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo=
golang.org/x/exp v0.0.0-20230314191032-db074128a8ec/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -691,8 +691,8 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
google.golang.org/api v0.112.0 h1:iDmzvZ4C086R3+en4nSyIf07HlQKMOX1Xx2dmia/+KQ= google.golang.org/api v0.113.0 h1:3zLZyS9hgne8yoXUFy871yWdQcA2tA6wp59aaCT6Cp4=
google.golang.org/api v0.112.0/go.mod h1:737UfWHNsOq4F3REUTmb+GN9pugkgNLCayLTfoIKpPc= google.golang.org/api v0.113.0/go.mod h1:ifYI2ZsFK6/uGddGfAD5BMxlnkBqCmqHSDUVi45N5Yg=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 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.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=

View file

@ -1,5 +1,12 @@
# Changes # Changes
## [0.13.0](https://github.com/googleapis/google-cloud-go/compare/iam/v0.12.0...iam/v0.13.0) (2023-03-15)
### Features
* **iam:** Update iam and longrunning deps ([91a1f78](https://github.com/googleapis/google-cloud-go/commit/91a1f784a109da70f63b96414bba8a9b4254cddd))
## [0.12.0](https://github.com/googleapis/google-cloud-go/compare/iam/v0.11.0...iam/v0.12.0) (2023-02-17) ## [0.12.0](https://github.com/googleapis/google-cloud-go/compare/iam/v0.11.0...iam/v0.12.0) (2023-02-17)

View file

@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.26.0 // protoc-gen-go v1.26.0
// protoc v3.21.12 // protoc v3.21.9
// source: google/iam/v1/iam_policy.proto // source: google/iam/v1/iam_policy.proto
package iampb package iampb

View file

@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.26.0 // protoc-gen-go v1.26.0
// protoc v3.21.12 // protoc v3.21.9
// source: google/iam/v1/options.proto // source: google/iam/v1/options.proto
package iampb package iampb

View file

@ -15,7 +15,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.26.0 // protoc-gen-go v1.26.0
// protoc v3.21.12 // protoc v3.21.9
// source: google/iam/v1/policy.proto // source: google/iam/v1/policy.proto
package iampb package iampb

View file

@ -1,6 +1,20 @@
# Changes # Changes
## [1.30.0](https://github.com/googleapis/google-cloud-go/compare/storage/v1.29.0...storage/v1.30.0) (2023-03-15)
### Features
* **storage/internal:** Update routing annotation for CreateBucketRequest docs: Add support for end-to-end checksumming in the gRPC WriteObject flow feat!: BREAKING CHANGE - renaming Notification to NotificationConfig ([2fef56f](https://github.com/googleapis/google-cloud-go/commit/2fef56f75a63dc4ff6e0eea56c7b26d4831c8e27))
* **storage:** Json downloads ([#7158](https://github.com/googleapis/google-cloud-go/issues/7158)) ([574a86c](https://github.com/googleapis/google-cloud-go/commit/574a86c614445f8c3f5a54446820df774c31cd47))
* **storage:** Update iam and longrunning deps ([91a1f78](https://github.com/googleapis/google-cloud-go/commit/91a1f784a109da70f63b96414bba8a9b4254cddd))
### Bug Fixes
* **storage:** Specify credentials with STORAGE_EMULATOR_HOST ([#7271](https://github.com/googleapis/google-cloud-go/issues/7271)) ([940ae15](https://github.com/googleapis/google-cloud-go/commit/940ae15f725ff384e345e627feb03d22e1fd8db5))
## [1.29.0](https://github.com/googleapis/google-cloud-go/compare/storage/v1.28.1...storage/v1.29.0) (2023-01-19) ## [1.29.0](https://github.com/googleapis/google-cloud-go/compare/storage/v1.28.1...storage/v1.29.0) (2023-01-19)

View file

@ -19,9 +19,9 @@ import (
"io" "io"
"time" "time"
"cloud.google.com/go/iam/apiv1/iampb"
gax "github.com/googleapis/gax-go/v2" gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/option" "google.golang.org/api/option"
iampb "google.golang.org/genproto/googleapis/iam/v1"
) )
// TODO(noahdietz): Move existing factory methods to this file. // TODO(noahdietz): Move existing factory methods to this file.

View file

@ -36,6 +36,9 @@ The client will use your default application credentials. Clients should be
reused instead of created as needed. The methods of [Client] are safe for reused instead of created as needed. The methods of [Client] are safe for
concurrent use by multiple goroutines. concurrent use by multiple goroutines.
You may configure the client by passing in options from the [google.golang.org/api/option]
package. You may also use options defined in this package, such as [WithJSONReads].
If you only wish to access public data, you can create If you only wish to access public data, you can create
an unauthenticated client with an unauthenticated client with

View file

@ -17,11 +17,13 @@ package storage
import ( import (
"context" "context"
"encoding/base64" "encoding/base64"
"errors"
"fmt" "fmt"
"io" "io"
"net/url" "net/url"
"os" "os"
"cloud.google.com/go/iam/apiv1/iampb"
"cloud.google.com/go/internal/trace" "cloud.google.com/go/internal/trace"
gapic "cloud.google.com/go/storage/internal/apiv2" gapic "cloud.google.com/go/storage/internal/apiv2"
storagepb "cloud.google.com/go/storage/internal/apiv2/stubs" storagepb "cloud.google.com/go/storage/internal/apiv2/stubs"
@ -29,7 +31,6 @@ import (
"google.golang.org/api/iterator" "google.golang.org/api/iterator"
"google.golang.org/api/option" "google.golang.org/api/option"
"google.golang.org/api/option/internaloption" "google.golang.org/api/option/internaloption"
iampb "google.golang.org/genproto/googleapis/iam/v1"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
@ -110,6 +111,11 @@ func newGRPCStorageClient(ctx context.Context, opts ...storageOption) (storageCl
s := initSettings(opts...) s := initSettings(opts...)
s.clientOption = append(defaultGRPCOptions(), s.clientOption...) s.clientOption = append(defaultGRPCOptions(), s.clientOption...)
config := newStorageConfig(s.clientOption...)
if config.readAPIWasSet {
return nil, errors.New("storage: GRPC is incompatible with any option that specifies an API for reads")
}
g, err := gapic.NewClient(ctx, s.clientOption...) g, err := gapic.NewClient(ctx, s.clientOption...)
if err != nil { if err != nil {
return nil, err return nil, err
@ -855,13 +861,6 @@ func (c *grpcStorageClient) NewRangeReader(ctx context.Context, params *newRange
ctx = setUserProjectMetadata(ctx, s.userProject) ctx = setUserProjectMetadata(ctx, s.userProject)
} }
// A negative length means "read to the end of the object", but the
// read_limit field it corresponds to uses zero to mean the same thing. Thus
// we coerce the length to 0 to read to the end of the object.
if params.length < 0 {
params.length = 0
}
b := bucketResourceName(globalProjectAlias, params.bucket) b := bucketResourceName(globalProjectAlias, params.bucket)
req := &storagepb.ReadObjectRequest{ req := &storagepb.ReadObjectRequest{
Bucket: b, Bucket: b,
@ -884,13 +883,20 @@ func (c *grpcStorageClient) NewRangeReader(ctx context.Context, params *newRange
cc, cancel := context.WithCancel(ctx) cc, cancel := context.WithCancel(ctx)
start := params.offset + seen req.ReadOffset = params.offset + seen
// A negative length means "read to the end of the object", but the
// read_limit field it corresponds to uses zero to mean the same thing. Thus
// we coerce the length to 0 to read to the end of the object.
if params.length < 0 {
params.length = 0
}
// Only set a ReadLimit if length is greater than zero, because zero // Only set a ReadLimit if length is greater than zero, because zero
// means read it all. // means read it all.
if params.length > 0 { if params.length > 0 {
req.ReadLimit = params.length - seen req.ReadLimit = params.length - seen
} }
req.ReadOffset = start
if err := applyCondsProto("gRPCReader.reopen", params.gen, params.conds, req); err != nil { if err := applyCondsProto("gRPCReader.reopen", params.gen, params.conds, req); err != nil {
cancel() cancel()
@ -963,7 +969,7 @@ func (c *grpcStorageClient) NewRangeReader(ctx context.Context, params *newRange
cr := msg.GetContentRange() cr := msg.GetContentRange()
if cr != nil { if cr != nil {
r.Attrs.StartOffset = cr.GetStart() r.Attrs.StartOffset = cr.GetStart()
r.remain = cr.GetEnd() - cr.GetStart() + 1 r.remain = cr.GetEnd() - cr.GetStart()
} else { } else {
r.remain = size r.remain = size
} }
@ -1254,12 +1260,12 @@ func (c *grpcStorageClient) ListNotifications(ctx context.Context, bucket string
if s.userProject != "" { if s.userProject != "" {
ctx = setUserProjectMetadata(ctx, s.userProject) ctx = setUserProjectMetadata(ctx, s.userProject)
} }
req := &storagepb.ListNotificationsRequest{ req := &storagepb.ListNotificationConfigsRequest{
Parent: bucketResourceName(globalProjectAlias, bucket), Parent: bucketResourceName(globalProjectAlias, bucket),
} }
var notifications []*storagepb.Notification var notifications []*storagepb.NotificationConfig
err = run(ctx, func() error { err = run(ctx, func() error {
gitr := c.raw.ListNotifications(ctx, req, s.gax...) gitr := c.raw.ListNotificationConfigs(ctx, req, s.gax...)
for { for {
// PageSize is not set and fallbacks to the API default pageSize of 100. // PageSize is not set and fallbacks to the API default pageSize of 100.
items, nextPageToken, err := gitr.InternalFetch(int(req.GetPageSize()), req.GetPageToken()) items, nextPageToken, err := gitr.InternalFetch(int(req.GetPageSize()), req.GetPageToken())
@ -1286,14 +1292,14 @@ func (c *grpcStorageClient) CreateNotification(ctx context.Context, bucket strin
defer func() { trace.EndSpan(ctx, err) }() defer func() { trace.EndSpan(ctx, err) }()
s := callSettings(c.settings, opts...) s := callSettings(c.settings, opts...)
req := &storagepb.CreateNotificationRequest{ req := &storagepb.CreateNotificationConfigRequest{
Parent: bucketResourceName(globalProjectAlias, bucket), Parent: bucketResourceName(globalProjectAlias, bucket),
Notification: toProtoNotification(n), NotificationConfig: toProtoNotification(n),
} }
var pbn *storagepb.Notification var pbn *storagepb.NotificationConfig
err = run(ctx, func() error { err = run(ctx, func() error {
var err error var err error
pbn, err = c.raw.CreateNotification(ctx, req, s.gax...) pbn, err = c.raw.CreateNotificationConfig(ctx, req, s.gax...)
return err return err
}, s.retry, s.idempotent, setRetryHeaderGRPC(ctx)) }, s.retry, s.idempotent, setRetryHeaderGRPC(ctx))
if err != nil { if err != nil {
@ -1307,9 +1313,9 @@ func (c *grpcStorageClient) DeleteNotification(ctx context.Context, bucket strin
defer func() { trace.EndSpan(ctx, err) }() defer func() { trace.EndSpan(ctx, err) }()
s := callSettings(c.settings, opts...) s := callSettings(c.settings, opts...)
req := &storagepb.DeleteNotificationRequest{Name: id} req := &storagepb.DeleteNotificationConfigRequest{Name: id}
return run(ctx, func() error { return run(ctx, func() error {
return c.raw.DeleteNotification(ctx, req, s.gax...) return c.raw.DeleteNotificationConfig(ctx, req, s.gax...)
}, s.retry, s.idempotent, setRetryHeaderGRPC(ctx)) }, s.retry, s.idempotent, setRetryHeaderGRPC(ctx))
} }

View file

@ -29,6 +29,7 @@ import (
"strings" "strings"
"time" "time"
"cloud.google.com/go/iam/apiv1/iampb"
"cloud.google.com/go/internal/optional" "cloud.google.com/go/internal/optional"
"cloud.google.com/go/internal/trace" "cloud.google.com/go/internal/trace"
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
@ -39,7 +40,6 @@ import (
raw "google.golang.org/api/storage/v1" raw "google.golang.org/api/storage/v1"
"google.golang.org/api/transport" "google.golang.org/api/transport"
htransport "google.golang.org/api/transport/http" htransport "google.golang.org/api/transport/http"
iampb "google.golang.org/genproto/googleapis/iam/v1"
) )
// httpStorageClient is the HTTP-JSON API implementation of the transport-agnostic // httpStorageClient is the HTTP-JSON API implementation of the transport-agnostic
@ -53,6 +53,7 @@ type httpStorageClient struct {
raw *raw.Service raw *raw.Service
scheme string scheme string
settings *settings settings *settings
config *storageConfig
} }
// newHTTPStorageClient initializes a new storageClient that uses the HTTP-JSON // newHTTPStorageClient initializes a new storageClient that uses the HTTP-JSON
@ -62,6 +63,7 @@ type httpStorageClient struct {
func newHTTPStorageClient(ctx context.Context, opts ...storageOption) (storageClient, error) { func newHTTPStorageClient(ctx context.Context, opts ...storageOption) (storageClient, error) {
s := initSettings(opts...) s := initSettings(opts...)
o := s.clientOption o := s.clientOption
config := newStorageConfig(o...)
var creds *google.Credentials var creds *google.Credentials
// In general, it is recommended to use raw.NewService instead of htransport.NewClient // In general, it is recommended to use raw.NewService instead of htransport.NewClient
@ -134,6 +136,7 @@ func newHTTPStorageClient(ctx context.Context, opts ...storageOption) (storageCl
raw: rawService, raw: rawService,
scheme: u.Scheme, scheme: u.Scheme,
settings: s, settings: s,
config: &config,
}, nil }, nil
} }
@ -779,6 +782,13 @@ func (c *httpStorageClient) NewRangeReader(ctx context.Context, params *newRange
s := callSettings(c.settings, opts...) s := callSettings(c.settings, opts...)
if c.config.useJSONforReads {
return c.newRangeReaderJSON(ctx, params, s)
}
return c.newRangeReaderXML(ctx, params, s)
}
func (c *httpStorageClient) newRangeReaderXML(ctx context.Context, params *newRangeReaderParams, s *settings) (r *Reader, err error) {
u := &url.URL{ u := &url.URL{
Scheme: c.scheme, Scheme: c.scheme,
Host: c.readHost, Host: c.readHost,
@ -793,186 +803,51 @@ func (c *httpStorageClient) NewRangeReader(ctx context.Context, params *newRange
return nil, err return nil, err
} }
req = req.WithContext(ctx) req = req.WithContext(ctx)
if s.userProject != "" { if s.userProject != "" {
req.Header.Set("X-Goog-User-Project", s.userProject) req.Header.Set("X-Goog-User-Project", s.userProject)
} }
if params.readCompressed {
req.Header.Set("Accept-Encoding", "gzip") if err := setRangeReaderHeaders(req.Header, params); err != nil {
}
if err := setEncryptionHeaders(req.Header, params.encryptionKey, false); err != nil {
return nil, err return nil, err
} }
// Define a function that initiates a Read with offset and length, assuming we reopen := readerReopen(ctx, req.Header, params, s,
// have already read seen bytes. func() (*http.Response, error) { return c.hc.Do(req) },
reopen := func(seen int64) (*http.Response, error) { func() error { return setConditionsHeaders(req.Header, params.conds) },
// If the context has already expired, return immediately without making a func() { req.URL.RawQuery = fmt.Sprintf("generation=%d", params.gen) })
// call.
if err := ctx.Err(); err != nil {
return nil, err
}
start := params.offset + seen
if params.length < 0 && start < 0 {
req.Header.Set("Range", fmt.Sprintf("bytes=%d", start))
} else if params.length < 0 && start > 0 {
req.Header.Set("Range", fmt.Sprintf("bytes=%d-", start))
} else if params.length > 0 {
// The end character isn't affected by how many bytes we've seen.
req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", start, params.offset+params.length-1))
}
// We wait to assign conditions here because the generation number can change in between reopen() runs.
if err := setConditionsHeaders(req.Header, params.conds); err != nil {
return nil, err
}
// If an object generation is specified, include generation as query string parameters.
if params.gen >= 0 {
req.URL.RawQuery = fmt.Sprintf("generation=%d", params.gen)
}
var res *http.Response
err = run(ctx, func() error {
res, err = c.hc.Do(req)
if err != nil {
return err
}
if res.StatusCode == http.StatusNotFound {
res.Body.Close()
return ErrObjectNotExist
}
if res.StatusCode < 200 || res.StatusCode > 299 {
body, _ := ioutil.ReadAll(res.Body)
res.Body.Close()
return &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
Body: string(body),
}
}
partialContentNotSatisfied :=
!decompressiveTranscoding(res) &&
start > 0 && params.length != 0 &&
res.StatusCode != http.StatusPartialContent
if partialContentNotSatisfied {
res.Body.Close()
return errors.New("storage: partial request not satisfied")
}
// With "Content-Encoding": "gzip" aka decompressive transcoding, GCS serves
// back the whole file regardless of the range count passed in as per:
// https://cloud.google.com/storage/docs/transcoding#range,
// thus we have to manually move the body forward by seen bytes.
if decompressiveTranscoding(res) && seen > 0 {
_, _ = io.CopyN(ioutil.Discard, res.Body, seen)
}
// If a generation hasn't been specified, and this is the first response we get, let's record the
// generation. In future requests we'll use this generation as a precondition to avoid data races.
if params.gen < 0 && res.Header.Get("X-Goog-Generation") != "" {
gen64, err := strconv.ParseInt(res.Header.Get("X-Goog-Generation"), 10, 64)
if err != nil {
return err
}
params.gen = gen64
}
return nil
}, s.retry, s.idempotent, setRetryHeaderHTTP(nil))
if err != nil {
return nil, err
}
return res, nil
}
res, err := reopen(0) res, err := reopen(0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var ( return parseReadResponse(res, params, reopen)
size int64 // total size of object, even if a range was requested. }
checkCRC bool
crc uint32
startOffset int64 // non-zero if range request.
)
if res.StatusCode == http.StatusPartialContent {
cr := strings.TrimSpace(res.Header.Get("Content-Range"))
if !strings.HasPrefix(cr, "bytes ") || !strings.Contains(cr, "/") {
return nil, fmt.Errorf("storage: invalid Content-Range %q", cr)
}
// Content range is formatted <first byte>-<last byte>/<total size>. We take
// the total size.
size, err = strconv.ParseInt(cr[strings.LastIndex(cr, "/")+1:], 10, 64)
if err != nil {
return nil, fmt.Errorf("storage: invalid Content-Range %q", cr)
}
dashIndex := strings.Index(cr, "-") func (c *httpStorageClient) newRangeReaderJSON(ctx context.Context, params *newRangeReaderParams, s *settings) (r *Reader, err error) {
if dashIndex >= 0 { call := c.raw.Objects.Get(params.bucket, params.object)
startOffset, err = strconv.ParseInt(cr[len("bytes="):dashIndex], 10, 64)
if err != nil { setClientHeader(call.Header())
return nil, fmt.Errorf("storage: invalid Content-Range %q: %w", cr, err) call.Context(ctx)
} call.Projection("full")
}
} else { if s.userProject != "" {
size = res.ContentLength call.UserProject(s.userProject)
// Check the CRC iff all of the following hold:
// - We asked for content (length != 0).
// - We got all the content (status != PartialContent).
// - The server sent a CRC header.
// - The Go http stack did not uncompress the file.
// - We were not served compressed data that was uncompressed on download.
// The problem with the last two cases is that the CRC will not match -- GCS
// computes it on the compressed contents, but we compute it on the
// uncompressed contents.
if params.length != 0 && !res.Uncompressed && !uncompressedByServer(res) {
crc, checkCRC = parseCRC32c(res)
}
} }
remain := res.ContentLength if err := setRangeReaderHeaders(call.Header(), params); err != nil {
body := res.Body return nil, err
if params.length == 0 {
remain = 0
body.Close()
body = emptyBody
}
var metaGen int64
if res.Header.Get("X-Goog-Metageneration") != "" {
metaGen, err = strconv.ParseInt(res.Header.Get("X-Goog-Metageneration"), 10, 64)
if err != nil {
return nil, err
}
} }
var lm time.Time reopen := readerReopen(ctx, call.Header(), params, s, func() (*http.Response, error) { return call.Download() },
if res.Header.Get("Last-Modified") != "" { func() error { return applyConds("NewReader", params.gen, params.conds, call) },
lm, err = http.ParseTime(res.Header.Get("Last-Modified")) func() { call.Generation(params.gen) })
if err != nil {
return nil, err
}
}
attrs := ReaderObjectAttrs{ res, err := reopen(0)
Size: size, if err != nil {
ContentType: res.Header.Get("Content-Type"), return nil, err
ContentEncoding: res.Header.Get("Content-Encoding"),
CacheControl: res.Header.Get("Cache-Control"),
LastModified: lm,
StartOffset: startOffset,
Generation: params.gen,
Metageneration: metaGen,
} }
return &Reader{ return parseReadResponse(res, params, reopen)
Attrs: attrs,
size: size,
remain: remain,
wantCRC: crc,
checkCRC: checkCRC,
reader: &httpReader{
reopen: reopen,
body: body,
},
}, nil
} }
func (c *httpStorageClient) OpenWriter(params *openWriterParams, opts ...storageOption) (*io.PipeWriter, error) { func (c *httpStorageClient) OpenWriter(params *openWriterParams, opts ...storageOption) (*io.PipeWriter, error) {
@ -1349,3 +1224,195 @@ func (r *httpReader) Read(p []byte) (int, error) {
func (r *httpReader) Close() error { func (r *httpReader) Close() error {
return r.body.Close() return r.body.Close()
} }
func setRangeReaderHeaders(h http.Header, params *newRangeReaderParams) error {
if params.readCompressed {
h.Set("Accept-Encoding", "gzip")
}
if err := setEncryptionHeaders(h, params.encryptionKey, false); err != nil {
return err
}
return nil
}
// readerReopen initiates a Read with offset and length, assuming we
// have already read seen bytes.
func readerReopen(ctx context.Context, header http.Header, params *newRangeReaderParams, s *settings,
doDownload func() (*http.Response, error), applyConditions func() error, setGeneration func()) func(int64) (*http.Response, error) {
return func(seen int64) (*http.Response, error) {
// If the context has already expired, return immediately without making a
// call.
if err := ctx.Err(); err != nil {
return nil, err
}
start := params.offset + seen
if params.length < 0 && start < 0 {
header.Set("Range", fmt.Sprintf("bytes=%d", start))
} else if params.length < 0 && start > 0 {
header.Set("Range", fmt.Sprintf("bytes=%d-", start))
} else if params.length > 0 {
// The end character isn't affected by how many bytes we've seen.
header.Set("Range", fmt.Sprintf("bytes=%d-%d", start, params.offset+params.length-1))
}
// We wait to assign conditions here because the generation number can change in between reopen() runs.
if err := applyConditions(); err != nil {
return nil, err
}
// If an object generation is specified, include generation as query string parameters.
if params.gen >= 0 {
setGeneration()
}
var err error
var res *http.Response
err = run(ctx, func() error {
res, err = doDownload()
if err != nil {
var e *googleapi.Error
if errors.As(err, &e) {
if e.Code == http.StatusNotFound {
return ErrObjectNotExist
}
}
return err
}
if res.StatusCode == http.StatusNotFound {
// this check is necessary only for XML
res.Body.Close()
return ErrObjectNotExist
}
if res.StatusCode < 200 || res.StatusCode > 299 {
body, _ := ioutil.ReadAll(res.Body)
res.Body.Close()
return &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
Body: string(body),
}
}
partialContentNotSatisfied :=
!decompressiveTranscoding(res) &&
start > 0 && params.length != 0 &&
res.StatusCode != http.StatusPartialContent
if partialContentNotSatisfied {
res.Body.Close()
return errors.New("storage: partial request not satisfied")
}
// With "Content-Encoding": "gzip" aka decompressive transcoding, GCS serves
// back the whole file regardless of the range count passed in as per:
// https://cloud.google.com/storage/docs/transcoding#range,
// thus we have to manually move the body forward by seen bytes.
if decompressiveTranscoding(res) && seen > 0 {
_, _ = io.CopyN(ioutil.Discard, res.Body, seen)
}
// If a generation hasn't been specified, and this is the first response we get, let's record the
// generation. In future requests we'll use this generation as a precondition to avoid data races.
if params.gen < 0 && res.Header.Get("X-Goog-Generation") != "" {
gen64, err := strconv.ParseInt(res.Header.Get("X-Goog-Generation"), 10, 64)
if err != nil {
return err
}
params.gen = gen64
}
return nil
}, s.retry, s.idempotent, setRetryHeaderHTTP(nil))
if err != nil {
return nil, err
}
return res, nil
}
}
func parseReadResponse(res *http.Response, params *newRangeReaderParams, reopen func(int64) (*http.Response, error)) (*Reader, error) {
var err error
var (
size int64 // total size of object, even if a range was requested.
checkCRC bool
crc uint32
startOffset int64 // non-zero if range request.
)
if res.StatusCode == http.StatusPartialContent {
cr := strings.TrimSpace(res.Header.Get("Content-Range"))
if !strings.HasPrefix(cr, "bytes ") || !strings.Contains(cr, "/") {
return nil, fmt.Errorf("storage: invalid Content-Range %q", cr)
}
// Content range is formatted <first byte>-<last byte>/<total size>. We take
// the total size.
size, err = strconv.ParseInt(cr[strings.LastIndex(cr, "/")+1:], 10, 64)
if err != nil {
return nil, fmt.Errorf("storage: invalid Content-Range %q", cr)
}
dashIndex := strings.Index(cr, "-")
if dashIndex >= 0 {
startOffset, err = strconv.ParseInt(cr[len("bytes="):dashIndex], 10, 64)
if err != nil {
return nil, fmt.Errorf("storage: invalid Content-Range %q: %w", cr, err)
}
}
} else {
size = res.ContentLength
// Check the CRC iff all of the following hold:
// - We asked for content (length != 0).
// - We got all the content (status != PartialContent).
// - The server sent a CRC header.
// - The Go http stack did not uncompress the file.
// - We were not served compressed data that was uncompressed on download.
// The problem with the last two cases is that the CRC will not match -- GCS
// computes it on the compressed contents, but we compute it on the
// uncompressed contents.
if params.length != 0 && !res.Uncompressed && !uncompressedByServer(res) {
crc, checkCRC = parseCRC32c(res)
}
}
remain := res.ContentLength
body := res.Body
if params.length == 0 {
remain = 0
body.Close()
body = emptyBody
}
var metaGen int64
if res.Header.Get("X-Goog-Metageneration") != "" {
metaGen, err = strconv.ParseInt(res.Header.Get("X-Goog-Metageneration"), 10, 64)
if err != nil {
return nil, err
}
}
var lm time.Time
if res.Header.Get("Last-Modified") != "" {
lm, err = http.ParseTime(res.Header.Get("Last-Modified"))
if err != nil {
return nil, err
}
}
attrs := ReaderObjectAttrs{
Size: size,
ContentType: res.Header.Get("Content-Type"),
ContentEncoding: res.Header.Get("Content-Encoding"),
CacheControl: res.Header.Get("Cache-Control"),
LastModified: lm,
StartOffset: startOffset,
Generation: params.gen,
Metageneration: metaGen,
}
return &Reader{
Attrs: attrs,
size: size,
remain: remain,
wantCRC: crc,
checkCRC: checkCRC,
reader: &httpReader{
reopen: reopen,
body: body,
},
}, nil
}

View file

@ -18,9 +18,9 @@ import (
"context" "context"
"cloud.google.com/go/iam" "cloud.google.com/go/iam"
"cloud.google.com/go/iam/apiv1/iampb"
"cloud.google.com/go/internal/trace" "cloud.google.com/go/internal/trace"
raw "google.golang.org/api/storage/v1" raw "google.golang.org/api/storage/v1"
iampb "google.golang.org/genproto/googleapis/iam/v1"
"google.golang.org/genproto/googleapis/type/expr" "google.golang.org/genproto/googleapis/type/expr"
) )

View file

@ -30,9 +30,9 @@
"CreateHmacKey" "CreateHmacKey"
] ]
}, },
"CreateNotification": { "CreateNotificationConfig": {
"methods": [ "methods": [
"CreateNotification" "CreateNotificationConfig"
] ]
}, },
"DeleteBucket": { "DeleteBucket": {
@ -45,9 +45,9 @@
"DeleteHmacKey" "DeleteHmacKey"
] ]
}, },
"DeleteNotification": { "DeleteNotificationConfig": {
"methods": [ "methods": [
"DeleteNotification" "DeleteNotificationConfig"
] ]
}, },
"DeleteObject": { "DeleteObject": {
@ -70,9 +70,9 @@
"GetIamPolicy" "GetIamPolicy"
] ]
}, },
"GetNotification": { "GetNotificationConfig": {
"methods": [ "methods": [
"GetNotification" "GetNotificationConfig"
] ]
}, },
"GetObject": { "GetObject": {
@ -95,9 +95,9 @@
"ListHmacKeys" "ListHmacKeys"
] ]
}, },
"ListNotifications": { "ListNotificationConfigs": {
"methods": [ "methods": [
"ListNotifications" "ListNotificationConfigs"
] ]
}, },
"ListObjects": { "ListObjects": {

View file

@ -24,13 +24,13 @@ import (
"regexp" "regexp"
"strings" "strings"
"cloud.google.com/go/iam/apiv1/iampb"
storagepb "cloud.google.com/go/storage/internal/apiv2/stubs" storagepb "cloud.google.com/go/storage/internal/apiv2/stubs"
gax "github.com/googleapis/gax-go/v2" gax "github.com/googleapis/gax-go/v2"
"google.golang.org/api/iterator" "google.golang.org/api/iterator"
"google.golang.org/api/option" "google.golang.org/api/option"
"google.golang.org/api/option/internaloption" "google.golang.org/api/option/internaloption"
gtransport "google.golang.org/api/transport/grpc" gtransport "google.golang.org/api/transport/grpc"
iampb "google.golang.org/genproto/googleapis/iam/v1"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
@ -49,10 +49,10 @@ type CallOptions struct {
SetIamPolicy []gax.CallOption SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption TestIamPermissions []gax.CallOption
UpdateBucket []gax.CallOption UpdateBucket []gax.CallOption
DeleteNotification []gax.CallOption DeleteNotificationConfig []gax.CallOption
GetNotification []gax.CallOption GetNotificationConfig []gax.CallOption
CreateNotification []gax.CallOption CreateNotificationConfig []gax.CallOption
ListNotifications []gax.CallOption ListNotificationConfigs []gax.CallOption
ComposeObject []gax.CallOption ComposeObject []gax.CallOption
DeleteObject []gax.CallOption DeleteObject []gax.CallOption
CancelResumableWrite []gax.CallOption CancelResumableWrite []gax.CallOption
@ -95,10 +95,10 @@ func defaultCallOptions() *CallOptions {
SetIamPolicy: []gax.CallOption{}, SetIamPolicy: []gax.CallOption{},
TestIamPermissions: []gax.CallOption{}, TestIamPermissions: []gax.CallOption{},
UpdateBucket: []gax.CallOption{}, UpdateBucket: []gax.CallOption{},
DeleteNotification: []gax.CallOption{}, DeleteNotificationConfig: []gax.CallOption{},
GetNotification: []gax.CallOption{}, GetNotificationConfig: []gax.CallOption{},
CreateNotification: []gax.CallOption{}, CreateNotificationConfig: []gax.CallOption{},
ListNotifications: []gax.CallOption{}, ListNotificationConfigs: []gax.CallOption{},
ComposeObject: []gax.CallOption{}, ComposeObject: []gax.CallOption{},
DeleteObject: []gax.CallOption{}, DeleteObject: []gax.CallOption{},
CancelResumableWrite: []gax.CallOption{}, CancelResumableWrite: []gax.CallOption{},
@ -133,10 +133,10 @@ type internalClient interface {
SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
UpdateBucket(context.Context, *storagepb.UpdateBucketRequest, ...gax.CallOption) (*storagepb.Bucket, error) UpdateBucket(context.Context, *storagepb.UpdateBucketRequest, ...gax.CallOption) (*storagepb.Bucket, error)
DeleteNotification(context.Context, *storagepb.DeleteNotificationRequest, ...gax.CallOption) error DeleteNotificationConfig(context.Context, *storagepb.DeleteNotificationConfigRequest, ...gax.CallOption) error
GetNotification(context.Context, *storagepb.GetNotificationRequest, ...gax.CallOption) (*storagepb.Notification, error) GetNotificationConfig(context.Context, *storagepb.GetNotificationConfigRequest, ...gax.CallOption) (*storagepb.NotificationConfig, error)
CreateNotification(context.Context, *storagepb.CreateNotificationRequest, ...gax.CallOption) (*storagepb.Notification, error) CreateNotificationConfig(context.Context, *storagepb.CreateNotificationConfigRequest, ...gax.CallOption) (*storagepb.NotificationConfig, error)
ListNotifications(context.Context, *storagepb.ListNotificationsRequest, ...gax.CallOption) *NotificationIterator ListNotificationConfigs(context.Context, *storagepb.ListNotificationConfigsRequest, ...gax.CallOption) *NotificationConfigIterator
ComposeObject(context.Context, *storagepb.ComposeObjectRequest, ...gax.CallOption) (*storagepb.Object, error) ComposeObject(context.Context, *storagepb.ComposeObjectRequest, ...gax.CallOption) (*storagepb.Object, error)
DeleteObject(context.Context, *storagepb.DeleteObjectRequest, ...gax.CallOption) error DeleteObject(context.Context, *storagepb.DeleteObjectRequest, ...gax.CallOption) error
CancelResumableWrite(context.Context, *storagepb.CancelResumableWriteRequest, ...gax.CallOption) (*storagepb.CancelResumableWriteResponse, error) CancelResumableWrite(context.Context, *storagepb.CancelResumableWriteRequest, ...gax.CallOption) (*storagepb.CancelResumableWriteResponse, error)
@ -267,27 +267,27 @@ func (c *Client) UpdateBucket(ctx context.Context, req *storagepb.UpdateBucketRe
return c.internalClient.UpdateBucket(ctx, req, opts...) return c.internalClient.UpdateBucket(ctx, req, opts...)
} }
// DeleteNotification permanently deletes a notification subscription. // DeleteNotificationConfig permanently deletes a NotificationConfig.
func (c *Client) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { func (c *Client) DeleteNotificationConfig(ctx context.Context, req *storagepb.DeleteNotificationConfigRequest, opts ...gax.CallOption) error {
return c.internalClient.DeleteNotification(ctx, req, opts...) return c.internalClient.DeleteNotificationConfig(ctx, req, opts...)
} }
// GetNotification view a notification config. // GetNotificationConfig view a NotificationConfig.
func (c *Client) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { func (c *Client) GetNotificationConfig(ctx context.Context, req *storagepb.GetNotificationConfigRequest, opts ...gax.CallOption) (*storagepb.NotificationConfig, error) {
return c.internalClient.GetNotification(ctx, req, opts...) return c.internalClient.GetNotificationConfig(ctx, req, opts...)
} }
// CreateNotification creates a notification subscription for a given bucket. // CreateNotificationConfig creates a NotificationConfig for a given bucket.
// These notifications, when triggered, publish messages to the specified // These NotificationConfigs, when triggered, publish messages to the
// Pub/Sub topics. // specified Pub/Sub topics. See
// See https://cloud.google.com/storage/docs/pubsub-notifications (at https://cloud.google.com/storage/docs/pubsub-notifications). // https://cloud.google.com/storage/docs/pubsub-notifications (at https://cloud.google.com/storage/docs/pubsub-notifications).
func (c *Client) CreateNotification(ctx context.Context, req *storagepb.CreateNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { func (c *Client) CreateNotificationConfig(ctx context.Context, req *storagepb.CreateNotificationConfigRequest, opts ...gax.CallOption) (*storagepb.NotificationConfig, error) {
return c.internalClient.CreateNotification(ctx, req, opts...) return c.internalClient.CreateNotificationConfig(ctx, req, opts...)
} }
// ListNotifications retrieves a list of notification subscriptions for a given bucket. // ListNotificationConfigs retrieves a list of NotificationConfigs for a given bucket.
func (c *Client) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) *NotificationIterator { func (c *Client) ListNotificationConfigs(ctx context.Context, req *storagepb.ListNotificationConfigsRequest, opts ...gax.CallOption) *NotificationConfigIterator {
return c.internalClient.ListNotifications(ctx, req, opts...) return c.internalClient.ListNotificationConfigs(ctx, req, opts...)
} }
// ComposeObject concatenates a list of existing objects into a new object in the same // ComposeObject concatenates a list of existing objects into a new object in the same
@ -365,8 +365,9 @@ func (c *Client) UpdateObject(ctx context.Context, req *storagepb.UpdateObjectRe
// returned persisted_size; in this case, the service will skip data at // returned persisted_size; in this case, the service will skip data at
// offsets that were already persisted (without checking that it matches // offsets that were already persisted (without checking that it matches
// the previously written data), and write only the data starting from the // the previously written data), and write only the data starting from the
// persisted offset. This behavior can make client-side handling simpler // persisted offset. Even though the data isnt written, it may still
// in some cases. // incur a performance cost over resuming at the correct write offset.
// This behavior can make client-side handling simpler in some cases.
// //
// The service will not view the object as complete until the client has // The service will not view the object as complete until the client has
// sent a WriteObjectRequest with finish_write set to true. Sending any // sent a WriteObjectRequest with finish_write set to true. Sending any
@ -603,6 +604,9 @@ func (c *gRPCClient) CreateBucket(ctx context.Context, req *storagepb.CreateBuck
if reg := regexp.MustCompile("(?P<project>.*)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { if reg := regexp.MustCompile("(?P<project>.*)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 {
routingHeadersMap["project"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1]) routingHeadersMap["project"] = url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])
} }
if reg := regexp.MustCompile("(?P<project>.*)"); reg.MatchString(req.GetBucket().GetProject()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetBucket().GetProject())[1])) > 0 {
routingHeadersMap["project"] = url.QueryEscape(reg.FindStringSubmatch(req.GetBucket().GetProject())[1])
}
for headerName, headerValue := range routingHeadersMap { for headerName, headerValue := range routingHeadersMap {
routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue) routingHeaders = fmt.Sprintf("%s%s=%s&", routingHeaders, headerName, headerValue)
} }
@ -816,7 +820,7 @@ func (c *gRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBuck
return resp, nil return resp, nil
} }
func (c *gRPCClient) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { func (c *gRPCClient) DeleteNotificationConfig(ctx context.Context, req *storagepb.DeleteNotificationConfigRequest, opts ...gax.CallOption) error {
routingHeaders := "" routingHeaders := ""
routingHeadersMap := make(map[string]string) routingHeadersMap := make(map[string]string)
if reg := regexp.MustCompile("(?P<bucket>projects/[^/]+/buckets/[^/]+)(?:/.*)?"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { if reg := regexp.MustCompile("(?P<bucket>projects/[^/]+/buckets/[^/]+)(?:/.*)?"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 {
@ -829,16 +833,16 @@ func (c *gRPCClient) DeleteNotification(ctx context.Context, req *storagepb.Dele
md := metadata.Pairs("x-goog-request-params", routingHeaders) md := metadata.Pairs("x-goog-request-params", routingHeaders)
ctx = insertMetadata(ctx, c.xGoogMetadata, md) ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).DeleteNotification[0:len((*c.CallOptions).DeleteNotification):len((*c.CallOptions).DeleteNotification)], opts...) opts = append((*c.CallOptions).DeleteNotificationConfig[0:len((*c.CallOptions).DeleteNotificationConfig):len((*c.CallOptions).DeleteNotificationConfig)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error var err error
_, err = c.client.DeleteNotification(ctx, req, settings.GRPC...) _, err = c.client.DeleteNotificationConfig(ctx, req, settings.GRPC...)
return err return err
}, opts...) }, opts...)
return err return err
} }
func (c *gRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { func (c *gRPCClient) GetNotificationConfig(ctx context.Context, req *storagepb.GetNotificationConfigRequest, opts ...gax.CallOption) (*storagepb.NotificationConfig, error) {
routingHeaders := "" routingHeaders := ""
routingHeadersMap := make(map[string]string) routingHeadersMap := make(map[string]string)
if reg := regexp.MustCompile("(?P<bucket>projects/[^/]+/buckets/[^/]+)(?:/.*)?"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 { if reg := regexp.MustCompile("(?P<bucket>projects/[^/]+/buckets/[^/]+)(?:/.*)?"); reg.MatchString(req.GetName()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetName())[1])) > 0 {
@ -851,11 +855,11 @@ func (c *gRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNoti
md := metadata.Pairs("x-goog-request-params", routingHeaders) md := metadata.Pairs("x-goog-request-params", routingHeaders)
ctx = insertMetadata(ctx, c.xGoogMetadata, md) ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).GetNotification[0:len((*c.CallOptions).GetNotification):len((*c.CallOptions).GetNotification)], opts...) opts = append((*c.CallOptions).GetNotificationConfig[0:len((*c.CallOptions).GetNotificationConfig):len((*c.CallOptions).GetNotificationConfig)], opts...)
var resp *storagepb.Notification var resp *storagepb.NotificationConfig
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error var err error
resp, err = c.client.GetNotification(ctx, req, settings.GRPC...) resp, err = c.client.GetNotificationConfig(ctx, req, settings.GRPC...)
return err return err
}, opts...) }, opts...)
if err != nil { if err != nil {
@ -864,7 +868,7 @@ func (c *gRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNoti
return resp, nil return resp, nil
} }
func (c *gRPCClient) CreateNotification(ctx context.Context, req *storagepb.CreateNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { func (c *gRPCClient) CreateNotificationConfig(ctx context.Context, req *storagepb.CreateNotificationConfigRequest, opts ...gax.CallOption) (*storagepb.NotificationConfig, error) {
routingHeaders := "" routingHeaders := ""
routingHeadersMap := make(map[string]string) routingHeadersMap := make(map[string]string)
if reg := regexp.MustCompile("(?P<bucket>.*)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { if reg := regexp.MustCompile("(?P<bucket>.*)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 {
@ -877,11 +881,11 @@ func (c *gRPCClient) CreateNotification(ctx context.Context, req *storagepb.Crea
md := metadata.Pairs("x-goog-request-params", routingHeaders) md := metadata.Pairs("x-goog-request-params", routingHeaders)
ctx = insertMetadata(ctx, c.xGoogMetadata, md) ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).CreateNotification[0:len((*c.CallOptions).CreateNotification):len((*c.CallOptions).CreateNotification)], opts...) opts = append((*c.CallOptions).CreateNotificationConfig[0:len((*c.CallOptions).CreateNotificationConfig):len((*c.CallOptions).CreateNotificationConfig)], opts...)
var resp *storagepb.Notification var resp *storagepb.NotificationConfig
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error var err error
resp, err = c.client.CreateNotification(ctx, req, settings.GRPC...) resp, err = c.client.CreateNotificationConfig(ctx, req, settings.GRPC...)
return err return err
}, opts...) }, opts...)
if err != nil { if err != nil {
@ -890,7 +894,7 @@ func (c *gRPCClient) CreateNotification(ctx context.Context, req *storagepb.Crea
return resp, nil return resp, nil
} }
func (c *gRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) *NotificationIterator { func (c *gRPCClient) ListNotificationConfigs(ctx context.Context, req *storagepb.ListNotificationConfigsRequest, opts ...gax.CallOption) *NotificationConfigIterator {
routingHeaders := "" routingHeaders := ""
routingHeadersMap := make(map[string]string) routingHeadersMap := make(map[string]string)
if reg := regexp.MustCompile("(?P<bucket>.*)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 { if reg := regexp.MustCompile("(?P<bucket>.*)"); reg.MatchString(req.GetParent()) && len(url.QueryEscape(reg.FindStringSubmatch(req.GetParent())[1])) > 0 {
@ -903,11 +907,11 @@ func (c *gRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListN
md := metadata.Pairs("x-goog-request-params", routingHeaders) md := metadata.Pairs("x-goog-request-params", routingHeaders)
ctx = insertMetadata(ctx, c.xGoogMetadata, md) ctx = insertMetadata(ctx, c.xGoogMetadata, md)
opts = append((*c.CallOptions).ListNotifications[0:len((*c.CallOptions).ListNotifications):len((*c.CallOptions).ListNotifications)], opts...) opts = append((*c.CallOptions).ListNotificationConfigs[0:len((*c.CallOptions).ListNotificationConfigs):len((*c.CallOptions).ListNotificationConfigs)], opts...)
it := &NotificationIterator{} it := &NotificationConfigIterator{}
req = proto.Clone(req).(*storagepb.ListNotificationsRequest) req = proto.Clone(req).(*storagepb.ListNotificationConfigsRequest)
it.InternalFetch = func(pageSize int, pageToken string) ([]*storagepb.Notification, string, error) { it.InternalFetch = func(pageSize int, pageToken string) ([]*storagepb.NotificationConfig, string, error) {
resp := &storagepb.ListNotificationsResponse{} resp := &storagepb.ListNotificationConfigsResponse{}
if pageToken != "" { if pageToken != "" {
req.PageToken = pageToken req.PageToken = pageToken
} }
@ -918,7 +922,7 @@ func (c *gRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListN
} }
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error var err error
resp, err = c.client.ListNotifications(ctx, req, settings.GRPC...) resp, err = c.client.ListNotificationConfigs(ctx, req, settings.GRPC...)
return err return err
}, opts...) }, opts...)
if err != nil { if err != nil {
@ -926,7 +930,7 @@ func (c *gRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListN
} }
it.Response = resp it.Response = resp
return resp.GetNotifications(), resp.GetNextPageToken(), nil return resp.GetNotificationConfigs(), resp.GetNextPageToken(), nil
} }
fetch := func(pageSize int, pageToken string) (string, error) { fetch := func(pageSize int, pageToken string) (string, error) {
items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
@ -1520,9 +1524,9 @@ func (it *HmacKeyMetadataIterator) takeBuf() interface{} {
return b return b
} }
// NotificationIterator manages a stream of *storagepb.Notification. // NotificationConfigIterator manages a stream of *storagepb.NotificationConfig.
type NotificationIterator struct { type NotificationConfigIterator struct {
items []*storagepb.Notification items []*storagepb.NotificationConfig
pageInfo *iterator.PageInfo pageInfo *iterator.PageInfo
nextFunc func() error nextFunc func() error
@ -1537,18 +1541,18 @@ type NotificationIterator struct {
// InternalFetch returns results from a single call to the underlying RPC. // InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize. // The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil. // If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*storagepb.Notification, nextPageToken string, err error) InternalFetch func(pageSize int, pageToken string) (results []*storagepb.NotificationConfig, nextPageToken string, err error)
} }
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. // PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func (it *NotificationIterator) PageInfo() *iterator.PageInfo { func (it *NotificationConfigIterator) PageInfo() *iterator.PageInfo {
return it.pageInfo return it.pageInfo
} }
// Next returns the next result. Its second return value is iterator.Done if there are no more // Next returns the next result. Its second return value is iterator.Done if there are no more
// results. Once Next returns Done, all subsequent calls will return Done. // results. Once Next returns Done, all subsequent calls will return Done.
func (it *NotificationIterator) Next() (*storagepb.Notification, error) { func (it *NotificationConfigIterator) Next() (*storagepb.NotificationConfig, error) {
var item *storagepb.Notification var item *storagepb.NotificationConfig
if err := it.nextFunc(); err != nil { if err := it.nextFunc(); err != nil {
return item, err return item, err
} }
@ -1557,11 +1561,11 @@ func (it *NotificationIterator) Next() (*storagepb.Notification, error) {
return item, nil return item, nil
} }
func (it *NotificationIterator) bufLen() int { func (it *NotificationConfigIterator) bufLen() int {
return len(it.items) return len(it.items)
} }
func (it *NotificationIterator) takeBuf() interface{} { func (it *NotificationConfigIterator) takeBuf() interface{} {
b := it.items b := it.items
it.items = nil it.items = nil
return b return b

File diff suppressed because it is too large Load diff

View file

@ -15,4 +15,4 @@
package internal package internal
// Version is the current tagged release of the library. // Version is the current tagged release of the library.
const Version = "1.29.0" const Version = "1.30.0"

View file

@ -92,7 +92,7 @@ func toNotification(rn *raw.Notification) *Notification {
return n return n
} }
func toNotificationFromProto(pbn *storagepb.Notification) *Notification { func toNotificationFromProto(pbn *storagepb.NotificationConfig) *Notification {
n := &Notification{ n := &Notification{
ID: pbn.GetName(), ID: pbn.GetName(),
EventTypes: pbn.GetEventTypes(), EventTypes: pbn.GetEventTypes(),
@ -104,8 +104,8 @@ func toNotificationFromProto(pbn *storagepb.Notification) *Notification {
return n return n
} }
func toProtoNotification(n *Notification) *storagepb.Notification { func toProtoNotification(n *Notification) *storagepb.NotificationConfig {
return &storagepb.Notification{ return &storagepb.NotificationConfig{
Name: n.ID, Name: n.ID,
Topic: fmt.Sprintf("//pubsub.googleapis.com/projects/%s/topics/%s", Topic: fmt.Sprintf("//pubsub.googleapis.com/projects/%s/topics/%s",
n.TopicProjectID, n.TopicID), n.TopicProjectID, n.TopicID),
@ -182,7 +182,7 @@ func notificationsToMap(rns []*raw.Notification) map[string]*Notification {
return m return m
} }
func notificationsToMapFromProto(ns []*storagepb.Notification) map[string]*Notification { func notificationsToMapFromProto(ns []*storagepb.NotificationConfig) map[string]*Notification {
m := map[string]*Notification{} m := map[string]*Notification{}
for _, n := range ns { for _, n := range ns {
m[n.Name] = toNotificationFromProto(n) m[n.Name] = toNotificationFromProto(n)

75
vendor/cloud.google.com/go/storage/option.go generated vendored Normal file
View file

@ -0,0 +1,75 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package storage
import (
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
)
// storageConfig contains the Storage client option configuration that can be
// set through storageClientOptions.
type storageConfig struct {
useJSONforReads bool
readAPIWasSet bool
}
// newStorageConfig generates a new storageConfig with all the given
// storageClientOptions applied.
func newStorageConfig(opts ...option.ClientOption) storageConfig {
var conf storageConfig
for _, opt := range opts {
if storageOpt, ok := opt.(storageClientOption); ok {
storageOpt.ApplyStorageOpt(&conf)
}
}
return conf
}
// A storageClientOption is an option for a Google Storage client.
type storageClientOption interface {
option.ClientOption
ApplyStorageOpt(*storageConfig)
}
// WithJSONReads is an option that may be passed to a Storage Client on creation.
// It sets the client to use the JSON API for object reads. Currently, the
// default API used for reads is XML.
// Setting this option is required to use the GenerationNotMatch condition.
//
// Note that when this option is set, reads will return a zero date for
// [ReaderObjectAttrs].LastModified and may return a different value for
// [ReaderObjectAttrs].CacheControl.
func WithJSONReads() option.ClientOption {
return &withReadAPI{useJSON: true}
}
// WithXMLReads is an option that may be passed to a Storage Client on creation.
// It sets the client to use the JSON API for object reads.
//
// This is the current default.
func WithXMLReads() option.ClientOption {
return &withReadAPI{useJSON: false}
}
type withReadAPI struct {
internaloption.EmbeddableAdapter
useJSON bool
}
func (w *withReadAPI) ApplyStorageOpt(c *storageConfig) {
c.useJSONforReads = w.useJSON
c.readAPIWasSet = true
}

View file

@ -139,15 +139,23 @@ func uncompressedByServer(res *http.Response) bool {
res.Header.Get("Content-Encoding") != "gzip" res.Header.Get("Content-Encoding") != "gzip"
} }
// parseCRC32c parses the crc32c hash from the X-Goog-Hash header.
// It can parse headers in the form [crc32c=xxx md5=xxx] (XML responses) or the
// form [crc32c=xxx,md5=xxx] (JSON responses). The md5 hash is ignored.
func parseCRC32c(res *http.Response) (uint32, bool) { func parseCRC32c(res *http.Response) (uint32, bool) {
const prefix = "crc32c=" const prefix = "crc32c="
for _, spec := range res.Header["X-Goog-Hash"] { for _, spec := range res.Header["X-Goog-Hash"] {
if strings.HasPrefix(spec, prefix) { values := strings.Split(spec, ",")
c, err := decodeUint32(spec[len(prefix):])
if err == nil { for _, v := range values {
return c, true if strings.HasPrefix(v, prefix) {
c, err := decodeUint32(v[len(prefix):])
if err == nil {
return c, true
}
} }
} }
} }
return 0, false return 0, false
} }

View file

@ -129,8 +129,10 @@ type Client struct {
// //
// Clients should be reused instead of created as needed. The methods of Client // Clients should be reused instead of created as needed. The methods of Client
// are safe for concurrent use by multiple goroutines. // are safe for concurrent use by multiple goroutines.
//
// You may configure the client by passing in options from the [google.golang.org/api/option]
// package. You may also use options defined in this package, such as [WithJSONReads].
func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
// Use the experimental gRPC client if the env var is set. // Use the experimental gRPC client if the env var is set.
// This is an experimental API and not intended for public use. // This is an experimental API and not intended for public use.
if withGRPC := os.Getenv("STORAGE_USE_GRPC"); withGRPC != "" { if withGRPC := os.Getenv("STORAGE_USE_GRPC"); withGRPC != "" {
@ -179,10 +181,12 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
endpoint := hostURL.String() endpoint := hostURL.String()
// Append the emulator host as default endpoint for the user // Append the emulator host as default endpoint for the user
opts = append([]option.ClientOption{option.WithoutAuthentication()}, opts...) opts = append([]option.ClientOption{
option.WithoutAuthentication(),
opts = append(opts, internaloption.WithDefaultEndpoint(endpoint)) internaloption.SkipDialSettingsValidation(),
opts = append(opts, internaloption.WithDefaultMTLSEndpoint(endpoint)) internaloption.WithDefaultEndpoint(endpoint),
internaloption.WithDefaultMTLSEndpoint(endpoint),
}, opts...)
} }
// htransport selects the correct endpoint among WithEndpoint (user override), WithDefaultEndpoint, and WithDefaultMTLSEndpoint. // htransport selects the correct endpoint among WithEndpoint (user override), WithDefaultEndpoint, and WithDefaultMTLSEndpoint.
@ -1713,6 +1717,8 @@ type Conditions struct {
// GenerationNotMatch specifies that the object must not have the given // GenerationNotMatch specifies that the object must not have the given
// generation for the operation to occur. // generation for the operation to occur.
// If GenerationNotMatch is zero, it has no effect. // If GenerationNotMatch is zero, it has no effect.
// This condition only works for object reads if the WithJSONReads client
// option is set.
GenerationNotMatch int64 GenerationNotMatch int64
// DoesNotExist specifies that the object must not exist in the bucket for // DoesNotExist specifies that the object must not exist in the bucket for
@ -1731,6 +1737,8 @@ type Conditions struct {
// MetagenerationNotMatch specifies that the object must not have the given // MetagenerationNotMatch specifies that the object must not have the given
// metageneration for the operation to occur. // metageneration for the operation to occur.
// If MetagenerationNotMatch is zero, it has no effect. // If MetagenerationNotMatch is zero, it has no effect.
// This condition only works for object reads if the WithJSONReads client
// option is set.
MetagenerationNotMatch int64 MetagenerationNotMatch int64
} }

View file

@ -11119,6 +11119,9 @@ var awsPartition = partition{
endpointKey{ endpointKey{
Region: "ap-southeast-3", Region: "ap-southeast-3",
}: endpoint{}, }: endpoint{},
endpointKey{
Region: "ap-southeast-4",
}: endpoint{},
endpointKey{ endpointKey{
Region: "ca-central-1", Region: "ca-central-1",
}: endpoint{}, }: endpoint{},
@ -25779,6 +25782,9 @@ var awsPartition = partition{
endpointKey{ endpointKey{
Region: "ap-south-1", Region: "ap-south-1",
}: endpoint{}, }: endpoint{},
endpointKey{
Region: "ap-south-2",
}: endpoint{},
endpointKey{ endpointKey{
Region: "ap-southeast-1", Region: "ap-southeast-1",
}: endpoint{}, }: endpoint{},
@ -25788,6 +25794,9 @@ var awsPartition = partition{
endpointKey{ endpointKey{
Region: "ap-southeast-3", Region: "ap-southeast-3",
}: endpoint{}, }: endpoint{},
endpointKey{
Region: "ap-southeast-4",
}: endpoint{},
endpointKey{ endpointKey{
Region: "ca-central-1", Region: "ca-central-1",
}: endpoint{}, }: endpoint{},

View file

@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go" const SDKName = "aws-sdk-go"
// SDKVersion is the version of this SDK // SDKVersion is the version of this SDK
const SDKVersion = "1.44.221" const SDKVersion = "1.44.222"

View file

@ -45,7 +45,7 @@ func (u *UnmarshalTypedError) UnmarshalError(
msg := resp.Header.Get(errorMessageHeader) msg := resp.Header.Get(errorMessageHeader)
body := resp.Body body := resp.Body
if len(code) == 0 { if len(code) == 0 || len(msg) == 0 {
// If unable to get code from HTTP headers have to parse JSON message // If unable to get code from HTTP headers have to parse JSON message
// to determine what kind of exception this will be. // to determine what kind of exception this will be.
var buf bytes.Buffer var buf bytes.Buffer
@ -57,7 +57,9 @@ func (u *UnmarshalTypedError) UnmarshalError(
} }
body = ioutil.NopCloser(&buf) body = ioutil.NopCloser(&buf)
code = jsonErr.Code if len(code) == 0 {
code = jsonErr.Code
}
msg = jsonErr.Message msg = jsonErr.Message
} }

View file

@ -1,3 +1,3 @@
{ {
"v2": "2.7.1" "v2": "2.8.0"
} }

View file

@ -1,5 +1,12 @@
# Changelog # Changelog
## [2.8.0](https://github.com/googleapis/gax-go/compare/v2.7.1...v2.8.0) (2023-03-15)
### Features
* **v2:** add WithTimeout option ([#259](https://github.com/googleapis/gax-go/issues/259)) ([9a8da43](https://github.com/googleapis/gax-go/commit/9a8da43693002448b1e8758023699387481866d1))
## [2.7.1](https://github.com/googleapis/gax-go/compare/v2.7.0...v2.7.1) (2023-03-06) ## [2.7.1](https://github.com/googleapis/gax-go/compare/v2.7.0...v2.7.1) (2023-03-06)

View file

@ -218,6 +218,14 @@ func (p pathOpt) Resolve(s *CallSettings) {
s.Path = p.p s.Path = p.p
} }
type timeoutOpt struct {
t time.Duration
}
func (t timeoutOpt) Resolve(s *CallSettings) {
s.timeout = t.t
}
// WithPath applies a Path override to the HTTP-based APICall. // WithPath applies a Path override to the HTTP-based APICall.
// //
// This is for internal use only. // This is for internal use only.
@ -230,6 +238,15 @@ func WithGRPCOptions(opt ...grpc.CallOption) CallOption {
return grpcOpt(append([]grpc.CallOption(nil), opt...)) return grpcOpt(append([]grpc.CallOption(nil), opt...))
} }
// WithTimeout is a convenience option for setting a context.WithTimeout on the
// singular context.Context used for **all** APICall attempts. Calculated from
// the start of the first APICall attempt.
// If the context.Context provided to Invoke already has a Deadline set, that
// will always be respected over the deadline calculated using this option.
func WithTimeout(t time.Duration) CallOption {
return &timeoutOpt{t: t}
}
// CallSettings allow fine-grained control over how calls are made. // CallSettings allow fine-grained control over how calls are made.
type CallSettings struct { type CallSettings struct {
// Retry returns a Retryer to be used to control retry logic of a method call. // Retry returns a Retryer to be used to control retry logic of a method call.
@ -241,4 +258,8 @@ type CallSettings struct {
// Path is an HTTP override for an APICall. // Path is an HTTP override for an APICall.
Path string Path string
// Timeout defines the amount of time that Invoke has to complete.
// Unexported so it cannot be changed by the code in an APICall.
timeout time.Duration
} }

View file

@ -30,4 +30,4 @@
package internal package internal
// Version is the current tagged release of the library. // Version is the current tagged release of the library.
const Version = "2.7.1" const Version = "2.8.0"

View file

@ -68,6 +68,16 @@ type sleeper func(ctx context.Context, d time.Duration) error
// invoke implements Invoke, taking an additional sleeper argument for testing. // invoke implements Invoke, taking an additional sleeper argument for testing.
func invoke(ctx context.Context, call APICall, settings CallSettings, sp sleeper) error { func invoke(ctx context.Context, call APICall, settings CallSettings, sp sleeper) error {
var retryer Retryer var retryer Retryer
// Only use the value provided via WithTimeout if the context doesn't
// already have a deadline. This is important for backwards compatibility if
// the user already set a deadline on the context given to Invoke.
if _, ok := ctx.Deadline(); !ok && settings.timeout != 0 {
c, cc := context.WithTimeout(ctx, settings.timeout)
defer cc()
ctx = c
}
for { for {
err := call(ctx, settings) err := call(ctx, settings)
if err == nil { if err == nil {

View file

@ -6,10 +6,15 @@ package internal
import ( import (
"context" "context"
"crypto/tls"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"net/http"
"os"
"time"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"google.golang.org/api/internal/impersonate" "google.golang.org/api/internal/impersonate"
@ -17,6 +22,8 @@ import (
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
) )
const quotaProjectEnvVar = "GOOGLE_CLOUD_QUOTA_PROJECT"
// Creds returns credential information obtained from DialSettings, or if none, then // Creds returns credential information obtained from DialSettings, or if none, then
// it returns default credential information. // it returns default credential information.
func Creds(ctx context.Context, ds *DialSettings) (*google.Credentials, error) { func Creds(ctx context.Context, ds *DialSettings) (*google.Credentials, error) {
@ -80,8 +87,25 @@ const (
// - Otherwise, executes standard OAuth 2.0 flow // - Otherwise, executes standard OAuth 2.0 flow
// More details: google.aip.dev/auth/4111 // More details: google.aip.dev/auth/4111
func credentialsFromJSON(ctx context.Context, data []byte, ds *DialSettings) (*google.Credentials, error) { func credentialsFromJSON(ctx context.Context, data []byte, ds *DialSettings) (*google.Credentials, error) {
var params google.CredentialsParams
params.Scopes = ds.GetScopes()
// Determine configurations for the OAuth2 transport, which is separate from the API transport.
// The OAuth2 transport and endpoint will be configured for mTLS if applicable.
clientCertSource, oauth2Endpoint, err := GetClientCertificateSourceAndEndpoint(oauth2DialSettings(ds))
if err != nil {
return nil, err
}
params.TokenURL = oauth2Endpoint
if clientCertSource != nil {
tlsConfig := &tls.Config{
GetClientCertificate: clientCertSource,
}
ctx = context.WithValue(ctx, oauth2.HTTPClient, customHTTPClient(tlsConfig))
}
// By default, a standard OAuth 2.0 token source is created // By default, a standard OAuth 2.0 token source is created
cred, err := google.CredentialsFromJSON(ctx, data, ds.GetScopes()...) cred, err := google.CredentialsFromJSONWithParams(ctx, data, params)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -131,14 +155,22 @@ func selfSignedJWTTokenSource(data []byte, ds *DialSettings) (oauth2.TokenSource
} }
} }
// QuotaProjectFromCreds returns the quota project from the JSON blob in the provided credentials. // GetQuotaProject retrieves quota project with precedence being: client option,
// // environment variable, creds file.
// NOTE(cbro): consider promoting this to a field on google.Credentials. func GetQuotaProject(creds *google.Credentials, clientOpt string) string {
func QuotaProjectFromCreds(cred *google.Credentials) string { if clientOpt != "" {
return clientOpt
}
if env := os.Getenv(quotaProjectEnvVar); env != "" {
return env
}
if creds == nil {
return ""
}
var v struct { var v struct {
QuotaProject string `json:"quota_project_id"` QuotaProject string `json:"quota_project_id"`
} }
if err := json.Unmarshal(cred.JSON, &v); err != nil { if err := json.Unmarshal(creds.JSON, &v); err != nil {
return "" return ""
} }
return v.QuotaProject return v.QuotaProject
@ -157,3 +189,35 @@ func impersonateCredentials(ctx context.Context, creds *google.Credentials, ds *
ProjectID: creds.ProjectID, ProjectID: creds.ProjectID,
}, nil }, nil
} }
// oauth2DialSettings returns the settings to be used by the OAuth2 transport, which is separate from the API transport.
func oauth2DialSettings(ds *DialSettings) *DialSettings {
var ods DialSettings
ods.DefaultEndpoint = google.Endpoint.TokenURL
ods.DefaultMTLSEndpoint = google.MTLSTokenURL
ods.ClientCertSource = ds.ClientCertSource
return &ods
}
// customHTTPClient constructs an HTTPClient using the provided tlsConfig, to support mTLS.
func customHTTPClient(tlsConfig *tls.Config) *http.Client {
trans := baseTransport()
trans.TLSClientConfig = tlsConfig
return &http.Client{Transport: trans}
}
func baseTransport() *http.Transport {
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
}

View file

@ -23,15 +23,16 @@
// //
// This package is not intended for use by end developers. Use the // This package is not intended for use by end developers. Use the
// google.golang.org/api/option package to configure API clients. // google.golang.org/api/option package to configure API clients.
package dca
// Package internal supports the options and transport packages.
package internal
import ( import (
"net/url" "net/url"
"os" "os"
"strings" "strings"
"google.golang.org/api/internal" "google.golang.org/api/internal/cert"
"google.golang.org/api/transport/cert"
) )
const ( const (
@ -43,7 +44,7 @@ const (
// GetClientCertificateSourceAndEndpoint is a convenience function that invokes // GetClientCertificateSourceAndEndpoint is a convenience function that invokes
// getClientCertificateSource and getEndpoint sequentially and returns the client // getClientCertificateSource and getEndpoint sequentially and returns the client
// cert source and endpoint as a tuple. // cert source and endpoint as a tuple.
func GetClientCertificateSourceAndEndpoint(settings *internal.DialSettings) (cert.Source, string, error) { func GetClientCertificateSourceAndEndpoint(settings *DialSettings) (cert.Source, string, error) {
clientCertSource, err := getClientCertificateSource(settings) clientCertSource, err := getClientCertificateSource(settings)
if err != nil { if err != nil {
return nil, "", err return nil, "", err
@ -65,7 +66,7 @@ func GetClientCertificateSourceAndEndpoint(settings *internal.DialSettings) (cer
// Important Note: For now, the environment variable GOOGLE_API_USE_CLIENT_CERTIFICATE // Important Note: For now, the environment variable GOOGLE_API_USE_CLIENT_CERTIFICATE
// must be set to "true" to allow certificate to be used (including user provided // must be set to "true" to allow certificate to be used (including user provided
// certificates). For details, see AIP-4114. // certificates). For details, see AIP-4114.
func getClientCertificateSource(settings *internal.DialSettings) (cert.Source, error) { func getClientCertificateSource(settings *DialSettings) (cert.Source, error) {
if !isClientCertificateEnabled() { if !isClientCertificateEnabled() {
return nil, nil return nil, nil
} else if settings.ClientCertSource != nil { } else if settings.ClientCertSource != nil {
@ -94,7 +95,7 @@ func isClientCertificateEnabled() bool {
// URL (ex. https://...), then the user-provided address will be merged into // URL (ex. https://...), then the user-provided address will be merged into
// the default endpoint. For example, WithEndpoint("myhost:8000") and // the default endpoint. For example, WithEndpoint("myhost:8000") and
// WithDefaultEndpoint("https://foo.com/bar/baz") will return "https://myhost:8080/bar/baz" // WithDefaultEndpoint("https://foo.com/bar/baz") will return "https://myhost:8080/bar/baz"
func getEndpoint(settings *internal.DialSettings, clientCertSource cert.Source) (string, error) { func getEndpoint(settings *DialSettings, clientCertSource cert.Source) (string, error) {
if settings.Endpoint == "" { if settings.Endpoint == "" {
mtlsMode := getMTLSMode() mtlsMode := getMTLSMode()
if mtlsMode == mTLSModeAlways || (clientCertSource != nil && mtlsMode == mTLSModeAuto) { if mtlsMode == mTLSModeAlways || (clientCertSource != nil && mtlsMode == mTLSModeAuto) {

View file

@ -5,4 +5,4 @@
package internal package internal
// Version is the current tagged release of the library. // Version is the current tagged release of the library.
const Version = "0.112.0" const Version = "0.113.0"

View file

@ -21,7 +21,6 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
"google.golang.org/api/internal" "google.golang.org/api/internal"
"google.golang.org/api/option" "google.golang.org/api/option"
"google.golang.org/api/transport/internal/dca"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
grpcgoogle "google.golang.org/grpc/credentials/google" grpcgoogle "google.golang.org/grpc/credentials/google"
@ -123,7 +122,7 @@ func dial(ctx context.Context, insecure bool, o *internal.DialSettings) (*grpc.C
if o.GRPCConn != nil { if o.GRPCConn != nil {
return o.GRPCConn, nil return o.GRPCConn, nil
} }
clientCertSource, endpoint, err := dca.GetClientCertificateSourceAndEndpoint(o) clientCertSource, endpoint, err := internal.GetClientCertificateSourceAndEndpoint(o)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -155,14 +154,10 @@ func dial(ctx context.Context, insecure bool, o *internal.DialSettings) (*grpc.C
return nil, err return nil, err
} }
if o.QuotaProject == "" {
o.QuotaProject = internal.QuotaProjectFromCreds(creds)
}
grpcOpts = append(grpcOpts, grpcOpts = append(grpcOpts,
grpc.WithPerRPCCredentials(grpcTokenSource{ grpc.WithPerRPCCredentials(grpcTokenSource{
TokenSource: oauth.TokenSource{creds.TokenSource}, TokenSource: oauth.TokenSource{creds.TokenSource},
quotaProject: o.QuotaProject, quotaProject: internal.GetQuotaProject(creds, o.QuotaProject),
requestReason: o.RequestReason, requestReason: o.RequestReason,
}), }),
) )

View file

@ -20,10 +20,9 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
"google.golang.org/api/googleapi/transport" "google.golang.org/api/googleapi/transport"
"google.golang.org/api/internal" "google.golang.org/api/internal"
"google.golang.org/api/internal/cert"
"google.golang.org/api/option" "google.golang.org/api/option"
"google.golang.org/api/transport/cert"
"google.golang.org/api/transport/http/internal/propagation" "google.golang.org/api/transport/http/internal/propagation"
"google.golang.org/api/transport/internal/dca"
) )
// NewClient returns an HTTP client for use communicating with a Google cloud // NewClient returns an HTTP client for use communicating with a Google cloud
@ -34,7 +33,7 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*http.Client,
if err != nil { if err != nil {
return nil, "", err return nil, "", err
} }
clientCertSource, endpoint, err := dca.GetClientCertificateSourceAndEndpoint(settings) clientCertSource, endpoint, err := internal.GetClientCertificateSourceAndEndpoint(settings)
if err != nil { if err != nil {
return nil, "", err return nil, "", err
} }
@ -66,7 +65,6 @@ func newTransport(ctx context.Context, base http.RoundTripper, settings *interna
paramTransport := &parameterTransport{ paramTransport := &parameterTransport{
base: base, base: base,
userAgent: settings.UserAgent, userAgent: settings.UserAgent,
quotaProject: settings.QuotaProject,
requestReason: settings.RequestReason, requestReason: settings.RequestReason,
} }
var trans http.RoundTripper = paramTransport var trans http.RoundTripper = paramTransport
@ -75,6 +73,7 @@ func newTransport(ctx context.Context, base http.RoundTripper, settings *interna
case settings.NoAuth: case settings.NoAuth:
// Do nothing. // Do nothing.
case settings.APIKey != "": case settings.APIKey != "":
paramTransport.quotaProject = internal.GetQuotaProject(nil, settings.QuotaProject)
trans = &transport.APIKey{ trans = &transport.APIKey{
Transport: trans, Transport: trans,
Key: settings.APIKey, Key: settings.APIKey,
@ -84,10 +83,7 @@ func newTransport(ctx context.Context, base http.RoundTripper, settings *interna
if err != nil { if err != nil {
return nil, err return nil, err
} }
if paramTransport.quotaProject == "" { paramTransport.quotaProject = internal.GetQuotaProject(creds, settings.QuotaProject)
paramTransport.quotaProject = internal.QuotaProjectFromCreds(creds)
}
ts := creds.TokenSource ts := creds.TokenSource
if settings.ImpersonationConfig == nil && settings.TokenSource != nil { if settings.ImpersonationConfig == nil && settings.TokenSource != nil {
ts = settings.TokenSource ts = settings.TokenSource

View file

@ -1,208 +0,0 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by aliasgen. DO NOT EDIT.
// Package iam aliases all exported identifiers in package
// "cloud.google.com/go/iam/apiv1/iampb".
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb.
// Please read https://github.com/googleapis/google-cloud-go/blob/main/migration.md
// for more details.
package iam
import (
src "cloud.google.com/go/iam/apiv1/iampb"
grpc "google.golang.org/grpc"
)
// Deprecated: Please use consts in: cloud.google.com/go/iam/apiv1/iampb
const (
AuditConfigDelta_ACTION_UNSPECIFIED = src.AuditConfigDelta_ACTION_UNSPECIFIED
AuditConfigDelta_ADD = src.AuditConfigDelta_ADD
AuditConfigDelta_REMOVE = src.AuditConfigDelta_REMOVE
AuditLogConfig_ADMIN_READ = src.AuditLogConfig_ADMIN_READ
AuditLogConfig_DATA_READ = src.AuditLogConfig_DATA_READ
AuditLogConfig_DATA_WRITE = src.AuditLogConfig_DATA_WRITE
AuditLogConfig_LOG_TYPE_UNSPECIFIED = src.AuditLogConfig_LOG_TYPE_UNSPECIFIED
BindingDelta_ACTION_UNSPECIFIED = src.BindingDelta_ACTION_UNSPECIFIED
BindingDelta_ADD = src.BindingDelta_ADD
BindingDelta_REMOVE = src.BindingDelta_REMOVE
)
// Deprecated: Please use vars in: cloud.google.com/go/iam/apiv1/iampb
var (
AuditConfigDelta_Action_name = src.AuditConfigDelta_Action_name
AuditConfigDelta_Action_value = src.AuditConfigDelta_Action_value
AuditLogConfig_LogType_name = src.AuditLogConfig_LogType_name
AuditLogConfig_LogType_value = src.AuditLogConfig_LogType_value
BindingDelta_Action_name = src.BindingDelta_Action_name
BindingDelta_Action_value = src.BindingDelta_Action_value
File_google_iam_v1_iam_policy_proto = src.File_google_iam_v1_iam_policy_proto
File_google_iam_v1_options_proto = src.File_google_iam_v1_options_proto
File_google_iam_v1_policy_proto = src.File_google_iam_v1_policy_proto
)
// Specifies the audit configuration for a service. The configuration
// determines which permission types are logged, and what identities, if any,
// are exempted from logging. An AuditConfig must have one or more
// AuditLogConfigs. If there are AuditConfigs for both `allServices` and a
// specific service, the union of the two AuditConfigs is used for that
// service: the log_types specified in each AuditConfig are enabled, and the
// exempted_members in each AuditLogConfig are exempted. Example Policy with
// multiple AuditConfigs: { "audit_configs": [ { "service": "allServices",
// "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [
// "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type":
// "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com",
// "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type":
// "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For
// sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ
// logging. It also exempts jose@example.com from DATA_READ logging, and
// aliya@example.com from DATA_WRITE logging.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type AuditConfig = src.AuditConfig
// One delta entry for AuditConfig. Each individual change (only one
// exempted_member in each entry) to a AuditConfig will be a separate entry.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type AuditConfigDelta = src.AuditConfigDelta
// The type of action performed on an audit configuration in a policy.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type AuditConfigDelta_Action = src.AuditConfigDelta_Action
// Provides the configuration for logging a type of permissions. Example: {
// "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [
// "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables
// 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from
// DATA_READ logging.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type AuditLogConfig = src.AuditLogConfig
// The list of valid permission types for which logging can be configured.
// Admin writes are always logged, and are not configurable.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type AuditLogConfig_LogType = src.AuditLogConfig_LogType
// Associates `members`, or principals, with a `role`.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type Binding = src.Binding
// One delta entry for Binding. Each individual change (only one member in
// each entry) to a binding will be a separate entry.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type BindingDelta = src.BindingDelta
// The type of action performed on a Binding in a policy.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type BindingDelta_Action = src.BindingDelta_Action
// Request message for `GetIamPolicy` method.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type GetIamPolicyRequest = src.GetIamPolicyRequest
// Encapsulates settings provided to GetIamPolicy.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type GetPolicyOptions = src.GetPolicyOptions
// IAMPolicyClient is the client API for IAMPolicy service. For semantics
// around ctx use and closing/ending streaming RPCs, please refer to
// https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type IAMPolicyClient = src.IAMPolicyClient
// IAMPolicyServer is the server API for IAMPolicy service.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type IAMPolicyServer = src.IAMPolicyServer
// An Identity and Access Management (IAM) policy, which specifies access
// controls for Google Cloud resources. A `Policy` is a collection of
// `bindings`. A `binding` binds one or more `members`, or principals, to a
// single `role`. Principals can be user accounts, service accounts, Google
// groups, and domains (such as G Suite). A `role` is a named list of
// permissions; each `role` can be an IAM predefined role or a user-created
// custom role. For some types of Google Cloud resources, a `binding` can also
// specify a `condition`, which is a logical expression that allows access to a
// resource only if the expression evaluates to `true`. A condition can add
// constraints based on attributes of the request, the resource, or both. To
// learn which resources support conditions in their IAM policies, see the [IAM
// documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
// **JSON example:** { "bindings": [ { "role":
// "roles/resourcemanager.organizationAdmin", "members": [
// "user:mike@example.com", "group:admins@example.com", "domain:google.com",
// "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role":
// "roles/resourcemanager.organizationViewer", "members": [
// "user:eve@example.com" ], "condition": { "title": "expirable access",
// "description": "Does not grant access after Sep 2020", "expression":
// "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag":
// "BwWWja0YfJA=", "version": 3 } **YAML example:** bindings: - members: -
// user:mike@example.com - group:admins@example.com - domain:google.com -
// serviceAccount:my-project-id@appspot.gserviceaccount.com role:
// roles/resourcemanager.organizationAdmin - members: - user:eve@example.com
// role: roles/resourcemanager.organizationViewer condition: title: expirable
// access description: Does not grant access after Sep 2020 expression:
// request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA=
// version: 3 For a description of IAM and its features, see the [IAM
// documentation](https://cloud.google.com/iam/docs/).
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type Policy = src.Policy
// The difference delta between two policies.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type PolicyDelta = src.PolicyDelta
// Request message for `SetIamPolicy` method.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type SetIamPolicyRequest = src.SetIamPolicyRequest
// Request message for `TestIamPermissions` method.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type TestIamPermissionsRequest = src.TestIamPermissionsRequest
// Response message for `TestIamPermissions` method.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type TestIamPermissionsResponse = src.TestIamPermissionsResponse
// UnimplementedIAMPolicyServer can be embedded to have forward compatible
// implementations.
//
// Deprecated: Please use types in: cloud.google.com/go/iam/apiv1/iampb
type UnimplementedIAMPolicyServer = src.UnimplementedIAMPolicyServer
// Deprecated: Please use funcs in: cloud.google.com/go/iam/apiv1/iampb
func NewIAMPolicyClient(cc grpc.ClientConnInterface) IAMPolicyClient {
return src.NewIAMPolicyClient(cc)
}
// Deprecated: Please use funcs in: cloud.google.com/go/iam/apiv1/iampb
func RegisterIAMPolicyServer(s *grpc.Server, srv IAMPolicyServer) {
src.RegisterIAMPolicyServer(s, srv)
}

16
vendor/modules.txt vendored
View file

@ -10,11 +10,11 @@ cloud.google.com/go/compute/internal
# cloud.google.com/go/compute/metadata v0.2.3 # cloud.google.com/go/compute/metadata v0.2.3
## explicit; go 1.19 ## explicit; go 1.19
cloud.google.com/go/compute/metadata cloud.google.com/go/compute/metadata
# cloud.google.com/go/iam v0.12.0 # cloud.google.com/go/iam v0.13.0
## explicit; go 1.19 ## explicit; go 1.19
cloud.google.com/go/iam cloud.google.com/go/iam
cloud.google.com/go/iam/apiv1/iampb cloud.google.com/go/iam/apiv1/iampb
# cloud.google.com/go/storage v1.29.0 # cloud.google.com/go/storage v1.30.0
## explicit; go 1.19 ## explicit; go 1.19
cloud.google.com/go/storage cloud.google.com/go/storage
cloud.google.com/go/storage/internal cloud.google.com/go/storage/internal
@ -81,7 +81,7 @@ github.com/VividCortex/ewma
# github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 # github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
## explicit; go 1.15 ## explicit; go 1.15
github.com/alecthomas/units github.com/alecthomas/units
# github.com/aws/aws-sdk-go v1.44.221 # github.com/aws/aws-sdk-go v1.44.222
## explicit; go 1.11 ## explicit; go 1.11
github.com/aws/aws-sdk-go/aws github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/awserr github.com/aws/aws-sdk-go/aws/awserr
@ -314,7 +314,7 @@ github.com/google/uuid
## explicit; go 1.19 ## explicit; go 1.19
github.com/googleapis/enterprise-certificate-proxy/client github.com/googleapis/enterprise-certificate-proxy/client
github.com/googleapis/enterprise-certificate-proxy/client/util github.com/googleapis/enterprise-certificate-proxy/client/util
# github.com/googleapis/gax-go/v2 v2.7.1 # github.com/googleapis/gax-go/v2 v2.8.0
## explicit; go 1.19 ## explicit; go 1.19
github.com/googleapis/gax-go/v2 github.com/googleapis/gax-go/v2
github.com/googleapis/gax-go/v2/apierror github.com/googleapis/gax-go/v2/apierror
@ -525,7 +525,7 @@ go.uber.org/atomic
## explicit; go 1.18 ## explicit; go 1.18
go.uber.org/goleak go.uber.org/goleak
go.uber.org/goleak/internal/stack go.uber.org/goleak/internal/stack
# golang.org/x/exp v0.0.0-20230314191032-db074128a8ec # golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/exp/constraints golang.org/x/exp/constraints
golang.org/x/exp/slices golang.org/x/exp/slices
@ -572,12 +572,13 @@ golang.org/x/time/rate
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/xerrors golang.org/x/xerrors
golang.org/x/xerrors/internal golang.org/x/xerrors/internal
# google.golang.org/api v0.112.0 # google.golang.org/api v0.113.0
## explicit; go 1.19 ## explicit; go 1.19
google.golang.org/api/googleapi google.golang.org/api/googleapi
google.golang.org/api/googleapi/transport google.golang.org/api/googleapi/transport
google.golang.org/api/iamcredentials/v1 google.golang.org/api/iamcredentials/v1
google.golang.org/api/internal google.golang.org/api/internal
google.golang.org/api/internal/cert
google.golang.org/api/internal/gensupport google.golang.org/api/internal/gensupport
google.golang.org/api/internal/impersonate google.golang.org/api/internal/impersonate
google.golang.org/api/internal/third_party/uritemplates google.golang.org/api/internal/third_party/uritemplates
@ -586,11 +587,9 @@ google.golang.org/api/option
google.golang.org/api/option/internaloption google.golang.org/api/option/internaloption
google.golang.org/api/storage/v1 google.golang.org/api/storage/v1
google.golang.org/api/transport google.golang.org/api/transport
google.golang.org/api/transport/cert
google.golang.org/api/transport/grpc google.golang.org/api/transport/grpc
google.golang.org/api/transport/http google.golang.org/api/transport/http
google.golang.org/api/transport/http/internal/propagation google.golang.org/api/transport/http/internal/propagation
google.golang.org/api/transport/internal/dca
# google.golang.org/appengine v1.6.7 # google.golang.org/appengine v1.6.7
## explicit; go 1.11 ## explicit; go 1.11
google.golang.org/appengine google.golang.org/appengine
@ -609,7 +608,6 @@ google.golang.org/appengine/urlfetch
## explicit; go 1.19 ## explicit; go 1.19
google.golang.org/genproto/googleapis/api google.golang.org/genproto/googleapis/api
google.golang.org/genproto/googleapis/api/annotations google.golang.org/genproto/googleapis/api/annotations
google.golang.org/genproto/googleapis/iam/v1
google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/rpc/code
google.golang.org/genproto/googleapis/rpc/errdetails google.golang.org/genproto/googleapis/rpc/errdetails
google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/rpc/status