Skip to content

Commit

Permalink
Expose additional attributes for GitHub organizations. (#1850)
Browse files Browse the repository at this point in the history
Co-authored-by: Keegan Campbell <[email protected]>
  • Loading branch information
garnertb and kfcampbell authored Aug 24, 2023
1 parent d106f39 commit df4cf3c
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
90 changes: 90 additions & 0 deletions github/data_source_github_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,78 @@ func dataSourceGithubOrganization() *schema.Resource {
},
},
},
"default_repository_permission": {
Type: schema.TypeString,
Computed: true,
},
"members_can_create_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"two_factor_requirement_enabled": {
Type: schema.TypeBool,
Computed: true,
},
"members_allowed_repository_creation_type": {
Type: schema.TypeString,
Computed: true,
},
"members_can_create_public_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"members_can_create_private_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"members_can_create_internal_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"members_can_create_pages": {
Type: schema.TypeBool,
Computed: true,
},
"members_can_create_public_pages": {
Type: schema.TypeBool,
Computed: true,
},
"members_can_create_private_pages": {
Type: schema.TypeBool,
Computed: true,
},
"members_can_fork_private_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"web_commit_signoff_required": {
Type: schema.TypeBool,
Computed: true,
},
"advanced_security_enabled_for_new_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"dependabot_alerts_enabled_for_new_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"dependabot_security_updates_enabled_for_new_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"dependency_graph_enabled_for_new_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"secret_scanning_enabled_for_new_repositories": {
Type: schema.TypeBool,
Computed: true,
},
"secret_scanning_push_protection_enabled_for_new_repositories": {
Type: schema.TypeBool,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -162,6 +234,24 @@ func dataSourceGithubOrganizationRead(d *schema.ResourceData, meta interface{})
d.Set("repositories", repoList)
d.Set("members", members)
d.Set("users", users)
d.Set("two_factor_requirement_enabled", organization.GetTwoFactorRequirementEnabled())
d.Set("default_repository_permission", organization.GetDefaultRepoPermission())
d.Set("members_can_create_repositories", organization.GetMembersCanCreateRepos())
d.Set("members_allowed_repository_creation_type", organization.GetMembersAllowedRepositoryCreationType())
d.Set("members_can_create_public_repositories", organization.GetMembersCanCreatePublicRepos())
d.Set("members_can_create_private_repositories", organization.GetMembersCanCreatePrivateRepos())
d.Set("members_can_create_internal_repositories", organization.GetMembersCanCreateInternalRepos())
d.Set("members_can_fork_private_repositories", organization.GetMembersCanCreatePrivateRepos())
d.Set("web_commit_signoff_required", organization.GetWebCommitSignoffRequired())
d.Set("members_can_create_pages", organization.GetMembersCanCreatePages())
d.Set("members_can_create_public_pages", organization.GetMembersCanCreatePublicPages())
d.Set("members_can_create_private_pages", organization.GetMembersCanCreatePrivatePages())
d.Set("advanced_security_enabled_for_new_repositories", organization.GetAdvancedSecurityEnabledForNewRepos())
d.Set("dependabot_alerts_enabled_for_new_repositories", organization.GetDependabotAlertsEnabledForNewRepos())
d.Set("dependabot_security_updates_enabled_for_new_repositories", organization.GetDependabotSecurityUpdatesEnabledForNewRepos())
d.Set("dependency_graph_enabled_for_new_repositories", organization.GetDependencyGraphEnabledForNewRepos())
d.Set("secret_scanning_enabled_for_new_repositories", organization.GetSecretScanningEnabledForNewRepos())
d.Set("secret_scanning_push_protection_enabled_for_new_repositories", organization.GetSecretScanningPushProtectionEnabledForNewRepos())

return nil
}
18 changes: 18 additions & 0 deletions github/data_source_github_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ func TestAccGithubOrganizationDataSource(t *testing.T) {
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "repositories.#"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members.#"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "two_factor_requirement_enabled"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "default_repository_permission"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_allowed_repository_creation_type"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_public_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_private_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_internal_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_fork_private_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "web_commit_signoff_required"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_pages"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_public_pages"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members_can_create_private_pages"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "advanced_security_enabled_for_new_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "dependabot_alerts_enabled_for_new_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "dependabot_security_updates_enabled_for_new_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "dependency_graph_enabled_for_new_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "secret_scanning_enabled_for_new_repositories"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "secret_scanning_push_protection_enabled_for_new_repositories"),
)

testCase := func(t *testing.T, mode string) {
Expand Down
18 changes: 18 additions & 0 deletions website/docs/d/organization.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ data "github_organization" "example" {
* `login` - The members login
* `email` - Publicly available email
* `role` - Member role `ADMIN`, `MEMBER`
* `two_factor_requirement_enabled` - Whether two-factor authentication is required for all members of the organization.
* `default_repository_permission` - Default permission level members have for organization repositories.
* `members_allowed_repository_creation_type` - The type of repository allowed to be created by members of the organization. Can be one of `ALL`, `PUBLIC`, `PRIVATE`, `NONE`.
* `members_can_create_repositories` - Whether non-admin organization members can create repositories.
* `members_can_create_internal_repositories` - Whether organization members can create internal repositories.
* `members_can_create_private_repositories` - Whether organization members can create private repositories.
* `members_can_create_public_repositories` - Whether organization members can create public repositories.
* `members_can_create_pages` - Whether organization members can create pages sites.
* `members_can_create_public_pages` - Whether organization members can create public pages sites.
* `members_can_create_private_pages` - Whether organization members can create private pages sites.
* `members_can_fork_private_repositories` - Whether organization members can create private repository forks.
* `web_commit_signoff_required` - Whether organization members must sign all commits.
* `advanced_security_enabled_for_new_repositories` - Whether advanced security is enabled for new repositories.
* `dependabot_alerts_enabled_for_new_repositories` - Whether Dependabot alerts is automatically enabled for new repositories.
* `dependabot_security_updates_enabled_for_new_repositories` - Whether Dependabot security updates is automatically enabled for new repositories.
* `dependency_graph_enabled_for_new_repositories` - Whether dependency graph is automatically enabled for new repositories.
* `secret_scanning_enabled_for_new_repositories` - Whether secret scanning is automatically enabled for new repositories.
* `secret_scanning_push_protection_enabled_for_new_repositories` - Whether secret scanning push protection is automatically enabled for new repositories.

0 comments on commit df4cf3c

Please sign in to comment.