From ca54a81f2f39ca89c23cb32e4858057b9065ef60 Mon Sep 17 00:00:00 2001 From: susanpann Date: Tue, 17 Oct 2023 17:05:22 +1000 Subject: [PATCH] feat: spaceID support offline package drop, cloud, ssh --- .../data_source_cloud_region_deployment_targets.go | 2 +- ...ata_source_offline_package_drop_deployment_targets.go | 2 +- .../data_source_ssh_connection_deployment_targets.go | 2 +- octopusdeploy/resource_cloud_region_deployment_target.go | 9 +++++---- .../resource_offline_package_drop_deployment_target.go | 9 +++++---- .../resource_ssh_connection_deployment_target.go | 9 +++++---- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/octopusdeploy/data_source_cloud_region_deployment_targets.go b/octopusdeploy/data_source_cloud_region_deployment_targets.go index b7631d430..894371290 100644 --- a/octopusdeploy/data_source_cloud_region_deployment_targets.go +++ b/octopusdeploy/data_source_cloud_region_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceCloudRegionDeploymentTargetsRead(ctx context.Context, d *schema.R } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_offline_package_drop_deployment_targets.go b/octopusdeploy/data_source_offline_package_drop_deployment_targets.go index 97517bae5..3e69b1ad1 100644 --- a/octopusdeploy/data_source_offline_package_drop_deployment_targets.go +++ b/octopusdeploy/data_source_offline_package_drop_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceOfflinePackageDropDeploymentTargetsRead(ctx context.Context, d *s } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/data_source_ssh_connection_deployment_targets.go b/octopusdeploy/data_source_ssh_connection_deployment_targets.go index 8be97de32..85934b8a0 100644 --- a/octopusdeploy/data_source_ssh_connection_deployment_targets.go +++ b/octopusdeploy/data_source_ssh_connection_deployment_targets.go @@ -38,7 +38,7 @@ func dataSourceSSHConnectionDeploymentTargetsRead(ctx context.Context, d *schema } client := m.(*client.Client) - existingDeploymentTargets, err := client.Machines.Get(query) + existingDeploymentTargets, err := machines.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_cloud_region_deployment_target.go b/octopusdeploy/resource_cloud_region_deployment_target.go index 2bf0babb0..922777a77 100644 --- a/octopusdeploy/resource_cloud_region_deployment_target.go +++ b/octopusdeploy/resource_cloud_region_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceCloudRegionDeploymentTargetCreate(ctx context.Context, d *schema.Re log.Printf("[INFO] creating cloud region deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceCloudRegionDeploymentTargetDelete(ctx context.Context, d *schema.Re log.Printf("[INFO] deleting cloud region deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceCloudRegionDeploymentTargetRead(ctx context.Context, d *schema.Reso log.Printf("[INFO] reading cloud region deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "cloud region deployment target") } @@ -79,7 +80,7 @@ func resourceCloudRegionDeploymentTargetUpdate(ctx context.Context, d *schema.Re deploymentTarget := expandCloudRegionDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, d.Get("space_id").(string), deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_offline_package_drop_deployment_target.go b/octopusdeploy/resource_offline_package_drop_deployment_target.go index 788ed2bf0..3c97c2854 100644 --- a/octopusdeploy/resource_offline_package_drop_deployment_target.go +++ b/octopusdeploy/resource_offline_package_drop_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceOfflinePackageDropDeploymentTargetCreate(ctx context.Context, d *sc log.Printf("[INFO] creating offline package drop deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceOfflinePackageDropDeploymentTargetDelete(ctx context.Context, d *sc log.Printf("[INFO] deleting offline package drop deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceOfflinePackageDropDeploymentTargetRead(ctx context.Context, d *sche log.Printf("[INFO] reading offline package drop deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "offline package drop deployment target") } @@ -79,7 +80,7 @@ func resourceOfflinePackageDropDeploymentTargetUpdate(ctx context.Context, d *sc deploymentTarget := expandOfflinePackageDropDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, d.Get("space_id").(string), deploymentTarget) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_ssh_connection_deployment_target.go b/octopusdeploy/resource_ssh_connection_deployment_target.go index 7e56c2640..0670b2ff5 100644 --- a/octopusdeploy/resource_ssh_connection_deployment_target.go +++ b/octopusdeploy/resource_ssh_connection_deployment_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceSSHConnectionDeploymentTargetCreate(ctx context.Context, d *schema. log.Printf("[INFO] creating SSH connection deployment target: %#v", deploymentTarget) client := m.(*client.Client) - createdDeploymentTarget, err := client.Machines.Add(deploymentTarget) + createdDeploymentTarget, err := machines.Add(client, deploymentTarget) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceSSHConnectionDeploymentTargetDelete(ctx context.Context, d *schema. log.Printf("[INFO] deleting SSH connection deployment target (%s)", d.Id()) client := m.(*client.Client) - if err := client.Machines.DeleteByID(d.Id()); err != nil { + if err := machines.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -61,7 +62,7 @@ func resourceSSHConnectionDeploymentTargetRead(ctx context.Context, d *schema.Re log.Printf("[INFO] reading SSH connection deployment target (%s)", d.Id()) client := m.(*client.Client) - deploymentTarget, err := client.Machines.GetByID(d.Id()) + deploymentTarget, err := machines.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "SSH connection deployment target") } @@ -79,7 +80,7 @@ func resourceSSHConnectionDeploymentTargetUpdate(ctx context.Context, d *schema. deploymentTarget := expandSSHConnectionDeploymentTarget(d) client := m.(*client.Client) - updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget) + updatedDeploymentTarget, err := machines.Update(client, d.Get("space_id").(string), deploymentTarget) if err != nil { return diag.FromErr(err) }