diff --git a/powerscale/helper/role_helper.go b/powerscale/helper/role_helper.go index 107c977..a93f468 100644 --- a/powerscale/helper/role_helper.go +++ b/powerscale/helper/role_helper.go @@ -38,6 +38,10 @@ func GetRoles(ctx context.Context, client *client.Client, state models.RoleDataS } roles, _, err := roleParams.Execute() + if err != nil { + return nil, err + } + // Pagination for roles.Resume != nil && state.RoleFilter != nil { roleParams = roleParams.Resume(*roles.Resume) diff --git a/powerscale/provider/s3_bucket_datasource_test.go b/powerscale/provider/s3_bucket_datasource_test.go index 447f0a4..91901c3 100644 --- a/powerscale/provider/s3_bucket_datasource_test.go +++ b/powerscale/provider/s3_bucket_datasource_test.go @@ -44,7 +44,7 @@ func TestAccS3BucketDatasource(t *testing.T) { }) } -func TestAccS3BucketsourceGetAll(t *testing.T) { +func TestAccS3BucketDatasourceGetAll(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -157,7 +157,11 @@ resource "powerscale_s3_bucket" "bucket_resource_test" { }] } -data "powerscale_s3_bucket" "bucket_datasource_test_all" {} +data "powerscale_s3_bucket" "bucket_datasource_test_all" { + depends_on = [ + powerscale_s3_bucket.bucket_resource_test + ] +} `, bucketName, bucketName) var S3BucketDatasourceConfig = fmt.Sprintf(` @@ -165,6 +169,7 @@ resource "powerscale_s3_bucket" "bucket_resource_test" { name = "%s" path = "/ifs/%s" create_path = true + zone = "System" acl = [{ grantee = { name = "Everyone" @@ -172,15 +177,13 @@ resource "powerscale_s3_bucket" "bucket_resource_test" { } permission = "FULL_CONTROL" }] + } data "powerscale_s3_bucket" "bucket_datasource_test" { filter { zone = "System" - owner = "root" + owner = powerscale_s3_bucket.bucket_resource_test.owner } - depends_on = [ - powerscale_s3_bucket.bucket_resource_test - ] } `, bucketName, bucketName) diff --git a/powerscale/provider/snapshot_restore_resource.go b/powerscale/provider/snapshot_restore_resource.go index 99adf49..55077bc 100644 --- a/powerscale/provider/snapshot_restore_resource.go +++ b/powerscale/provider/snapshot_restore_resource.go @@ -283,6 +283,9 @@ func (r *SnapshotRestoreResource) Update(ctx context.Context, request resource.U state, diags := helper.ManageSnapshotRestore(ctx, r.client, plan) response.Diagnostics.Append(diags...) + if response.Diagnostics.HasError() { + return + } // Save updated data into Terraform state response.Diagnostics.Append(response.State.Set(ctx, &state)...) diff --git a/powerscale/provider/user_data_source.go b/powerscale/provider/user_data_source.go index be5ed47..2958e8b 100644 --- a/powerscale/provider/user_data_source.go +++ b/powerscale/provider/user_data_source.go @@ -26,6 +26,7 @@ import ( "terraform-provider-powerscale/powerscale/helper" "terraform-provider-powerscale/powerscale/models" + "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -261,6 +262,9 @@ func (d *UserDataSource) Schema(ctx context.Context, req datasource.SchemaReques }, }, }, + Validators: []validator.List{ + listvalidator.SizeAtLeast(1), + }, }, "name_prefix": schema.StringAttribute{ Optional: true, diff --git a/powerscale/provider/user_group_data_source.go b/powerscale/provider/user_group_data_source.go index bc341ea..65edc9e 100644 --- a/powerscale/provider/user_group_data_source.go +++ b/powerscale/provider/user_group_data_source.go @@ -25,6 +25,7 @@ import ( "terraform-provider-powerscale/powerscale/helper" "terraform-provider-powerscale/powerscale/models" + "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -184,6 +185,9 @@ func (d *UserGroupDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, + Validators: []validator.List{ + listvalidator.SizeAtLeast(1), + }, }, "name_prefix": schema.StringAttribute{ Optional: true, diff --git a/powerscale/provider/user_group_datasource_test.go b/powerscale/provider/user_group_datasource_test.go index 8a8111c..731eb1d 100644 --- a/powerscale/provider/user_group_datasource_test.go +++ b/powerscale/provider/user_group_datasource_test.go @@ -113,7 +113,6 @@ func TestAccUserGroupDataSourceAll(t *testing.T) { var userGroupFilterDataSourceConfig = ` data "powerscale_user_group" "test" { filter { - names = [] cached = false # name_prefix = "" # domain = ""