Skip to content

Commit

Permalink
feat: spaceID support for tag sets
Browse files Browse the repository at this point in the history
  • Loading branch information
domenicsim1 committed Oct 12, 2023
1 parent 3d20b42 commit bb935d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion octopusdeploy/data_source_tag_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ func dataSourceTagSetsRead(ctx context.Context, d *schema.ResourceData, m interf
Skip: d.Get("skip").(int),
Take: d.Get("take").(int),
}
spaceID := d.Get("space_id").(string)

octopus := m.(*client.Client)
existingTagSets, err := octopus.TagSets.Get(query)
existingTagSets, err := tagsets.Get(octopus, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
11 changes: 6 additions & 5 deletions octopusdeploy/resource_tag_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tagsets"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand All @@ -30,7 +31,7 @@ func resourceTagSetCreate(ctx context.Context, d *schema.ResourceData, m interfa
log.Printf("[INFO] creating tag set: %#v", tagSet)

octopus := m.(*client.Client)
createdTagSet, err := octopus.TagSets.Add(tagSet)
createdTagSet, err := tagsets.Add(octopus, tagSet)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -49,7 +50,7 @@ func resourceTagSetDelete(ctx context.Context, d *schema.ResourceData, m interfa
log.Printf("[INFO] deleting tag set (%s)", d.Id())

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

Expand All @@ -63,7 +64,7 @@ func resourceTagSetRead(ctx context.Context, d *schema.ResourceData, m interface
tflog.Info(ctx, fmt.Sprintf("reading tag set (%s)", d.Id()))

octopus := m.(*client.Client)
tagSet, err := octopus.TagSets.GetByID(d.Id())
tagSet, err := tagsets.GetByID(octopus, d.Get("space_id").(string), d.Id())
if err != nil {
return errors.ProcessApiError(ctx, d, err, "tag set")
}
Expand All @@ -82,13 +83,13 @@ func resourceTagSetUpdate(ctx context.Context, d *schema.ResourceData, m interfa
log.Printf("[INFO] updating tag set: %#v", tagSet)

octopus := m.(*client.Client)
existingTagSet, err := octopus.TagSets.GetByID(d.Id())
existingTagSet, err := tagsets.GetByID(octopus, d.Get("space_id").(string), d.Id())
if err != nil {
return diag.FromErr(err)
}
tagSet.Tags = existingTagSet.Tags

updatedTagSet, err := octopus.TagSets.Update(tagSet)
updatedTagSet, err := tagsets.Update(octopus, tagSet)
if err != nil {
return diag.FromErr(err)
}
Expand Down
3 changes: 2 additions & 1 deletion octopusdeploy/schema_tag_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func getTagSetDataSchema() map[string]*schema.Schema {
Optional: true,
Type: schema.TypeList,
},
"take": getQueryTake(),
"take": getQueryTake(),
"space_id": getSpaceIDSchema(),
}
}

Expand Down

0 comments on commit bb935d2

Please sign in to comment.