From e977561ca8784d490037f38a58b13f6cdb613c24 Mon Sep 17 00:00:00 2001 From: zry98 Date: Thu, 28 May 2026 02:05:49 +0200 Subject: [PATCH] feat: expose `plan_seats` and `plan_filled_seats` on `github_organization` data source --- docs/data-sources/organization.md | 2 ++ github/data_source_github_organization.go | 13 +++++++++++++ github/data_source_github_organization_test.go | 4 ++++ templates/data-sources/organization.md.tmpl | 2 ++ 4 files changed, 21 insertions(+) diff --git a/docs/data-sources/organization.md b/docs/data-sources/organization.md index def786ba5d..8262a595af 100644 --- a/docs/data-sources/organization.md +++ b/docs/data-sources/organization.md @@ -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: diff --git a/github/data_source_github_organization.go b/github/data_source_github_organization.go index 1800f5653f..5887d44c1c 100644 --- a/github/data_source_github_organization.go +++ b/github/data_source_github_organization.go @@ -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, @@ -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{ @@ -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 } diff --git a/github/data_source_github_organization_test.go b/github/data_source_github_organization_test.go index 5d8da74a42..616300f470 100644 --- a/github/data_source_github_organization_test.go +++ b/github/data_source_github_organization_test.go @@ -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"), @@ -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"), diff --git a/templates/data-sources/organization.md.tmpl b/templates/data-sources/organization.md.tmpl index bc36284217..da568241c8 100644 --- a/templates/data-sources/organization.md.tmpl +++ b/templates/data-sources/organization.md.tmpl @@ -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: