-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Terraform CLI and Framework Versions
Terraform v1.11.3 on darwin_arm64
github.com/hashicorp/terraform-plugin-framework-validators from the main branch
Terraform Plugin Framework Code
func (r *writeOnlyResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
...
"attr": schema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.PreferWriteOnlyAttribute(path.MatchRoot("attr_wo")),
stringvalidator.ExactlyOneOf(path.MatchRoot("attr_wo")),
},
},
"attr_wo": schema.StringAttribute{
Optional: true,
WriteOnly: true,
Validators: []validator.String{
stringvalidator.ExactlyOneOf(path.MatchRoot("attr")),
stringvalidator.AlsoRequires(path.MatchRoot("attr_wo_version")),
},
},
"has_attr_wo": schema.BoolAttribute{
Computed: true,
},
"attr_wo_version": schema.Int32Attribute{
Optional: true,
},
},
}
}
Terraform Configuration
terraform {
required_providers {
provs = {
source = "edu/provs"
}
}
}
provider "provs" {
path = "/var/tmp/custom_tf_provider"
}
resource "provs_write_only_test" "test" {
attr = "attr val"
}
Expected Behavior
Actual Behavior
The warning is not shown.
Steps to Reproduce
terraform plan
Logs
No response
Additional Information
This is due to the configuration of the validator. The client capabilities are not passed into the validator struct and the writeOnly capability is always false. Due to this, the validator is always skipped.
I already have a fix for this, but as suggested in the contribution guide, before opening a PR, I opened an issue first to understand if this behavior is actually intended for the moment or it is truly a bug.
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working