Skip to content

Commit

Permalink
Remove projects/ prefix if it exists (GoogleCloudPlatform#12574)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengq-google authored and amanMahendroo committed Dec 17, 2024
1 parent 3466cd0 commit 6d32dc5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,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 6d32dc5

Please sign in to comment.