-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat: add default values to attributes to documentation #65
Comments
While not official, you can achieve this with a workaround in your own provider. Check out https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/internal/provider/provider.go#L23-L48 for an example. |
@jacobbednarz Any chance that you have similar workaround for providers based on terraform-plugin-framework? |
nothing that exists today. it has been requested at hashicorp/terraform-plugin-framework#625 though if you'd like to track it. |
hi, let me put my 2 cents here. Here is a naive implementation for type stringDefault struct {
schema.StringAttribute
}
func (a stringDefault) GetDescription() string {
origDescription := a.StringAttribute.GetDescription()
if a.Default == nil {
return origDescription
}
resp := defaults.StringResponse{}
a.Default.DefaultString(context.TODO(), defaults.StringRequest{}, &resp)
origDescription = fmt.Sprintf(`%s Default: %s`, origDescription, resp.PlanValue)
return origDescription
} and then use this wrapper in func (s *bridgeVlan) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"string_attribute": stringDefault{
schema.StringAttribute{
Optional: true,
Computed: true,
Default: stringdefault.StaticString("default value"),
},
},
},
}
} |
Current behavior
Given the schema entry:
the rendered output is
Desired behavior
I'd like to have
Defaults to abc
in the generation as well as follows:Versions
v0.4.0
v2.6.1
The text was updated successfully, but these errors were encountered: