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

Commit

Permalink
Merge pull request #8 from babbel/current-user
Browse files Browse the repository at this point in the history
Add support to retrieve information about the currently authenticated user
  • Loading branch information
jansiwy authored Mar 18, 2020
2 parents 3c218f1 + 22bd212 commit e48ae7e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ matrix:
allow_failures:
- go: tip
include:
- name: "make lint"
script: make lint
# - name: "make lint"
# script: make lint
- name: "make test"
script: make test
- name: "make website-lint"
Expand Down
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
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 e48ae7e

Please sign in to comment.