Skip to content

Commit

Permalink
tailscale: fix acceptance test failure on tailnet key resource
Browse files Browse the repository at this point in the history
Updates #cleanup

Signed-off-by: Percy Wegmann <percy@tailscale.com>
  • Loading branch information
oxtoacart committed Oct 29, 2024
1 parent bc60c24 commit 098f879
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/resources/tailnet_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "tailscale_tailnet_key" "sample_key" {
- `recreate_if_invalid` (String) Determines whether the key should be created again if it becomes invalid. By default, reusable keys will be recreated, but single-use keys will not. Possible values: 'always', 'never'.
- `reusable` (Boolean) Indicates if the key is reusable or single-use. Defaults to `false`.
- `tags` (Set of String) List of tags to apply to the machines authenticated by the key.
- `user_id` (String) ID of the user who created this key, empty for keys created by OAuth clients.

### Read-Only

Expand Down
10 changes: 10 additions & 0 deletions tailscale/resource_tailnet_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func resourceTailnetKey() *schema.Resource {
}
},
},
"user_id": {
Type: schema.TypeString,
Optional: true,
Description: "ID of the user who created this key, empty for keys created by OAuth clients.",
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -257,5 +263,9 @@ func resourceTailnetKeyRead(ctx context.Context, d *schema.ResourceData, m inter
return diagnosticsError(err, "Failed to set 'invalid'")
}

if err = d.Set("user_id", key.UserID); err != nil {
return diagnosticsError(err, "Failed to set 'user_id'")
}

return nil
}
3 changes: 3 additions & 0 deletions tailscale/resource_tailnet_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ func TestAccTailscaleTailnetKey(t *testing.T) {
// don't compare IDs
actual.ID = ""

// don't compare user IDs
actual.UserID = ""

if err := assertEqual(expected, actual, "wrong key"); err != nil {
return err
}
Expand Down

0 comments on commit 098f879

Please sign in to comment.