Skip to content

Commit

Permalink
Merge pull request integrations#138 from terraform-providers/b-topics…
Browse files Browse the repository at this point in the history
…-set

resource/github_repository: Avoid spurious diff for topics
  • Loading branch information
radeksimko authored Aug 17, 2018
2 parents 800792f + 18355c0 commit 6a335d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func resourceGithubRepository() *schema.Resource {
Default: false,
},
"topics": {
Type: schema.TypeList,
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
},
Expand Down Expand Up @@ -146,7 +146,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
LicenseTemplate: github.String(d.Get("license_template").(string)),
GitignoreTemplate: github.String(d.Get("gitignore_template").(string)),
Archived: github.Bool(d.Get("archived").(bool)),
Topics: expandStringList(d.Get("topics").([]interface{})),
Topics: expandStringList(d.Get("topics").(*schema.Set).List()),
}
}

Expand Down
5 changes: 4 additions & 1 deletion github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"sort"
"strings"
"testing"

Expand Down Expand Up @@ -321,7 +322,7 @@ func TestAccGithubRepository_topics(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Topics: []string{"topic1", "topic2"},
Topics: []string{"topic2", "topic1"},

// non-zero defaults
DefaultBranch: "master",
Expand Down Expand Up @@ -482,6 +483,8 @@ func testAccCheckGithubRepositoryAttributes(repo *github.Repository, want *testA
if len(want.Topics) != len(repo.Topics) {
return fmt.Errorf("got topics %#v; want %#v", repo.Topics, want.Topics)
}
sort.Strings(repo.Topics)
sort.Strings(want.Topics)
for i := range want.Topics {
if repo.Topics[i] != want.Topics[i] {
return fmt.Errorf("got topics %#v; want %#v", repo.Topics, want.Topics)
Expand Down

0 comments on commit 6a335d5

Please sign in to comment.