From 4c0f2278027c8e48423f8229b17a3795d3f2cda3 Mon Sep 17 00:00:00 2001 From: domenicsim1 <87625140+domenicsim1@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:39:18 +1000 Subject: [PATCH] fix: Implement filtering a worker pool by name (#537) (#786) fixes #536 Co-authored-by: Itai Spiegel --- octopusdeploy/data_source_worker_pools.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/octopusdeploy/data_source_worker_pools.go b/octopusdeploy/data_source_worker_pools.go index f685a2249..a6308406d 100644 --- a/octopusdeploy/data_source_worker_pools.go +++ b/octopusdeploy/data_source_worker_pools.go @@ -25,6 +25,7 @@ func dataSourceWorkerPoolsRead(ctx context.Context, d *schema.ResourceData, m in Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + name := d.Get("name").(string) client := m.(*client.Client) workerPools, err := workerpools.Get(client, d.Get("space_id").(string), query) @@ -39,6 +40,11 @@ func dataSourceWorkerPoolsRead(ctx context.Context, d *schema.ResourceData, m in return diag.FromErr(err) } + // There is no name filter on the WorkerPools endpoint in the Octopus API, + // so filter in-memory if the name field is specified + if name != "" && workerPoolResource.Name != name { + continue + } flattenedWorkerPools = append(flattenedWorkerPools, flattenWorkerPool(workerPoolResource)) }