Skip to content

Commit

Permalink
feat: spaceID support offline package drop, cloud, ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
susanpann committed Oct 17, 2023
1 parent ed6db65 commit ca54a81
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 5 additions & 4 deletions octopusdeploy/resource_cloud_region_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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)
}
Expand Down
9 changes: 5 additions & 4 deletions octopusdeploy/resource_ssh_connection_deployment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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)
}
Expand Down

0 comments on commit ca54a81

Please sign in to comment.