Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Add support to retrieve information about the currently authenticated…
Browse files Browse the repository at this point in the history
… user

Copy https://github.com/terraform-providers/terraform-provider-github/pull/261 as the original repository behind this PR has been deleted
  • Loading branch information
jansiwy authored and fmasuhr committed Jun 18, 2020
1 parent 0eb729b commit 8ad48d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions github/data_source_github_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,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
15 changes: 13 additions & 2 deletions website/docs/d/user.html.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
layout: "github"
page_title: "GitHub: github_user"
sidebar_current: "docs-github-datasource-user"
description: |-
Get information on a GitHub user.
---
Expand All @@ -12,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 @@ -41,4 +53,3 @@ data "github_user" "example" {
* `following` - the number of following users.
* `created_at` - the creation date.
* `updated_at` - the update date.

0 comments on commit 8ad48d1

Please sign in to comment.