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

Feat/initial #2

Merged
merged 18 commits into from
Feb 21, 2024
Merged

Feat/initial #2

merged 18 commits into from
Feb 21, 2024

Conversation

vlnevyhosteny
Copy link
Contributor

No description provided.

@vlnevyhosteny vlnevyhosteny requested a review from ggreer February 15, 2024 20:06
@vlnevyhosteny vlnevyhosteny self-assigned this Feb 15, 2024

func New(accessToken string, region Region, httpClient *http.Client) *Client {
baseUrl := BaseUrl
if region == EURegion {
Copy link

Choose a reason for hiding this comment

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

nit, style-ism: i'd tend to write this as a switch (region) { ... } with a default that returns an erroor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in f77aee6

return req, nil
}

func (c *Client) do(req *http.Request, response ...interface{}) (*http.Response, error) {
Copy link

Choose a reason for hiding this comment

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

should this be a vararg collector (.... -> []) or just a single object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason why I use response ...interface{} is to have option use do without response body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps this is a much better solution: ConductorOne/baton-sdk#104 . Also, it makes sense to move to SDK since I use it in every other connector.


var resources []*v2.Resource
for _, integration := range response {
integration := integration
Copy link

Choose a reason for hiding this comment

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

no-op assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


var resources []*v2.Resource
for _, user := range response {
user := user
Copy link

Choose a reason for hiding this comment

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

nit: noop assignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't to prevent linter error:

pkg/connector/users.go:59:38: G601: Implicit memory aliasing in for loop. (gosec)
                resource, err := userResource(ctx, &user)

Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI go v1.22 fixes this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, gonna fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that but it looks like that golangci-lint use still the old rules https://stackoverflow.com/a/68247837 . I added error suppression comment.

Copy link
Contributor

@ggreer ggreer left a comment

Choose a reason for hiding this comment

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

Just a few small changes and then I think this is good to go.

pkg/connector/integrations.go Outdated Show resolved Hide resolved
pkg/connector/integrations.go Outdated Show resolved Hide resolved
pkg/connector/roles.go Show resolved Hide resolved
pkg/connector/connector.go Outdated Show resolved Hide resolved
pkg/connector/integrations.go Outdated Show resolved Hide resolved
@vlnevyhosteny vlnevyhosteny requested a review from ggreer February 21, 2024 09:25
@vlnevyhosteny vlnevyhosteny merged commit 73a8633 into main Feb 21, 2024
2 checks passed
@vlnevyhosteny vlnevyhosteny deleted the feat/initial branch February 21, 2024 18:19
@vlnevyhosteny vlnevyhosteny linked an issue Feb 21, 2024 that may be closed by this pull request
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.

baton-celigo
3 participants