-
Notifications
You must be signed in to change notification settings - Fork 416
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
add a client for VPP calls #20243
Conversation
There was a problem hiding this 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
} | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return fmt.Errorf("calling Apple VPP endpoint failed with status %d", resp.StatusCode) |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍎 🚀
server/mdm/apple/vpp/api.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm dumb, thanks!
No description provided.