Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to retrieve information about the currently authenticated user #261

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions github/data_source_github_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ func dataSourceGithubUserRead(d *schema.ResourceData, meta interface{}) error {
return err
}

gpg, _, err := client.Users.ListGPGKeys(ctx, username, nil)
gpg, _, err := client.Users.ListGPGKeys(ctx, user.GetLogin(), nil)
if err != nil {
return err
}
ssh, _, err := client.Users.ListKeys(ctx, username, nil)
ssh, _, err := client.Users.ListKeys(ctx, user.GetLogin(), nil)
if err != nil {
return err
}
Expand Down
14 changes: 12 additions & 2 deletions website/docs/d/user.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ Use this data source to retrieve information about a GitHub user.
## Example Usage

```hcl
# Retrieve information about a GitHub user.
data "github_user" "example" {
username = "example"
}

# Retrieve information about the currently authenticated user.
data "github_user" "current" {
username = ""
}

output "current_github_login" {
value = "${data.github_user.current.login}"
}

```

## Argument Reference

* `username` - (Required) The username.
* `username` - (Required) The username. Use an empty string `""` to retrieve information about the currently authenticated user.

## Attributes Reference

Expand All @@ -42,4 +53,3 @@ data "github_user" "example" {
* `following` - the number of following users.
* `created_at` - the creation date.
* `updated_at` - the update date.