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

add a client for VPP calls #20243

Merged
merged 8 commits into from
Jul 8, 2024
Merged

add a client for VPP calls #20243

merged 8 commits into from
Jul 8, 2024

Conversation

roperzh
Copy link
Member

@roperzh roperzh commented Jul 5, 2024

No description provided.

@roperzh roperzh marked this pull request as ready for review July 5, 2024 23:18
@roperzh roperzh requested a review from gillespi314 as a code owner July 5, 2024 23:18
@roperzh roperzh requested a review from a team as a code owner July 7, 2024 15:29
Copy link
Member

@mna mna left a comment

Choose a reason for hiding this comment

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

Nice! Just some very minor comments, feel free to ignore.

server/mdm/apple/vpp/api.go Outdated Show resolved Hide resolved
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("calling Apple VPP endpoint failed with status %d", resp.StatusCode)
Copy link
Member

Choose a reason for hiding this comment

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

Not critical (especially since the Apple API appears to not use non-200 statuses 😢 ), but it's often useful for debugging purpose to add the response's body when the status is not success (ideally with a limited reader to prevent reading too much).

Copy link
Member Author

Choose a reason for hiding this comment

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

great idea, thanks! I pushed f002dd4 addressing this.

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
}

func getBaseURL() string {
devURL := os.Getenv("FLEET_DEV_VPP_URL")
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

Copy link
Contributor

@jahzielv jahzielv left a comment

Choose a reason for hiding this comment

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

🍎 🚀

@@ -201,7 +201,14 @@ func do[T any](req *http.Request, token string, dest *T) error {
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("calling Apple VPP endpoint failed with status %d", resp.StatusCode)
// use an io.LimitedReader to read only a limited amount of the
// response body for logging purposes
Copy link
Member

Choose a reason for hiding this comment

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

Oh sorry, I didn't realize you already had the body read in full, in that case you could just check the len and limit it to 1024 bytes without using a reader. No big deal either way, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wondering about that! sounds good! changes pushed

Copy link
Member

Choose a reason for hiding this comment

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

LGTM, you should remove the comment above though ^

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm dumb, thanks!

@roperzh roperzh merged commit e9dba54 into feat-vpp-apps-18867 Jul 8, 2024
15 checks passed
@roperzh roperzh deleted the vpp-client branch July 8, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants