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

Add support for provider-defined functions #10013

Merged
merged 3 commits into from
Feb 22, 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
6 changes: 6 additions & 0 deletions mmv1/provider/terraform/common~compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
-%>
'<%= dir -%>/<%= fname.delete_suffix(".erb") -%>': 'third_party/terraform/framework_models/<%= fname -%>'
<% end -%>
<%
Dir["third_party/terraform/functions/*.go.erb"].each do |file_path|
SarahFrench marked this conversation as resolved.
Show resolved Hide resolved
fname = file_path.split('/')[-1]
-%>
'<%= dir -%>/functions/<%= fname.delete_suffix(".erb") -%>': 'third_party/terraform/functions/<%= fname -%>'
<% end -%>
<%
Dir["third_party/terraform/scripts/**/*.erb"].each do |file_path|
fname = file_path.delete_prefix("third_party/terraform/")
Expand Down
7 changes: 7 additions & 0 deletions mmv1/provider/terraform/common~copy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@
'<%= dir -%>/envvar/<%= fname -%>': 'third_party/terraform/envvar/<%= fname -%>'
<% end -%>

<%
Dir["third_party/terraform/functions/*.go"].each do |file_path|
fname = file_path.split('/')[-1]
-%>
'<%= dir -%>/functions/<%= fname -%>': 'third_party/terraform/functions/<%= fname -%>'
<% end -%>

<%
Dir["third_party/terraform/scripts/**/*.*"].each do |file_path|
next if file_path.end_with?('.erb')
Expand Down
1 change: 1 addition & 0 deletions mmv1/third_party/terraform/functions/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package functions
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/function"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/metaschema"
Expand All @@ -28,6 +29,7 @@ import (
// Ensure the implementation satisfies the expected interfaces
var (
_ provider.ProviderWithMetaSchema = &FrameworkProvider{}
_ provider.ProviderWithFunctions = &FrameworkProvider{}
)

// New is a helper function to simplify provider server and testing implementation.
Expand Down Expand Up @@ -294,5 +296,10 @@ func (p *FrameworkProvider) DataSources(_ context.Context) []func() datasource.D

// Resources defines the resources implemented in the provider.
func (p *FrameworkProvider) Resources(_ context.Context) []func() resource.Resource {
return nil
return nil
}

// Functions defines the provider functions implemented in the provider.
func (p *FrameworkProvider) Functions(_ context.Context) []func() function.Function {
return nil
}
Loading