diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index 688180c256..0a320a8d37 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -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, }, @@ -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()), } } diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index cf9f521379..1884a351fa 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "sort" "strings" "testing" @@ -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", @@ -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)