Skip to content

Commit

Permalink
Remove projects/ prefix if it exists (#12574)
Browse files Browse the repository at this point in the history
[upstream:1707d5036b099eabb5a5be66871f298f3f5bb4d2]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Dec 17, 2024
1 parent a9e35f4 commit 5ec35ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/12574.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cloudlogging: fixed bug in `google_logging_project_bucket_config` that if providing "project" in the format of `<project-id-only>` , the create url will contains "projects/" twice.
```
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ For example: jsonPayload.request.status`,
}

func projectBucketConfigID(d *schema.ResourceData, config *transport_tpg.Config) (string, error) {
project := d.Get("project").(string)
projectID := d.Get("project").(string)
location := d.Get("location").(string)
bucketID := d.Get("bucket_id").(string)

if !strings.HasPrefix(project, "project") {
project = "projects/" + project
if strings.HasPrefix(projectID, "projects/") {
// Remove "projects/" prefix if it exists
projectID = strings.TrimPrefix(projectID, "projects/")
}

id := fmt.Sprintf("%s/locations/%s/buckets/%s", project, location, bucketID)
id := fmt.Sprintf("projects/%s/locations/%s/buckets/%s", projectID, location, bucketID)
return id, nil
}

Expand Down

0 comments on commit 5ec35ef

Please sign in to comment.