Skip to content
10 changes: 9 additions & 1 deletion github/data_source_github_organization_team_sync_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ func dataSourceGithubOrganizationTeamSyncGroups() *schema.Resource {
ReadContext: dataSourceGithubOrganizationTeamSyncGroupsRead,

Schema: map[string]*schema.Schema{
"q": {
Comment thread
laughedelic marked this conversation as resolved.
Outdated
Type: schema.TypeString,
Optional: true,
Default: "",
Comment thread
laughedelic marked this conversation as resolved.
Outdated
Description: "Filters the results to return only those that begin with the specified value.",
},
"groups": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -42,7 +48,9 @@ func dataSourceGithubOrganizationTeamSyncGroupsRead(ctx context.Context, d *sche
client := meta.(*Owner).v3client

orgName := meta.(*Owner).name
query := d.Get("q").(string)
options := &github.ListIDPGroupsOptions{
Query: query,
ListCursorOptions: github.ListCursorOptions{
PerPage: maxPerPage,
},
Expand All @@ -65,7 +73,7 @@ func dataSourceGithubOrganizationTeamSyncGroupsRead(ctx context.Context, d *sche
options.Page = resp.NextPageToken
}

d.SetId(fmt.Sprintf("%s/github-org-team-sync-groups", orgName))
d.SetId(fmt.Sprintf("%s/github-org-team-sync-groups/%s", orgName, query))
Comment thread
laughedelic marked this conversation as resolved.
Outdated
if err := d.Set("groups", groups); err != nil {
return diag.Errorf("error setting groups: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ func TestAccGithubOrganizationTeamSyncGroupsDataSource_existing(t *testing.T) {
resource.TestCheckResourceAttrSet("data.github_organization_team_sync_groups.test", "groups.0.group_name"),
),
},
{
Config: `data "github_organization_team_sync_groups" "test" { q = "nonexistent_prefix_" }`,
Check: resource.ComposeTestCheckFunc(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ConfigStateChecks instead of Check

Copy link
Copy Markdown
Contributor Author

@laughedelic laughedelic Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ad18a98 + 49d1e01

resource.TestCheckResourceAttr("data.github_organization_team_sync_groups.test", "q", "nonexistent_prefix_"),
resource.TestCheckResourceAttr("data.github_organization_team_sync_groups.test", "groups.#", "0"),
),
},
},
})
}
8 changes: 7 additions & 1 deletion website/docs/d/organization_team_sync_groups.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ Use this data source to retrieve the identity provider (IdP) groups for an organ
## Example Usage

```hcl
data "github_organization_team_sync_groups" "test" {}
data "github_organization_team_sync_groups" "test" {
q = "myprefix_"
}
Comment thread
laughedelic marked this conversation as resolved.
```

## Argument Reference

* `q` - (Optional) Filters the results to return only those groups whose names begin with this value.

## Attributes Reference

* `groups` - An Array of GitHub Identity Provider Groups. Each `group` block consists of the fields documented below.
Expand Down