-
Notifications
You must be signed in to change notification settings - Fork 123
Support publishing experimental resources/datasources within the framework provider #1464
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ package provider | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| import ( | ||||||||||||||||||||||
| "context" | ||||||||||||||||||||||
| "os" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| "github.com/elastic/terraform-provider-elasticstack/internal/apm/agent_configuration" | ||||||||||||||||||||||
| "github.com/elastic/terraform-provider-elasticstack/internal/clients" | ||||||||||||||||||||||
|
|
@@ -42,6 +43,8 @@ import ( | |||||||||||||||||||||
| "github.com/hashicorp/terraform-plugin-framework/resource" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const IncludeExperimentalEnvVar = "TF_ELASTICSTACK_INCLUDE_EXPERIMENTAL" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Ensure the implementation satisfies the expected interfaces. | ||||||||||||||||||||||
| var ( | ||||||||||||||||||||||
| _ fwprovider.Provider = &Provider{} | ||||||||||||||||||||||
|
|
@@ -92,18 +95,26 @@ func (p *Provider) Configure(ctx context.Context, req fwprovider.ConfigureReques | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (p *Provider) DataSources(ctx context.Context) []func() datasource.DataSource { | ||||||||||||||||||||||
| return []func() datasource.DataSource{ | ||||||||||||||||||||||
| indices.NewDataSource, | ||||||||||||||||||||||
| spaces.NewDataSource, | ||||||||||||||||||||||
| export_saved_objects.NewDataSource, | ||||||||||||||||||||||
| enrollment_tokens.NewDataSource, | ||||||||||||||||||||||
| integration_ds.NewDataSource, | ||||||||||||||||||||||
| enrich.NewEnrichPolicyDataSource, | ||||||||||||||||||||||
| role_mapping.NewRoleMappingDataSource, | ||||||||||||||||||||||
| datasources := p.dataSources(ctx) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if os.Getenv(IncludeExperimentalEnvVar) == "true" { | ||||||||||||||||||||||
| datasources = append(datasources, p.experimentalDataSources(ctx)...) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return datasources | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (p *Provider) Resources(ctx context.Context) []func() resource.Resource { | ||||||||||||||||||||||
| resources := p.resources(ctx) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if os.Getenv(IncludeExperimentalEnvVar) == "true" { | ||||||||||||||||||||||
| resources = append(resources, p.experimentalResources(ctx)...) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return resources | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (p *Provider) resources(ctx context.Context) []func() resource.Resource { | ||||||||||||||||||||||
| return []func() resource.Resource{ | ||||||||||||||||||||||
| agent_configuration.NewAgentConfigurationResource, | ||||||||||||||||||||||
| func() resource.Resource { return &import_saved_objects.Resource{} }, | ||||||||||||||||||||||
|
|
@@ -132,3 +143,23 @@ func (p *Provider) Resources(ctx context.Context) []func() resource.Resource { | |||||||||||||||||||||
| datafeed_state.NewMLDatafeedStateResource, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
||||||||||||||||||||||
| // experimentalResources returns a list of experimental resource constructors. | |
| // | |
| // Experimental resources are features that are not yet considered stable and may change or be removed in future releases. | |
| // To add a new experimental resource, append its constructor to the returned slice. | |
| // These resources will only be included in the provider if the environment variable | |
| // TF_ELASTICSTACK_INCLUDE_EXPERIMENTAL is set to "true". | |
| // | |
| // This method helps contributors isolate experimental features from stable ones. |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dataSources method should include a comment explaining that it returns stable/non-experimental datasources, distinguishing it from experimentalDataSources.
| // dataSources returns the list of stable (non-experimental) datasources for the provider. | |
| // Experimental datasources are returned by experimentalDataSources. |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The experimentalDataSources method should include a comment explaining its purpose and when/how experimental datasources should be added. This helps future contributors understand where to add experimental features.
| // experimentalDataSources returns a list of experimental datasource constructors. | |
| // Experimental datasources are features that are not yet stable or officially supported. | |
| // To include experimental datasources in the provider, add their constructors to the returned slice. | |
| // These datasources will only be registered if the environment variable TF_ELASTICSTACK_INCLUDE_EXPERIMENTAL is set to "true". | |
| // Future contributors should add new experimental datasources here before they are promoted to stable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
resourcesmethod should include a comment explaining that it returns stable/non-experimental resources, distinguishing it fromexperimentalResources.