Skip to content
Open
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
2 changes: 2 additions & 0 deletions docs/data-sources/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ data "github_organization" "example" {
- `login` - The organization account login
- `description` - The organization account description
- `plan` - The organization account plan name
- `plan_seats` - The total number of seats included in the organization's plan. `0` if the plan does not have a seat limit (e.g. `free` plan)
- `plan_filled_seats` - The number of seats currently filled in the organization's plan
- `repositories` - (`list`) A list of the full names of the repositories in the organization formatted as `owner/name` strings
- `members` - **Deprecated**: use `users` instead by replacing `github_organization.example.members` to `github_organization.example.users[*].login` which will give you the same value, expect this field to be removed in next major version
- `users` - (`list`) A list with the members of the organization with following fields:
Expand Down
13 changes: 13 additions & 0 deletions github/data_source_github_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ func dataSourceGithubOrganization() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"plan_seats": {
Type: schema.TypeInt,
Computed: true,
},
"plan_filled_seats": {
Type: schema.TypeInt,
Computed: true,
},
"repositories": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -162,9 +170,12 @@ func dataSourceGithubOrganizationRead(ctx context.Context, d *schema.ResourceDat
}

var planName string
var planSeats, planFilledSeats int

if plan := organization.GetPlan(); plan != nil {
planName = plan.GetName()
planSeats = plan.GetSeats()
planFilledSeats = plan.GetFilledSeats()
}

opts := &github.RepositoryListByOrgOptions{
Expand Down Expand Up @@ -274,6 +285,8 @@ func dataSourceGithubOrganizationRead(ctx context.Context, d *schema.ResourceDat
_ = d.Set("node_id", organization.GetNodeID())
_ = d.Set("description", organization.GetDescription())
_ = d.Set("plan", planName)
_ = d.Set("plan_seats", planSeats)
_ = d.Set("plan_filled_seats", planFilledSeats)

return nil
}
4 changes: 4 additions & 0 deletions github/data_source_github_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func TestAccGithubOrganizationDataSource(t *testing.T) {
resource.TestCheckResourceAttr("data.github_organization.test", "orgname", testAccConf.owner),
resource.TestCheckResourceAttrSet("data.github_organization.test", "node_id"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan_seats"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan_filled_seats"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "repositories.#"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "members.#"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "two_factor_requirement_enabled"),
Expand Down Expand Up @@ -119,6 +121,8 @@ func TestAccGithubOrganizationDataSource(t *testing.T) {
resource.TestCheckResourceAttr("data.github_organization.test", "orgname", testAccConf.owner),
resource.TestCheckResourceAttrSet("data.github_organization.test", "node_id"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan_seats"),
resource.TestCheckResourceAttrSet("data.github_organization.test", "plan_filled_seats"),
resource.TestCheckNoResourceAttr("data.github_organization.test", "repositories.#"),
resource.TestCheckNoResourceAttr("data.github_organization.test", "members.#"),
resource.TestCheckNoResourceAttr("data.github_organization.test", "two_factor_requirement_enabled"),
Expand Down
2 changes: 2 additions & 0 deletions templates/data-sources/organization.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Use this data source to retrieve basic information about a GitHub Organization.
- `login` - The organization account login
- `description` - The organization account description
- `plan` - The organization account plan name
- `plan_seats` - The total number of seats included in the organization's plan. `0` if the plan does not have a seat limit (e.g. `free` plan)
- `plan_filled_seats` - The number of seats currently filled in the organization's plan
- `repositories` - (`list`) A list of the full names of the repositories in the organization formatted as `owner/name` strings
- `members` - **Deprecated**: use `users` instead by replacing `github_organization.example.members` to `github_organization.example.users[*].login` which will give you the same value, expect this field to be removed in next major version
- `users` - (`list`) A list with the members of the organization with following fields:
Expand Down