From 7aac2f7d3a3ec97ebf2d6c66709898c0ccefa22f Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Wed, 11 Oct 2023 09:09:45 +1300 Subject: [PATCH] feat: users and userroles to use new client --- octopusdeploy/resource_user.go | 9 +++++---- octopusdeploy/resource_user_role.go | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/octopusdeploy/resource_user.go b/octopusdeploy/resource_user.go index fb73069c1..0a7a5f599 100644 --- a/octopusdeploy/resource_user.go +++ b/octopusdeploy/resource_user.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users" "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" @@ -28,7 +29,7 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface log.Printf("[DEBUG] creating user") client := m.(*client.Client) - createdUser, err := client.Users.Add(user) + createdUser, err := users.Add(client, user) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceUserDelete(ctx context.Context, d *schema.ResourceData, m interface log.Printf("[INFO] deleting user (%s)", d.Id()) client := m.(*client.Client) - if err := client.Users.DeleteByID(d.Id()); err != nil { + if err := users.DeleteByID(client, d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceUserRead(ctx context.Context, d *schema.ResourceData, m interface{} log.Printf("[INFO] reading user (%s)", d.Id()) client := m.(*client.Client) - user, err := client.Users.GetByID(d.Id()) + user, err := users.GetByID(client, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "user") } @@ -79,7 +80,7 @@ func resourceUserUpdate(ctx context.Context, d *schema.ResourceData, m interface user := expandUser(d) client := m.(*client.Client) - updatedUser, err := client.Users.Update(user) + updatedUser, err := users.Update(client, user) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_user_role.go b/octopusdeploy/resource_user_role.go index 447a77e6a..d1cc14780 100644 --- a/octopusdeploy/resource_user_role.go +++ b/octopusdeploy/resource_user_role.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/userroles" "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" @@ -28,7 +29,7 @@ func resourceUserRoleCreate(ctx context.Context, d *schema.ResourceData, m inter log.Printf("[INFO] creating user role: %#v", userRole) client := m.(*client.Client) - createdUserRole, err := client.UserRoles.Add(userRole) + createdUserRole, err := userroles.Add(client, userRole) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceUserRoleDelete(ctx context.Context, d *schema.ResourceData, m inter log.Printf("[INFO] deleting user role (%s)", d.Id()) client := m.(*client.Client) - if err := client.UserRoles.DeleteByID(d.Id()); err != nil { + if err := userroles.DeleteByID(client, d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceUserRoleRead(ctx context.Context, d *schema.ResourceData, m interfa log.Printf("[INFO] reading user role (%s)", d.Id()) client := m.(*client.Client) - userRole, err := client.UserRoles.GetByID(d.Id()) + userRole, err := userroles.GetByID(client, d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "user role") } @@ -79,7 +80,7 @@ func resourceUserRoleUpdate(ctx context.Context, d *schema.ResourceData, m inter userRole := expandUserRole(d) client := m.(*client.Client) - updatedUserRole, err := client.UserRoles.Update(userRole) + updatedUserRole, err := userroles.Update(client, userRole) if err != nil { return diag.FromErr(err) }