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

Default values in provider functions #35375

Closed
kimdre opened this issue Jun 23, 2024 · 1 comment
Closed

Default values in provider functions #35375

kimdre opened this issue Jun 23, 2024 · 1 comment
Labels
enhancement new new issue not yet triaged

Comments

@kimdre
Copy link

kimdre commented Jun 23, 2024

Terraform Version

Terraform v1.8.5
on linux_amd64

Use Cases

Omit arguments in provider functions when the default is already the correct value.

e.g. My provider function has a filename argument that often is the same value: .env

Attempted Solutions

Setting defaults to provider functions in the Plugin Framework does not work or I was not able to.

Proposal

Provide a additional Default key to the function definition to specify a default value to a parameter:

func (r ExampleFunction) Definition(_ context.Context, _ function.DefinitionRequest, resp *function.DefinitionResponse) {
	resp.Definition = function.Definition{
		Summary: "Example function",
		MarkdownDescription: "Foo bar",
		Parameters: []function.Parameter{
			function.StringParameter{
				Name: "filename",
				MarkdownDescription: "Path to the dotenv file",
				// Add this 
				Default: ".env",
			},
		},
		Return: function.StringReturn{},
	}
}

References

No response

@kimdre kimdre added enhancement new new issue not yet triaged labels Jun 23, 2024
@jbardin
Copy link
Member

jbardin commented Jun 24, 2024

Hi @kimdre,

The default values would be handled by the wrapper provided in the plugin framework, not by Terraform. Terraform is only concerned with making the RPC call, and does not know about the actual function implementation. You can find the framework project repository here: https://github.com/hashicorp/terraform-plugin-framework

Thanks!

@jbardin jbardin closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants