Skip to content

Commit

Permalink
feat: use new client for Get() for variables/project+groups/users+roles
Browse files Browse the repository at this point in the history
  • Loading branch information
mik-ky committed Oct 10, 2023
1 parent 7aac2f7 commit c0e1cac
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
5 changes: 4 additions & 1 deletion octopusdeploy/data_source_library_variable_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -27,8 +28,10 @@ func dataSourceLibraryVariableSetReadByName(ctx context.Context, d *schema.Resou
Take: d.Get("take").(int),
}

spaceID := d.Get("space_id").(string)

client := m.(*client.Client)
existingLibraryVariableSets, err := client.LibraryVariableSets.Get(query)
existingLibraryVariableSets, err := libraryvariablesets.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 3 additions & 1 deletion octopusdeploy/data_source_project_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ func dataSourceProjectGroupsRead(ctx context.Context, d *schema.ResourceData, m
Take: d.Get("take").(int),
}

spaceID := d.Get("space_id").(string)

client := m.(*client.Client)
existingProjectGroups, err := client.ProjectGroups.Get(query)
existingProjectGroups, err := projectgroups.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 3 additions & 1 deletion octopusdeploy/data_source_projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ func dataSourceProjectsRead(ctx context.Context, d *schema.ResourceData, m inter
Take: d.Get("take").(int),
}

spaceID := d.Get("space_id").(string)

client := m.(*client.Client)
existingProjects, err := client.Projects.Get(query)
existingProjects, err := projects.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
5 changes: 4 additions & 1 deletion octopusdeploy/data_source_script_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/scriptmodules"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/variables"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -27,8 +28,10 @@ func dataSourceScriptModulesRead(ctx context.Context, d *schema.ResourceData, m
Take: d.Get("take").(int),
}

spaceID := d.Get("space_id").(string)

client := m.(*client.Client)
existingScriptModules, err := client.ScriptModules.Get(query)
existingScriptModules, err := scriptmodules.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 3 additions & 1 deletion octopusdeploy/data_source_user_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ func dataSourceUserRolesRead(ctx context.Context, d *schema.ResourceData, meta i
Take: d.Get("take").(int),
}

spaceID := d.Get("space_id").(string)

client := meta.(*client.Client)
existingUserRoles, err := client.UserRoles.Get(query)
existingUserRoles, err := userroles.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 3 additions & 1 deletion octopusdeploy/data_source_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ func dataSourceUsersRead(ctx context.Context, d *schema.ResourceData, meta inter
Take: d.Get("take").(int),
}

spaceID := d.Get("space_id").(string)

client := meta.(*client.Client)
existingUsers, err := client.Users.Get(query)
existingUsers, err := users.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
10 changes: 5 additions & 5 deletions octopusdeploy/resource_library_variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariableset"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariablesets"
"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 @@ -30,7 +30,7 @@ func resourceLibraryVariableSetCreate(ctx context.Context, d *schema.ResourceDat

client := m.(*client.Client)

createdLibraryVariableSet, err := libraryvariableset.Add(client, libraryVariableSet)
createdLibraryVariableSet, err := libraryvariablesets.Add(client, libraryVariableSet)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -54,7 +54,7 @@ func resourceLibraryVariableSetDelete(ctx context.Context, d *schema.ResourceDat
}

client := m.(*client.Client)
err := libraryvariableset.DeleteByID(client, spaceID, d.Id())
err := libraryvariablesets.DeleteByID(client, spaceID, d.Id())
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -73,7 +73,7 @@ func resourceLibraryVariableSetRead(ctx context.Context, d *schema.ResourceData,
}

client := m.(*client.Client)
libraryVariableSet, err := libraryvariableset.GetByID(client, spaceID, d.Id())
libraryVariableSet, err := libraryvariablesets.GetByID(client, spaceID, d.Id())
if err != nil {
return errors.ProcessApiError(ctx, d, err, "library variable set")
}
Expand All @@ -92,7 +92,7 @@ func resourceLibraryVariableSetUpdate(ctx context.Context, d *schema.ResourceDat
libraryVariableSet := expandLibraryVariableSet(d)

client := m.(*client.Client)
updatedLibraryVariableSet, err := libraryvariableset.Update(client, libraryVariableSet)
updatedLibraryVariableSet, err := libraryvariablesets.Update(client, libraryVariableSet)
if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit c0e1cac

Please sign in to comment.