Skip to content

Commit

Permalink
fix id for project access token resource
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelsz-rb committed Sep 3, 2024
1 parent 74ff677 commit 307d3bc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions rollbar/resource_project_access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"fmt"
"strconv"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -156,15 +157,15 @@ func resourceProjectAccessTokenCreate(ctx context.Context, d *schema.ResourceDat
return diag.FromErr(err)
}

d.SetId(pat.AccessToken)

d.SetId(strconv.FormatInt(time.Now().Unix(), 10))
mustSet(d, "access_token", pat.AccessToken)
return resourceProjectAccessTokenRead(ctx, d, m)
}

func resourceProjectAccessTokenRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics

accessToken := d.Id()
accessToken := d.Get("access_token").(string)
projectID := d.Get("project_id").(int)
l := log.With().
Str("accessToken", accessToken).
Expand Down Expand Up @@ -195,7 +196,7 @@ func resourceProjectAccessTokenRead(ctx context.Context, d *schema.ResourceData,
}

func resourceProjectAccessTokenUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accessToken := d.Id()
accessToken := d.Get("access_token").(string)
projectID := d.Get("project_id").(int)
size := d.Get("rate_limit_window_size").(int)
count := d.Get("rate_limit_window_count").(int)
Expand All @@ -220,7 +221,7 @@ func resourceProjectAccessTokenUpdate(ctx context.Context, d *schema.ResourceDat
}

func resourceProjectAccessTokenDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accessToken := d.Id()
accessToken := d.Get("access_token").(string)
projectID := d.Get("project_id").(int)

l := log.With().
Expand Down Expand Up @@ -258,6 +259,7 @@ func resourceProjectAccessTokenImporter(_ context.Context, d *schema.ResourceDat
Str("access_token", accessToken).
Send()
mustSet(d, "project_id", projectID)
d.SetId(accessToken)
mustSet(d, "access_token", accessToken)
d.SetId(strconv.FormatInt(time.Now().Unix(), 10))
return []*schema.ResourceData{d}, nil
}

0 comments on commit 307d3bc

Please sign in to comment.