Skip to content

Commit

Permalink
fix: remove incorrect required schema key on ref data source (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
youcandanch authored Apr 28, 2022
1 parent b723752 commit 9bc16d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
9 changes: 2 additions & 7 deletions github/data_source_github_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ func dataSourceGithubRef() *schema.Resource {
Read: dataSourceGithubRefRead,

Schema: map[string]*schema.Schema{
"repository": {
"ref": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"branch": {
"repository": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Expand All @@ -28,10 +28,6 @@ func dataSourceGithubRef() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"ref": {
Type: schema.TypeString,
Computed: true,
},
"sha": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -60,7 +56,6 @@ func dataSourceGithubRefRead(d *schema.ResourceData, meta interface{}) error {

d.SetId(buildTwoPartID(repoName, ref))
d.Set("etag", resp.Header.Get("ETag"))
d.Set("ref", *refData.Ref)
d.Set("sha", *refData.Object.SHA)

return nil
Expand Down
5 changes: 2 additions & 3 deletions github/data_source_github_ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ func TestAccGithubRefDataSource(t *testing.T) {

randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)

t.Run("queries an existing ref without error", func(t *testing.T) {

t.Run("queries an existing branch ref without error", func(t *testing.T) {
config := fmt.Sprintf(`
resource "github_repository" "test" {
name = "tf-acc-test-%[1]s"
Expand All @@ -23,7 +22,7 @@ func TestAccGithubRefDataSource(t *testing.T) {
data "github_ref" "test" {
repository = github_repository.test.id
ref = "/heads/main"
ref = "heads/main"
}
`, randomID)

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/ref.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: |-
Get information about a repository ref.
---

# github\ref
# github_ref

Use this data source to retrieve information about a repository ref.

Expand Down

0 comments on commit 9bc16d5

Please sign in to comment.