Skip to content

Commit

Permalink
Fixes #556 (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson authored Oct 20, 2023
1 parent 19fa565 commit faf3715
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions octopusdeploy/resource_deployment_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func getDeploymentProcessSchema() map[string]*schema.Schema {

func resourceDeploymentProcessCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*client.Client)
deploymentProcess := expandDeploymentProcess(ctx, d, client)
deploymentProcess, err := expandDeploymentProcess(ctx, d, client)

if err != nil {
return diag.FromErr(err)
}

log.Printf("[INFO] creating deployment process: %#v", deploymentProcess)

Expand Down Expand Up @@ -195,7 +199,12 @@ func resourceDeploymentProcessUpdate(ctx context.Context, d *schema.ResourceData
log.Printf("[INFO] updating deployment process (%s)", d.Id())

client := m.(*client.Client)
deploymentProcess := expandDeploymentProcess(ctx, d, client)
deploymentProcess, err := expandDeploymentProcess(ctx, d, client)

if err != nil {
return diag.FromErr(err)
}

current, err := client.DeploymentProcesses.GetByID(d.Id())
if err != nil {
r, _ := regexp.Compile(`Projects-\d+`)
Expand Down
6 changes: 3 additions & 3 deletions octopusdeploy/schema_deployment_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func expandDeploymentProcess(ctx context.Context, d *schema.ResourceData, client *client.Client) *deployments.DeploymentProcess {
func expandDeploymentProcess(ctx context.Context, d *schema.ResourceData, client *client.Client) (*deployments.DeploymentProcess, error) {
projectID := d.Get("project_id").(string)
deploymentProcess := deployments.NewDeploymentProcess(projectID)
deploymentProcess.ID = d.Id()
Expand All @@ -20,7 +20,7 @@ func expandDeploymentProcess(ctx context.Context, d *schema.ResourceData, client
} else {
project, err := client.Projects.GetByID(projectID)
if err != nil {
return nil
return nil, err
}

if project.PersistenceSettings != nil && project.PersistenceSettings.Type() == projects.PersistenceSettingsTypeVersionControlled {
Expand Down Expand Up @@ -48,7 +48,7 @@ func expandDeploymentProcess(ctx context.Context, d *schema.ResourceData, client
}
}

return deploymentProcess
return deploymentProcess, nil
}

func setDeploymentProcess(ctx context.Context, d *schema.ResourceData, deploymentProcess *deployments.DeploymentProcess) error {
Expand Down

0 comments on commit faf3715

Please sign in to comment.