chore(deps): bump cloud.google.com/go/storage from 1.29.0 to 1.30.1 (#2439)

Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.29.0 to 1.30.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.29.0...spanner/v1.30.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/storage
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-05-29 17:07:45 -07:00 committed by GitHub
parent 4edf751d43
commit 297e46db80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 2140 additions and 2141 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/GoogleContainerTools/kaniko
go 1.17 go 1.17
require ( require (
cloud.google.com/go/storage v1.29.0 cloud.google.com/go/storage v1.30.1
github.com/Azure/azure-storage-blob-go v0.14.0 github.com/Azure/azure-storage-blob-go v0.14.0
github.com/aws/aws-sdk-go v1.44.253 github.com/aws/aws-sdk-go v1.44.253
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220228164355-396b2034c795 github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220228164355-396b2034c795

3
go.sum
View File

@ -547,8 +547,9 @@ cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq
cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc=
cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s=
cloud.google.com/go/storage v1.28.1/go.mod h1:Qnisd4CqDdo6BGs2AD5LLnEsmSQ80wQ5ogcBBKhU86Y= cloud.google.com/go/storage v1.28.1/go.mod h1:Qnisd4CqDdo6BGs2AD5LLnEsmSQ80wQ5ogcBBKhU86Y=
cloud.google.com/go/storage v1.29.0 h1:6weCgzRvMg7lzuUurI4697AqIRPU1SvzHhynwpW31jI=
cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4= cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4=
cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM=
cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E=
cloud.google.com/go/storagetransfer v1.5.0/go.mod h1:dxNzUopWy7RQevYFHewchb29POFv3/AaBgnhqzqiK0w= cloud.google.com/go/storagetransfer v1.5.0/go.mod h1:dxNzUopWy7RQevYFHewchb29POFv3/AaBgnhqzqiK0w=
cloud.google.com/go/storagetransfer v1.6.0/go.mod h1:y77xm4CQV/ZhFZH75PLEXY0ROiS7Gh6pSKrM8dJyg6I= cloud.google.com/go/storagetransfer v1.6.0/go.mod h1:y77xm4CQV/ZhFZH75PLEXY0ROiS7Gh6pSKrM8dJyg6I=
cloud.google.com/go/storagetransfer v1.7.0/go.mod h1:8Giuj1QNb1kfLAiWM1bN6dHzfdlDAVC9rv9abHot2W4= cloud.google.com/go/storagetransfer v1.7.0/go.mod h1:8Giuj1QNb1kfLAiWM1bN6dHzfdlDAVC9rv9abHot2W4=

View File

@ -1,6 +1,29 @@
# Changes # Changes
## [1.30.1](https://github.com/googleapis/google-cloud-go/compare/storage/v1.30.0...storage/v1.30.1) (2023-03-21)
### Bug Fixes
* **storage:** Retract versions with Copier bug ([#7583](https://github.com/googleapis/google-cloud-go/issues/7583)) ([9c10b6f](https://github.com/googleapis/google-cloud-go/commit/9c10b6f8a54cb8447260148b5e4a9b5160281020))
* Versions v1.25.0-v1.27.0 are retracted due to [#6857](https://github.com/googleapis/google-cloud-go/issues/6857).
* **storage:** SignedURL v4 allows headers with colons in value ([#7603](https://github.com/googleapis/google-cloud-go/issues/7603)) ([6b50f9b](https://github.com/googleapis/google-cloud-go/commit/6b50f9b368f5b271ade1706c342865cef46712e6))
## [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"
iampb "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.1"

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.
@ -535,7 +539,7 @@ func v4SanitizeHeaders(hdrs []string) []string {
sanitizedHeader := strings.TrimSpace(hdr) sanitizedHeader := strings.TrimSpace(hdr)
var key, value string var key, value string
headerMatches := strings.Split(sanitizedHeader, ":") headerMatches := strings.SplitN(sanitizedHeader, ":", 2)
if len(headerMatches) < 2 { if len(headerMatches) < 2 {
continue continue
} }
@ -649,7 +653,7 @@ var utcNow = func() time.Time {
func extractHeaderNames(kvs []string) []string { func extractHeaderNames(kvs []string) []string {
var res []string var res []string
for _, header := range kvs { for _, header := range kvs {
nameValue := strings.Split(header, ":") nameValue := strings.SplitN(header, ":", 2)
res = append(res, nameValue[0]) res = append(res, nameValue[0])
} }
return res return res
@ -793,7 +797,7 @@ func sortHeadersByKey(hdrs []string) []string {
headersMap := map[string]string{} headersMap := map[string]string{}
var headersKeys []string var headersKeys []string
for _, h := range hdrs { for _, h := range hdrs {
parts := strings.Split(h, ":") parts := strings.SplitN(h, ":", 2)
k := parts[0] k := parts[0]
v := parts[1] v := parts[1]
headersMap[k] = v headersMap[k] = v
@ -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

@ -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)
}

3
vendor/modules.txt vendored
View File

@ -14,7 +14,7 @@ cloud.google.com/go/compute/metadata
## 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.1
## 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
@ -934,7 +934,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