From bae58134402fd050af10064c389afc84bad358ee Mon Sep 17 00:00:00 2001 From: Domenic Simone Date: Sat, 14 Oct 2023 22:22:48 +1030 Subject: [PATCH] feat: spaceID support channel --- octopusdeploy/data_source_channels.go | 3 ++- octopusdeploy/resource_channel.go | 9 +++++---- octopusdeploy/schema_channel.go | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/octopusdeploy/data_source_channels.go b/octopusdeploy/data_source_channels.go index 72bc93e41..cfa228483 100644 --- a/octopusdeploy/data_source_channels.go +++ b/octopusdeploy/data_source_channels.go @@ -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) } diff --git a/octopusdeploy/resource_channel.go b/octopusdeploy/resource_channel.go index 0401b043e..397f52001 100644 --- a/octopusdeploy/resource_channel.go +++ b/octopusdeploy/resource_channel.go @@ -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" @@ -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) } @@ -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) } @@ -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") } @@ -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) } diff --git a/octopusdeploy/schema_channel.go b/octopusdeploy/schema_channel.go index 473a87bfe..88aa0bda9 100644 --- a/octopusdeploy/schema_channel.go +++ b/octopusdeploy/schema_channel.go @@ -80,6 +80,7 @@ func getChannelDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } }