Skip to content

Commit

Permalink
validate environment id list is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 committed Dec 4, 2024
1 parent 14ce0fb commit 7592d7b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions octopusdeploy_framework/resource_deployment_freeze_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func (d *deploymentFreezeProjectResource) Delete(ctx context.Context, req resour
return
}
}
tflog.Debug(ctx, fmt.Sprintf("before delete: %#v", freeze))

delete(freeze.ProjectEnvironmentScope, data.ProjectID.ValueString())
freeze, err = deploymentfreezes.Update(d.Client, freeze)
Expand All @@ -179,7 +178,6 @@ func mapEnvironmentIds(ids []string) basetypes.ListValue {
for i, envID := range ids {
environmentIDs[i] = types.StringValue(envID)
}

environmentIdList, _ := types.ListValue(types.StringType, environmentIDs)
return environmentIdList
}
2 changes: 2 additions & 0 deletions octopusdeploy_framework/resource_deployment_freeze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func testDeploymentFreezeBasic(localName string, freezeName string, start string
environment_ids = [ %s ]
}`, projectScopeLocalName, localName, projectLocalName, strings.Join(environmentScopes, ","))

fmt.Println(projectScopes)

return fmt.Sprintf(`
%s
Expand Down
5 changes: 5 additions & 0 deletions octopusdeploy_framework/schemas/deployment_freeze_project.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package schemas

import (
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)

Expand Down Expand Up @@ -39,6 +41,9 @@ func (d DeploymentFreezeProjectSchema) GetResourceSchema() resourceSchema.Schema
Description: "The environment IDs associated with this project deployment freeze scope.",
ElementType: types.StringType,
Optional: true,
Validators: []validator.List{
listvalidator.SizeAtLeast(1),
},
},
},
}
Expand Down

0 comments on commit 7592d7b

Please sign in to comment.