From e0ee8977f232272bf4d80e0b9de489dd3a272fc9 Mon Sep 17 00:00:00 2001 From: Domenic Simone Date: Thu, 12 Oct 2023 10:29:32 +1100 Subject: [PATCH] chore: workerpools --- octopusdeploy/data_source_worker_pools.go | 2 +- octopusdeploy/resource_dynamic_worker_pool.go | 11 +++++++---- octopusdeploy/resource_static_worker_pool.go | 10 ++++++---- octopusdeploy/schema_worker_pool.go | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/octopusdeploy/data_source_worker_pools.go b/octopusdeploy/data_source_worker_pools.go index 0c42e000b..f685a2249 100644 --- a/octopusdeploy/data_source_worker_pools.go +++ b/octopusdeploy/data_source_worker_pools.go @@ -27,7 +27,7 @@ func dataSourceWorkerPoolsRead(ctx context.Context, d *schema.ResourceData, m in } client := m.(*client.Client) - workerPools, err := client.WorkerPools.Get(query) + workerPools, err := workerpools.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_dynamic_worker_pool.go b/octopusdeploy/resource_dynamic_worker_pool.go index ff99aa48f..5b9678320 100644 --- a/octopusdeploy/resource_dynamic_worker_pool.go +++ b/octopusdeploy/resource_dynamic_worker_pool.go @@ -29,7 +29,7 @@ func resourceDynamicWorkerPoolCreate(ctx context.Context, d *schema.ResourceData log.Printf("[INFO] creating dynamic worker pool: %#v", workerPool) client := m.(*client.Client) - createdWorkerPool, err := client.WorkerPools.Add(workerPool) + createdWorkerPool, err := workerpools.Add(client, workerPool.SpaceID, workerPool) if err != nil { return diag.FromErr(err) } @@ -47,9 +47,10 @@ func resourceDynamicWorkerPoolCreate(ctx context.Context, d *schema.ResourceData func resourceDynamicWorkerPoolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting dynamic worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - if err := client.WorkerPools.DeleteByID(d.Id()); err != nil { + if err := workerpools.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -62,8 +63,9 @@ func resourceDynamicWorkerPoolDelete(ctx context.Context, d *schema.ResourceData func resourceDynamicWorkerPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading dynamic worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - workerPoolResource, err := client.WorkerPools.GetByID(d.Id()) + workerPoolResource, err := workerpools.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "dynamic worker pool") } @@ -81,9 +83,10 @@ func resourceDynamicWorkerPoolUpdate(ctx context.Context, d *schema.ResourceData workerPool := expandDynamicWorkerPool(d) log.Printf("[INFO] updating dynamic worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - updatedWorkerPool, err := client.WorkerPools.Update(workerPool) + updatedWorkerPool, err := workerpools.Update(client, spaceID, workerPool) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_static_worker_pool.go b/octopusdeploy/resource_static_worker_pool.go index 826c9e4f5..bf5d82d62 100644 --- a/octopusdeploy/resource_static_worker_pool.go +++ b/octopusdeploy/resource_static_worker_pool.go @@ -29,7 +29,7 @@ func resourceStaticWorkerPoolCreate(ctx context.Context, d *schema.ResourceData, log.Printf("[INFO] creating static worker pool: %#v", workerPool) client := m.(*client.Client) - createdWorkerPool, err := client.WorkerPools.Add(workerPool) + createdWorkerPool, err := workerpools.Add(client, workerPool.SpaceID, workerPool) if err != nil { return diag.FromErr(err) } @@ -47,9 +47,10 @@ func resourceStaticWorkerPoolCreate(ctx context.Context, d *schema.ResourceData, func resourceStaticWorkerPoolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] deleting static worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - if err := client.WorkerPools.DeleteByID(d.Id()); err != nil { + if err := workerpools.DeleteByID(client, spaceID, d.Id()); err != nil { return diag.FromErr(err) } @@ -61,9 +62,10 @@ func resourceStaticWorkerPoolDelete(ctx context.Context, d *schema.ResourceData, func resourceStaticWorkerPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { log.Printf("[INFO] reading static worker pool (%s)", d.Id()) + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - workerPoolResource, err := client.WorkerPools.GetByID(d.Id()) + workerPoolResource, err := workerpools.GetByID(client, spaceID, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "static worker pool") } @@ -83,7 +85,7 @@ func resourceStaticWorkerPoolUpdate(ctx context.Context, d *schema.ResourceData, log.Printf("[INFO] updating static worker pool (%s)", d.Id()) client := m.(*client.Client) - updatedWorkerPool, err := client.WorkerPools.Update(workerPool) + updatedWorkerPool, err := workerpools.Update(client, workerPool.SpaceID, workerPool) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/schema_worker_pool.go b/octopusdeploy/schema_worker_pool.go index e98036b65..2ac9f0438 100644 --- a/octopusdeploy/schema_worker_pool.go +++ b/octopusdeploy/schema_worker_pool.go @@ -34,6 +34,7 @@ func getWorkerPoolDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), "worker_pools": { Computed: true, Description: "A list of worker pools that match the filter(s).",