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

Use already initialized API client in GetIDFn #464

Open
denniskniep opened this issue Jan 30, 2025 · 0 comments
Open

Use already initialized API client in GetIDFn #464

denniskniep opened this issue Jan 30, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@denniskniep
Copy link

denniskniep commented Jan 30, 2025

Feature Request
Can we add to the parameter terraformProviderConfig of the GetIDFn the meta value? So that ts.Map(), which is passed into the GetIDFn returns also the Meta property?

// GetIDFn returns the ID to be used in TF State file, i.e. "id" field in
// terraform.tfstate.
type GetIDFn func(ctx context.Context, externalName string, parameters map[string]any, terraformProviderConfig map[string]any) (string, error)

tfID, err := cfg.ExternalName.GetIDFn(ctx, externalName, params, ts.Map())
if err != nil {
return nil, errors.Wrap(err, "cannot get ID")
}

func (s Setup) Map() map[string]any {
return map[string]any{
"version": s.Version,
"requirement": map[string]string{
"source": s.Requirement.Source,
"version": s.Requirement.Version,
},
"configuration": s.Configuration,
"client_metadata": s.ClientMetadata,
}
}

Meta any

UseCase:
It is necessary to execute an request via the API client during retrieving the Id via GetIDFn. It would make sense to use the already initialized API client instead of creating a fresh one.

@denniskniep denniskniep added the enhancement New feature or request label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant