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

fix(client): expose Client struct for provider to use #11

Merged
1 commit merged into from
Mar 10, 2020

Conversation

mjunglw
Copy link
Contributor

@mjunglw mjunglw commented Mar 10, 2020

Basic requirement from Terraform-Provider-Lacework -> cast interface{} into your client

This is how we set it up on provider.go:

func providerConfigure(d *schema.ResourceData) (interface{}, error) {
	client, err := client.New(
		d.Get("account").(string),
		client.WithApiKeys(d.Get("key_id").(string), d.Get("secret").(string)),
	)
	if err != nil {
		return nil, err
	}

	return client, nil
}

Example:

func resourceLaceworkIntegrationAWSCFGCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*client.Client)
	client.GetIntegrations()
	return nil
}

I think exposing Client should be enough. I don't think we need to do anything extravagant:

type Client struct {
	account    string
	apiVersion string
	baseURL    *url.URL
	auth       *authConfig
	c          *http.Client
}

Thoughts? @afiunelw, @scottford-lw, @lwmobeent

@mjunglw mjunglw requested review from a user, lwmobeent and scottford-lw March 10, 2020 02:20
@ghost ghost assigned mjunglw Mar 10, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Yes, yes and yes!!

tenor-258459338

@ghost ghost merged commit c779ce9 into master Mar 10, 2020
@mjunglw mjunglw deleted the expose-client-public branch March 11, 2020 05:10
This pull request was closed.
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.

1 participant