Skip to content

Commit

Permalink
Adding validators to user and usergroup datasources (#255)
Browse files Browse the repository at this point in the history
* Adding validators to user and usergroup datasources

* Fixing S3 bucket ds tests
  • Loading branch information
rounak-adhikary authored Nov 20, 2024
1 parent 1aced9d commit 14447c2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
15 changes: 9 additions & 6 deletions powerscale/provider/s3_bucket_datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -157,30 +157,33 @@ 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(`
resource "powerscale_s3_bucket" "bucket_resource_test" {
name = "%s"
path = "/ifs/%s"
create_path = true
zone = "System"
acl = [{
grantee = {
name = "Everyone"
type = "wellknown"
}
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)
4 changes: 4 additions & 0 deletions powerscale/provider/user_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions powerscale/provider/user_group_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion powerscale/provider/user_group_datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func TestAccUserGroupDataSourceAll(t *testing.T) {
var userGroupFilterDataSourceConfig = `
data "powerscale_user_group" "test" {
filter {
names = []
cached = false
# name_prefix = ""
# domain = ""
Expand Down

0 comments on commit 14447c2

Please sign in to comment.