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

Expose some internal structures for Crossplane provider #949

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

ydubreuil
Copy link
Member

This PR exposes some internal objects that are needed to build a Crossplane Elasticstack provider.

During initialization, the provider must instantiate a new ApiClient to use this Terraform provider as a library.

This is used like this in the Crossplane provider:

import (
...
	"github.com/elastic/terraform-provider-elasticstack/provider"
	"github.com/elastic/terraform-provider-elasticstack/xpprovider"
...
)

// TerraformSetupBuilder builds Terraform a terraform.SetupFn function which
// returns Terraform provider setup configuration
func TerraformSetupBuilder(version, providerSource, providerVersion string) terraform.SetupFn {
	return func(ctx context.Context, client client.Client, mg resource.Managed) (terraform.Setup, error) {
...
		apiClient, diag := xpprovider.NewApiClientFromFramework(ctx, fwpc, version)
		if diag.HasError() {
			return ps, errors.Errorf("%v", diag.Errors())
		}
		ps.Meta = apiClient
...

This patch is currently sitting in a branch from my fork that I use to build the Crossplane provider. It has been successfully used to create a PoC of a Crossplane Elasticstack provider.

@ydubreuil ydubreuil requested a review from tobio December 12, 2024 14:20
tobio
tobio previously approved these changes Dec 13, 2024
Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to add an entry to CHANGELOG.md for this?

@ydubreuil
Copy link
Member Author

@tobio I added an entry in the changelog

@tobio tobio merged commit 4d4ec04 into elastic:main Dec 17, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants