Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility #441

Merged
merged 2 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func dataSourceGithubRepository() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"visibility": {
Type: schema.TypeString,
Computed: true,
},
"has_issues": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -143,6 +147,7 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
d.Set("description", repo.GetDescription())
d.Set("homepage_url", repo.GetHomepage())
d.Set("private", repo.GetPrivate())
d.Set("visibility", repo.GetVisibility())
d.Set("has_issues", repo.GetHasIssues())
d.Set("has_wiki", repo.GetHasWiki())
d.Set("allow_merge_commit", repo.GetAllowMergeCommit())
Expand Down
1 change: 1 addition & 0 deletions github/data_source_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func testRepoCheck() resource.TestCheckFunc {
resource.TestCheckResourceAttr("data.github_repository.test", "id", "test-repo"),
resource.TestCheckResourceAttr("data.github_repository.test", "name", "test-repo"),
resource.TestCheckResourceAttr("data.github_repository.test", "private", "false"),
resource.TestCheckResourceAttr("data.github_repository.test", "visibility", "public"),
resource.TestCheckResourceAttr("data.github_repository.test", "description", "Test description, used in GitHub Terraform provider acceptance test."),
resource.TestCheckResourceAttr("data.github_repository.test", "homepage_url", "http://www.example.com"),
resource.TestCheckResourceAttr("data.github_repository.test", "has_issues", "true"),
Expand Down
8 changes: 8 additions & 0 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ func resourceGithubRepository() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"visibility": {
Type: schema.TypeString,
Optional: true,
Default: "public",
ValidateFunc: validation.StringInSlice([]string{"public", "private", "internal"}, false),
},
"has_issues": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -179,6 +185,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
Description: github.String(d.Get("description").(string)),
Homepage: github.String(d.Get("homepage_url").(string)),
Private: github.Bool(d.Get("private").(bool)),
Visibility: github.String(d.Get("visibility").(string)),
HasDownloads: github.Bool(d.Get("has_downloads").(bool)),
HasIssues: github.Bool(d.Get("has_issues").(bool)),
HasProjects: github.Bool(d.Get("has_projects").(bool)),
Expand Down Expand Up @@ -303,6 +310,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("description", repo.GetDescription())
d.Set("homepage_url", repo.GetHomepage())
d.Set("private", repo.GetPrivate())
d.Set("visibility", repo.GetVisibility())
d.Set("has_issues", repo.GetHasIssues())
d.Set("has_projects", repo.GetHasProjects())
d.Set("has_wiki", repo.GetHasWiki())
Expand Down
39 changes: 31 additions & 8 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestAccGithubRepository_basic(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
HasIssues: true,
HasWiki: true,
IsTemplate: false,
Expand All @@ -93,6 +94,7 @@ func TestAccGithubRepository_basic(t *testing.T) {
Name: name,
Description: "Updated " + description,
Homepage: "http://example.com/",
Visibility: "public",
AllowMergeCommit: false,
AllowSquashMerge: true,
AllowRebaseMerge: true,
Expand Down Expand Up @@ -136,6 +138,7 @@ func TestAccGithubRepository_archive(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
HasIssues: true,
HasWiki: true,
AllowMergeCommit: true,
Expand Down Expand Up @@ -180,6 +183,7 @@ func TestAccGithubRepository_archiveUpdate(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
HasIssues: true,
HasWiki: true,
AllowMergeCommit: true,
Expand All @@ -199,6 +203,7 @@ func TestAccGithubRepository_archiveUpdate(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
HasIssues: true,
HasWiki: true,
AllowMergeCommit: true,
Expand Down Expand Up @@ -264,6 +269,7 @@ func TestAccGithubRepository_defaultBranch(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
HasIssues: true,
HasWiki: true,
AllowMergeCommit: true,
Expand All @@ -289,6 +295,7 @@ func TestAccGithubRepository_defaultBranch(t *testing.T) {
Name: name,
Description: "Updated " + description,
Homepage: "http://example.com/",
Visibility: "public",
AutoInit: true,
HasIssues: true,
HasWiki: true,
Expand Down Expand Up @@ -334,6 +341,7 @@ func TestAccGithubRepository_templates(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
HasIssues: true,
HasWiki: true,
AllowMergeCommit: true,
Expand Down Expand Up @@ -393,6 +401,7 @@ func TestAccGithubRepository_topics(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
Topics: []string{"topic2", "topic1"},

// non-zero defaults
Expand All @@ -411,6 +420,7 @@ func TestAccGithubRepository_topics(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
Topics: []string{"topic1", "topic2", "topic3"},

// non-zero defaults
Expand All @@ -429,6 +439,7 @@ func TestAccGithubRepository_topics(t *testing.T) {
Name: name,
Description: description,
Homepage: "http://example.com/",
Visibility: "public",
Topics: []string{},

// non-zero defaults
Expand Down Expand Up @@ -562,6 +573,7 @@ type testAccGithubRepositoryExpectedAttributes struct {
Description string
Homepage string
Private bool
Visibility string
HasDownloads bool
HasIssues bool
HasProjects bool
Expand Down Expand Up @@ -594,6 +606,9 @@ func testAccCheckGithubRepositoryAttributes(repo *github.Repository, want *testA
if private := repo.GetPrivate(); private != want.Private {
return fmt.Errorf("got private %#v; want %#v", private, want.Private)
}
if visibility := repo.GetVisibility(); visibility != want.Visibility {
return fmt.Errorf("got visibility %#v; want %#v", visibility, want.Visibility)
}
if hasIssues := repo.GetHasIssues(); hasIssues != want.HasIssues {
return fmt.Errorf("got has issues %#v; want %#v", hasIssues, want.HasIssues)
}
Expand Down Expand Up @@ -757,7 +772,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = true
has_wiki = true
Expand Down Expand Up @@ -789,7 +805,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = false
has_wiki = false
Expand All @@ -811,7 +828,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = true
has_wiki = true
Expand All @@ -833,7 +851,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = true
has_wiki = true
Expand All @@ -856,7 +875,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = true
has_wiki = true
Expand All @@ -879,7 +899,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = true
has_wiki = true
Expand Down Expand Up @@ -912,7 +933,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

has_issues = true
has_wiki = true
Expand All @@ -934,7 +956,8 @@ resource "github_repository" "foo" {

# So that acceptance tests can be run in a github organization
# with no billing
private = false
private = false
visibility = "public"

topics = [%s]
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ The following arguments are supported:

* `private` - Whether the repository is private.

* `visibility` - Whether the repository is public, private or internal.

* `has_issues` - Whether the repository has GitHub Issues enabled.

* `has_projects` - Whether the repository has the GitHub Projects enabled.
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ The following arguments are supported:

* `private` - (Optional) Set to `true` to create a private repository.
Repositories are created as public (e.g. open source) by default.

* `visibility` - (Optional) Can be `public` or `private`. If your organization is associated with an enterprise account
using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, visibility can also be `internal`. The `visibility`
parameter overrides the `private` parameter.

* `has_issues` - (Optional) Set to `true` to enable the GitHub Issues features
on the repository.
Expand Down