Skip to content

Commit

Permalink
chore: workerpools
Browse files Browse the repository at this point in the history
  • Loading branch information
domenicsim1 committed Oct 11, 2023
1 parent ab652f0 commit e0ee897
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion octopusdeploy/data_source_worker_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
11 changes: 7 additions & 4 deletions octopusdeploy/resource_dynamic_worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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)
}
Expand Down
10 changes: 6 additions & 4 deletions octopusdeploy/resource_static_worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy/schema_worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).",
Expand Down

0 comments on commit e0ee897

Please sign in to comment.