Skip to content

Commit

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

client := m.(*client.Client)
existingChannels, err := client.Channels.Get(query)
existingChannels, err := channels.Get(client, spaceID, query)
if err != nil {
return diag.FromErr(err)
}
Expand Down
9 changes: 5 additions & 4 deletions octopusdeploy/resource_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -32,7 +33,7 @@ func resourceChannelCreate(ctx context.Context, d *schema.ResourceData, m interf
tflog.Info(ctx, fmt.Sprintf("creating channel: %#v", channel))

client := m.(*client.Client)
createdChannel, err := client.Channels.Add(channel)
createdChannel, err := channels.Add(client, channel)
if err != nil {
return diag.FromErr(err)
}
Expand All @@ -54,7 +55,7 @@ func resourceChannelDelete(ctx context.Context, d *schema.ResourceData, m interf
tflog.Info(ctx, fmt.Sprintf("deleting channel (%s)", d.Id()))

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

Expand All @@ -68,7 +69,7 @@ func resourceChannelRead(ctx context.Context, d *schema.ResourceData, m interfac
tflog.Info(ctx, fmt.Sprintf("reading channel (%s)", d.Id()))

client := m.(*client.Client)
channel, err := client.Channels.GetByID(d.Id())
channel, err := channels.GetByID(client, d.Get("space_id").(string), d.Id())
if err != nil {
return errors.ProcessApiError(ctx, d, err, "channel")
}
Expand All @@ -89,7 +90,7 @@ func resourceChannelUpdate(ctx context.Context, d *schema.ResourceData, m interf

channel := expandChannel(d)
client := m.(*client.Client)
updatedChannel, err := client.Channels.Update(channel)
updatedChannel, err := channels.Update(client, channel)
if err != nil {
return diag.FromErr(err)
}
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy/schema_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func getChannelDataSchema() map[string]*schema.Schema {
"partial_name": getQueryPartialName(),
"skip": getQuerySkip(),
"take": getQueryTake(),
"space_id": getSpaceIDSchema(),
}
}

Expand Down

0 comments on commit bae5813

Please sign in to comment.