diff --git a/octopusdeploy/data_source_feeds.go b/octopusdeploy/data_source_feeds.go index 9245d397c..0368e1c30 100644 --- a/octopusdeploy/data_source_feeds.go +++ b/octopusdeploy/data_source_feeds.go @@ -26,9 +26,10 @@ func dataSourceFeedsRead(ctx context.Context, d *schema.ResourceData, m interfac Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingFeeds, err := client.Feeds.Get(query) + existingFeeds, err := feeds.Get(client, spaceID, query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_github_repository_feed.go b/octopusdeploy/resource_github_repository_feed.go index 7be418671..81d899745 100644 --- a/octopusdeploy/resource_github_repository_feed.go +++ b/octopusdeploy/resource_github_repository_feed.go @@ -33,7 +33,7 @@ func resourceGitHubRepositoryFeedCreate(ctx context.Context, d *schema.ResourceD tflog.Info(ctx, fmt.Sprintf("creating GitHub repository feed, %s", feed.GetName())) client := m.(*client.Client) - createdGitHubRepositoryFeed, err := client.Feeds.Add(feed) + createdGitHubRepositoryFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceGitHubRepositoryFeedDelete(ctx context.Context, d *schema.ResourceD tflog.Info(ctx, fmt.Sprintf("deleting GitHub repository feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceGitHubRepositoryFeedRead(ctx context.Context, d *schema.ResourceDat tflog.Info(ctx, fmt.Sprintf("reading GitHub repository feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "GitHub repository feed") } @@ -90,7 +90,7 @@ func resourceGitHubRepositoryFeedUpdate(ctx context.Context, d *schema.ResourceD tflog.Info(ctx, fmt.Sprintf("updating GitHub repository feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_helm_feed.go b/octopusdeploy/resource_helm_feed.go index 81d60029e..d05cefb68 100644 --- a/octopusdeploy/resource_helm_feed.go +++ b/octopusdeploy/resource_helm_feed.go @@ -33,7 +33,7 @@ func resourceHelmFeedCreate(ctx context.Context, d *schema.ResourceData, m inter tflog.Info(ctx, fmt.Sprintf("creating Helm feed, %s", feed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(feed) + createdFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceHelmFeedDelete(ctx context.Context, d *schema.ResourceData, m inter tflog.Info(ctx, fmt.Sprintf("deleting Helm feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceHelmFeedRead(ctx context.Context, d *schema.ResourceData, m interfa tflog.Info(ctx, fmt.Sprintf("reading Helm feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Helm feed") } @@ -90,7 +90,7 @@ func resourceHelmFeedUpdate(ctx context.Context, d *schema.ResourceData, m inter tflog.Info(ctx, fmt.Sprintf("updating Helm feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_maven_feed.go b/octopusdeploy/resource_maven_feed.go index 8b1d81d24..6483c0c0d 100644 --- a/octopusdeploy/resource_maven_feed.go +++ b/octopusdeploy/resource_maven_feed.go @@ -33,7 +33,7 @@ func resourceMavenFeedCreate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("creating Maven feed: %s", mavenFeed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(mavenFeed) + createdFeed, err := feeds.Add(client, mavenFeed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceMavenFeedDelete(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("deleting Maven feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceMavenFeedRead(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("reading Maven feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "Maven feed") } @@ -90,7 +90,7 @@ func resourceMavenFeedUpdate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("updating Maven feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_nuget_feed.go b/octopusdeploy/resource_nuget_feed.go index 97b9fea95..1aa53e699 100644 --- a/octopusdeploy/resource_nuget_feed.go +++ b/octopusdeploy/resource_nuget_feed.go @@ -33,7 +33,7 @@ func resourceNuGetFeedCreate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("creating NuGet feed: %s", feed.GetName())) client := m.(*client.Client) - createdFeed, err := client.Feeds.Add(feed) + createdFeed, err := feeds.Add(client, feed) if err != nil { return diag.FromErr(err) } @@ -52,7 +52,7 @@ func resourceNuGetFeedDelete(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("deleting NuGet feed (%s)", d.Id())) client := m.(*client.Client) - err := client.Feeds.DeleteByID(d.Id()) + err := feeds.DeleteByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return diag.FromErr(err) } @@ -67,7 +67,7 @@ func resourceNuGetFeedRead(ctx context.Context, d *schema.ResourceData, m interf tflog.Info(ctx, fmt.Sprintf("reading NuGet feed (%s)", d.Id())) client := m.(*client.Client) - feed, err := client.Feeds.GetByID(d.Id()) + feed, err := feeds.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "NuGet feed") } @@ -90,7 +90,7 @@ func resourceNuGetFeedUpdate(ctx context.Context, d *schema.ResourceData, m inte tflog.Info(ctx, fmt.Sprintf("updating NuGet feed (%s)", feed.GetID())) client := m.(*client.Client) - updatedFeed, err := client.Feeds.Update(feed) + updatedFeed, err := feeds.Update(client, feed) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/schema_feed.go b/octopusdeploy/schema_feed.go index 0d312fc7a..6c5c77337 100644 --- a/octopusdeploy/schema_feed.go +++ b/octopusdeploy/schema_feed.go @@ -48,6 +48,7 @@ func getFeedDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } } diff --git a/octopusdeploy/schema_helm_feed.go b/octopusdeploy/schema_helm_feed.go index 08870ccb9..1dc3d3478 100644 --- a/octopusdeploy/schema_helm_feed.go +++ b/octopusdeploy/schema_helm_feed.go @@ -36,6 +36,10 @@ func expandHelmFeed(d *schema.ResourceData) (*feeds.HelmFeed, error) { helmFeed.Username = v.(string) } + if v, ok := d.GetOk("space_id"); ok { + helmFeed.SpaceID = v.(string) + } + return helmFeed, nil } @@ -64,17 +68,17 @@ func getHelmFeedSchema() map[string]*schema.Schema { } } -func setHelmFeed(ctx context.Context, d *schema.ResourceData, mavenFeed *feeds.HelmFeed) error { - d.Set("feed_uri", mavenFeed.FeedURI) - d.Set("name", mavenFeed.Name) - d.Set("space_id", mavenFeed.SpaceID) - d.Set("username", mavenFeed.Username) +func setHelmFeed(ctx context.Context, d *schema.ResourceData, helmFeed *feeds.HelmFeed) error { + d.Set("feed_uri", helmFeed.FeedURI) + d.Set("name", helmFeed.Name) + d.Set("space_id", helmFeed.SpaceID) + d.Set("username", helmFeed.Username) - if err := d.Set("package_acquisition_location_options", mavenFeed.PackageAcquisitionLocationOptions); err != nil { + if err := d.Set("package_acquisition_location_options", helmFeed.PackageAcquisitionLocationOptions); err != nil { return fmt.Errorf("error setting package_acquisition_location_options: %s", err) } - d.SetId(mavenFeed.GetID()) + d.SetId(helmFeed.GetID()) return nil }