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

Adding validators to user and usergroup datasources #255

Merged
merged 4 commits into from
Nov 20, 2024
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
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
Loading