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(cloudian-sdk): add cloudian user #61

Merged
merged 5 commits into from
Dec 20, 2024
Merged

feat(cloudian-sdk): add cloudian user #61

merged 5 commits into from
Dec 20, 2024

Conversation

mariatsji
Copy link
Contributor

No description provided.

@mariatsji mariatsji requested review from tenstad and erikgb December 19, 2024 06:13
Comment on lines 215 to 223
url := client.baseURL + "/user"

// We can create an internal type for this json data later, if needed
jsonData, err := json.Marshal(toInternalUser(user))
if err != nil {
return fmt.Errorf("error marshaling JSON: %w", err)
}

req, err := client.newRequest(ctx, url, http.MethodPut, jsonData)
Copy link
Member

Choose a reason for hiding this comment

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

Move url to where it's used?

Suggested change
url := client.baseURL + "/user"
// We can create an internal type for this json data later, if needed
jsonData, err := json.Marshal(toInternalUser(user))
if err != nil {
return fmt.Errorf("error marshaling JSON: %w", err)
}
req, err := client.newRequest(ctx, url, http.MethodPut, jsonData)
// We can create an internal type for this json data later, if needed
jsonData, err := json.Marshal(toInternalUser(user))
if err != nil {
return fmt.Errorf("error marshaling JSON: %w", err)
}
url := client.baseURL + "/user"
req, err := client.newRequest(ctx, url, http.MethodPut, jsonData)

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 kinda like having it as the first var in every exported function. This way we can see at a glance what endpoint we invoke. But I don't have an issue with moving it down..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

come to think of it - the whole var could be inlined. gofmt wants no spaces between that +

return fmt.Errorf("error marshaling JSON: %w", err)
}

req, err := client.newRequest(ctx, client.baseURL+"/user", http.MethodPut, jsonData)
Copy link
Member

@erikgb erikgb Dec 20, 2024

Choose a reason for hiding this comment

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

Why isn't the base URL handled inside the client newRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would make sense, but perhaps in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

Supporting leaving it be for now and fixing in new PR

@mariatsji mariatsji merged commit b003f75 into main Dec 20, 2024
5 checks passed
@mariatsji mariatsji deleted the sdk-add-user branch December 20, 2024 08:53
@statnett-bot statnett-bot bot mentioned this pull request Jan 2, 2025
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.

3 participants