Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpaceID support for deployment targets #553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func dataSourceAzureCloudServiceDeploymentTargetsRead(ctx context.Context, d *sc
}

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 dataSourceAzureServiceFabricClusterDeploymentTargetsRead(ctx context.Contex
}

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 dataSourceAzureWebAppDeploymentTargetsRead(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 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 dataSourceKubernetesClusterDeploymentTargetsRead(ctx context.Context, d *sc
}

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 dataSourceListeningTentacleDeploymentTargetsRead(ctx context.Context, d *sc
}

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 dataSourcePollingTentacleDeploymentTargetsRead(ctx context.Context, d *sche
}

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
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 resourceAzureCloudServiceDeploymentTargetCreate(ctx context.Context, d *sch
log.Printf("[INFO] creating Azure cloud service 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 resourceAzureCloudServiceDeploymentTargetDelete(ctx context.Context, d *sch
log.Printf("[INFO] deleting Azure cloud service 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 resourceAzureCloudServiceDeploymentTargetRead(ctx context.Context, d *schem
log.Printf("[INFO] reading Azure cloud service 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, "Azure cloud service deployment target")
}
Expand All @@ -79,7 +80,7 @@ func resourceAzureCloudServiceDeploymentTargetUpdate(ctx context.Context, d *sch

deploymentTarget := expandAzureCloudServiceDeploymentTarget(d)
client := m.(*client.Client)
updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget)
updatedDeploymentTarget, err := machines.Update(client, 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 resourceAzureServiceFabricClusterDeploymentTargetCreate(ctx context.Context
log.Printf("[INFO] creating Azure service fabric cluster 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 resourceAzureServiceFabricClusterDeploymentTargetDelete(ctx context.Context
log.Printf("[INFO] deleting Azure service fabric cluster 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 resourceAzureServiceFabricClusterDeploymentTargetRead(ctx context.Context,
log.Printf("[INFO] reading Azure service fabric cluster 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, "Azure service fabric cluster deployment target")
}
Expand All @@ -79,7 +80,7 @@ func resourceAzureServiceFabricClusterDeploymentTargetUpdate(ctx context.Context

deploymentTarget := expandAzureServiceFabricClusterDeploymentTarget(d)
client := m.(*client.Client)
updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget)
updatedDeploymentTarget, err := machines.Update(client, deploymentTarget)
if err != nil {
return diag.FromErr(err)
}
Expand Down
9 changes: 5 additions & 4 deletions octopusdeploy/resource_azure_web_app_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 resourceAzureWebAppDeploymentTargetCreate(ctx context.Context, d *schema.Re
log.Printf("[INFO] creating Azure web app 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 resourceAzureWebAppDeploymentTargetDelete(ctx context.Context, d *schema.Re
log.Printf("[INFO] deleting Azure web app 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 resourceAzureWebAppDeploymentTargetRead(ctx context.Context, d *schema.Reso
log.Printf("[INFO] reading Azure web app 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, "Azure web app deployment target")
}
Expand All @@ -79,7 +80,7 @@ func resourceAzureWebAppDeploymentTargetUpdate(ctx context.Context, d *schema.Re

deploymentTarget := expandAzureWebAppDeploymentTarget(d)
client := m.(*client.Client)
updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget)
updatedDeploymentTarget, err := machines.Update(client, deploymentTarget)
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, 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 resourceKubernetesClusterDeploymentTargetCreate(ctx context.Context, d *sch
log.Printf("[INFO] creating Kubernetes cluster 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 resourceKubernetesClusterDeploymentTargetDelete(ctx context.Context, d *sch
log.Printf("[INFO] deleting Kubernetes cluster 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 resourceKubernetesClusterDeploymentTargetRead(ctx context.Context, d *schem
log.Printf("[INFO] reading Kubernetes cluster 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, "Kubernetes cluster deployment target")
}
Expand All @@ -79,7 +80,7 @@ func resourceKubernetesClusterDeploymentTargetUpdate(ctx context.Context, d *sch

deploymentTarget := expandKubernetesClusterDeploymentTarget(d)
client := m.(*client.Client)
updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget)
updatedDeploymentTarget, err := machines.Update(client, 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 resourceListeningTentacleDeploymentTargetCreate(ctx context.Context, d *sch
log.Printf("[INFO] creating listening tentacle 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 resourceListeningTentacleDeploymentTargetDelete(ctx context.Context, d *sch
log.Printf("[INFO] deleting listening tentacle 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 resourceListeningTentacleDeploymentTargetRead(ctx context.Context, d *schem
log.Printf("[INFO] reading listening tentacle 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, "listening tentacle deployment target")
}
Expand All @@ -79,7 +80,7 @@ func resourceListeningTentacleDeploymentTargetUpdate(ctx context.Context, d *sch

deploymentTarget := expandListeningTentacleDeploymentTarget(d)
client := m.(*client.Client)
updatedDeploymentTarget, err := client.Machines.Update(deploymentTarget)
updatedDeploymentTarget, err := machines.Update(client, 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, deploymentTarget)
if err != nil {
return diag.FromErr(err)
}
Expand Down
Loading
Loading