Skip to content

Commit

Permalink
Make storage bucket object respect custom endpoints (#10525)
Browse files Browse the repository at this point in the history
  • Loading branch information
trodge committed Apr 24, 2024
1 parent 731a277 commit 1a466f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ func dataSourceGoogleStorageBucketObjectRead(d *schema.ResourceData, meta interf
name = url.QueryEscape(name)
}
// Using REST apis because the storage go client doesn't support folders
url := fmt.Sprintf("https://www.googleapis.com/storage/v1/b/%s/o/%s", bucket, name)
url, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("{{StorageBasePath}}b/%s/o/%s", bucket, name))
if err != nil {
return fmt.Errorf("Error formatting url for storage bucket object: %s", err)
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func datasourceGoogleStorageBucketObjectsRead(d *schema.ResourceData, meta inter

for {
bucket := d.Get("bucket").(string)
url := fmt.Sprintf("https://storage.googleapis.com/storage/v1/b/%s/o", bucket)
url, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("{{StorageBasePath}}b/%s/o", bucket))
if err != nil {
return err
}

if v, ok := d.GetOk("match_glob"); ok {
params["matchGlob"] = v.(string)
Expand All @@ -80,7 +83,7 @@ func datasourceGoogleStorageBucketObjectsRead(d *schema.ResourceData, meta inter
params["prefix"] = v.(string)
}

url, err := transport_tpg.AddQueryParams(url, params)
url, err = transport_tpg.AddQueryParams(url, params)
if err != nil {
return err
}
Expand Down

0 comments on commit 1a466f7

Please sign in to comment.