Skip to content

Commit

Permalink
feat: spaceID support for tenants
Browse files Browse the repository at this point in the history
  • Loading branch information
domenicsim1 committed Oct 12, 2023
1 parent bb935d2 commit dc2c8f5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions octopusdeploy/resource_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -28,7 +29,7 @@ func resourceTenantCreate(ctx context.Context, d *schema.ResourceData, m interfa
log.Printf("[INFO] creating tenant: %#v", tenant)

client := m.(*client.Client)
createdTenant, err := client.Tenants.Add(tenant)
createdTenant, err := tenants.Add(client, tenant)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -47,7 +48,7 @@ func resourceTenantDelete(ctx context.Context, d *schema.ResourceData, m interfa
log.Printf("[INFO] deleting tenant (%s)", d.Id())

client := m.(*client.Client)
if err := client.Tenants.DeleteByID(d.Id()); err != nil {
if err := tenants.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil {
return diag.FromErr(err)
}

Expand All @@ -60,7 +61,7 @@ func resourceTenantRead(ctx context.Context, d *schema.ResourceData, m interface
log.Printf("[INFO] reading tenant (%s)", d.Id())

client := m.(*client.Client)
tenant, err := client.Tenants.GetByID(d.Id())
tenant, err := tenants.GetByID(client, d.Get("space_id").(string), d.Id())
if err != nil {
return errors.ProcessApiError(ctx, d, err, "tenant")
}
Expand All @@ -78,7 +79,7 @@ func resourceTenantUpdate(ctx context.Context, d *schema.ResourceData, m interfa

tenant := expandTenant(d)
client := m.(*client.Client)
updatedTenant, err := client.Tenants.Update(tenant)
updatedTenant, err := tenants.Update(client, tenant)
if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit dc2c8f5

Please sign in to comment.