-
Notifications
You must be signed in to change notification settings - Fork 4
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: Add methods blink, update and device to supervisor v1 struct #79
base: master
Are you sure you want to change the base?
feat: Add methods blink, update and device to supervisor v1 struct #79
Conversation
a9bf476
to
3589bdb
Compare
@@ -29,22 +30,104 @@ func (s *SupervisorV1Service) Reboot(ctx context.Context, force bool) error { | |||
&request{Force: force}, | |||
) | |||
if err != nil { | |||
return fmt.Errorf("unable to create restart service request: %v", err) | |||
return fmt.Errorf("unable to create restart service request: %w", err) |
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.
What's the reason for this change? As this is an open source library, I'd be reluctant to exposing the underlying implementation error without a good reason.
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 can understand that though we probably want to respond differently when we receive an internal server error versus a bad request response. If we can wrap this error here, on a higher level we can decide whether to do a retry or ask an operator for help.
supervisorv1.go
Outdated
return fmt.Errorf("unable to create blink request: %w", err) | ||
} | ||
|
||
err = s.client.Do(req, io.Discard) |
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.
We should be able to switch to (also in other places)
err = s.client.Do(req, io.Discard) | |
err = s.client.Do(req, nil) |
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.
Fair enough
supervisorv1.go
Outdated
response := new(SupervisorV1DeviceResponse) | ||
|
||
err = s.client.Do(req, response) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to get device state: %w", err) | ||
} | ||
|
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.
We generally follow the slightly more idiomatic form (at least these days)
response := new(SupervisorV1DeviceResponse) | |
err = s.client.Do(req, response) | |
if err != nil { | |
return nil, fmt.Errorf("unable to get device state: %w", err) | |
} | |
var response SupervisorV1DeviceResponse | |
err = s.client.Do(req, &response) | |
if err != nil { | |
return nil, fmt.Errorf("unable to get device state: %w", err) | |
} | |
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 fine with that. Though in other parts of this repository, I see a construction where the response created by:
response := &SupervisorV1DeviceResponse{}
In hindsight, I probably should have used that. Do you still want me to stick to your suggestion?
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.
Yeah the library needs a little cleaning to be honest. Lets go with the more idiomatic way I suggested here for now
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.
Thanks. That will give me a guide for potential future pull requests.
3589bdb
to
df029f7
Compare
Added the following methods: - Blink: start a blink pattern on a LED for 15 s - Update: trigger a check for the target state of configurations - Device: return the current device state
df029f7
to
14563d1
Compare
Added the following methods: