From dab3adef31983692bfb8502c35f4e0c568527ae8 Mon Sep 17 00:00:00 2001 From: Jarrett Spiker Date: Tue, 31 May 2022 14:59:09 -0400 Subject: [PATCH 1/2] Use filtering with tfe_agent_pool data source --- go.mod | 2 +- go.sum | 2 ++ tfe/data_source_agent_pool.go | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 7ae10523b..e12524951 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.1 // indirect github.com/hashicorp/go-slug v0.9.1 - github.com/hashicorp/go-tfe v1.4.0 + github.com/hashicorp/go-tfe v1.5.0 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce github.com/hashicorp/hcl/v2 v2.10.0 // indirect diff --git a/go.sum b/go.sum index c35817b93..859cef9b4 100644 --- a/go.sum +++ b/go.sum @@ -218,6 +218,8 @@ github.com/hashicorp/go-slug v0.9.1 h1:gYNVJ3t0jAWx8AT2eYZci3Xd7NBHyjayW9AR1DU4k github.com/hashicorp/go-slug v0.9.1/go.mod h1:Ib+IWBYfEfJGI1ZyXMGNbu2BU+aa3Dzu41RKLH301v4= github.com/hashicorp/go-tfe v1.4.0 h1:rMoQ2r1QppaglYsBdmdgFphipNTCkjTaO1oOLVj04Ec= github.com/hashicorp/go-tfe v1.4.0/go.mod h1:E8a90lC4kjU5Lc2c0D+SnWhUuyuoCIVm4Ewzv3jCD3A= +github.com/hashicorp/go-tfe v1.5.0 h1:MtABkqH2s6lRFl8HaGt0qESLGAyrmMAFfecsEm+13K8= +github.com/hashicorp/go-tfe v1.5.0/go.mod h1:E8a90lC4kjU5Lc2c0D+SnWhUuyuoCIVm4Ewzv3jCD3A= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= diff --git a/tfe/data_source_agent_pool.go b/tfe/data_source_agent_pool.go index 7e9764912..26128c746 100644 --- a/tfe/data_source_agent_pool.go +++ b/tfe/data_source_agent_pool.go @@ -33,7 +33,11 @@ func dataSourceTFEAgentPoolRead(d *schema.ResourceData, meta interface{}) error organization := d.Get("organization").(string) // Create an options struct. - options := tfe.AgentPoolListOptions{} + // to reduce the number of pages returned, search based on the name. TFE instances which + // do not support agent pool seach will just ignore the query parameter + options := tfe.AgentPoolListOptions{ + Query: name, + } for { l, err := tfeClient.AgentPools.List(ctx, organization, &options) From 0ef4ce5ec5e3ddb0ac5507296c95b1268ce9b420 Mon Sep 17 00:00:00 2001 From: Jarrett Spiker Date: Wed, 1 Jun 2022 11:06:28 -0400 Subject: [PATCH 2/2] Update changelog with #508 --- CHANGELOG.md | 5 +++++ tfe/data_source_agent_pool.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c78187514..57fbf0e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Unreleased + +ENHANCEMENTS: +* d/agent_pool: Improve efficiency of reading agent pool data when the target organization has more than 20 agent pools ([#508](https://github.com/hashicorp/terraform-provider-tfe/pull/508)) + ## 0.33.0 (July 8th, 2022) FEATURES: diff --git a/tfe/data_source_agent_pool.go b/tfe/data_source_agent_pool.go index 26128c746..2fdeb58d5 100644 --- a/tfe/data_source_agent_pool.go +++ b/tfe/data_source_agent_pool.go @@ -34,7 +34,7 @@ func dataSourceTFEAgentPoolRead(d *schema.ResourceData, meta interface{}) error // Create an options struct. // to reduce the number of pages returned, search based on the name. TFE instances which - // do not support agent pool seach will just ignore the query parameter + // do not support agent pool search will just ignore the query parameter options := tfe.AgentPoolListOptions{ Query: name, }