diff --git a/README.md b/README.md index 620a7425a9..813ddd96bc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This project is used to read and write to/from GitHub (repositories, teams, file ## Usage -Detailed documentation for the GitHub provider can be found [here](https://www.terraform.io/docs/providers/github/index.html). +Detailed documentation for the GitHub provider can be found [here](https://registry.terraform.io/providers/integrations/github). ## Contributing diff --git a/github/data_source_github_ref.go b/github/data_source_github_ref.go index ea22e436c2..81f6e49123 100644 --- a/github/data_source_github_ref.go +++ b/github/data_source_github_ref.go @@ -24,6 +24,10 @@ func dataSourceGithubRef() *schema.Resource { Required: true, ForceNew: true, }, + "owner": { + Type: schema.TypeString, + Optional: true, + }, "etag": { Type: schema.TypeString, Computed: true, @@ -38,15 +42,18 @@ func dataSourceGithubRef() *schema.Resource { func dataSourceGithubRefRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*Owner).v3client - orgName := meta.(*Owner).name + owner, ok := d.Get("owner").(string) + if !ok { + owner = meta.(*Owner).name + } repoName := d.Get("repository").(string) ref := d.Get("ref").(string) - refData, resp, err := client.Git.GetRef(context.TODO(), orgName, repoName, ref) + refData, resp, err := client.Git.GetRef(context.TODO(), owner, repoName, ref) if err != nil { if err, ok := err.(*github.ErrorResponse); ok { if err.Response.StatusCode == http.StatusNotFound { - log.Printf("[DEBUG] Missing GitHub ref %s/%s (%s)", orgName, repoName, ref) + log.Printf("[DEBUG] Missing GitHub ref %s/%s (%s)", owner, repoName, ref) d.SetId("") return nil } diff --git a/website/docs/d/ref.html.markdown b/website/docs/d/ref.html.markdown index 2e4a757493..2e2c2fd853 100644 --- a/website/docs/d/ref.html.markdown +++ b/website/docs/d/ref.html.markdown @@ -13,8 +13,9 @@ Use this data source to retrieve information about a repository ref. ```hcl data "github_ref" "development" { + owner = "example" repository = "example" - ref = "heads/development" + ref = "heads/development" } ``` @@ -22,6 +23,8 @@ data "github_ref" "development" { The following arguments are supported: +* `owner` - (Required) Owner of the repository. + * `repository` - (Required) The GitHub repository name. * `ref` - (Required) The repository ref to look up. Must be formatted `heads/` for branches, and `tags/` for tags. @@ -32,4 +35,6 @@ The following additional attributes are exported: * `etag` - An etag representing the ref. +* `id` - A string storing a reference to the repository name and ref. + * `sha` - A string storing the reference's `HEAD` commit's SHA1.