Skip to content

Commit 2043f1b

Browse files
Remove projects/ prefix if it exists (#12574) (#8923)
[upstream:1707d5036b099eabb5a5be66871f298f3f5bb4d2] Signed-off-by: Modular Magician <[email protected]>
1 parent ce43676 commit 2043f1b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.changelog/12574.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
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.
3+
```

google-beta/services/logging/resource_logging_project_bucket_config.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,16 @@ For example: jsonPayload.request.status`,
133133
}
134134

135135
func projectBucketConfigID(d *schema.ResourceData, config *transport_tpg.Config) (string, error) {
136-
project := d.Get("project").(string)
136+
projectID := d.Get("project").(string)
137137
location := d.Get("location").(string)
138138
bucketID := d.Get("bucket_id").(string)
139139

140-
if !strings.HasPrefix(project, "project") {
141-
project = "projects/" + project
140+
if strings.HasPrefix(projectID, "projects/") {
141+
// Remove "projects/" prefix if it exists
142+
projectID = strings.TrimPrefix(projectID, "projects/")
142143
}
143144

144-
id := fmt.Sprintf("%s/locations/%s/buckets/%s", project, location, bucketID)
145+
id := fmt.Sprintf("projects/%s/locations/%s/buckets/%s", projectID, location, bucketID)
145146
return id, nil
146147
}
147148

0 commit comments

Comments
 (0)