Skip to content

Commit

Permalink
feat!: Modify resource libraryvariableset to use new client
Browse files Browse the repository at this point in the history
  • Loading branch information
mik-ky committed Oct 5, 2023
1 parent 52148e2 commit e4435ef
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions octopusdeploy/resource_library_variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ func resourceLibraryVariableSetCreate(ctx context.Context, d *schema.ResourceDat
func resourceLibraryVariableSetDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Printf("[INFO] deleting library variable set (%s)", d.Id())

var spaceID string
if v, ok := d.GetOk("space_id"); ok {
spaceID = v.(string)
}

client := m.(*client.Client)
err := client.LibraryVariableSets.DeleteByID(d.Id())
err := libraryvariableset.DeleteByID(client, spaceID, d.Id())
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -62,8 +67,13 @@ func resourceLibraryVariableSetDelete(ctx context.Context, d *schema.ResourceDat
func resourceLibraryVariableSetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Printf("[INFO] reading library variable set (%s)", d.Id())

var spaceID string
if v, ok := d.GetOk("space_id"); ok {
spaceID = v.(string)
}

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

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

0 comments on commit e4435ef

Please sign in to comment.