-
Notifications
You must be signed in to change notification settings - Fork 0
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
allows to use multiple ownership transfer methods for own op #279
Conversation
c40cc02
to
b64c1bc
Compare
Codecov Report
@@ Coverage Diff @@
## main #279 +/- ##
==========================================
+ Coverage 60.23% 60.56% +0.32%
==========================================
Files 64 64
Lines 4059 4067 +8
==========================================
+ Hits 2445 2463 +18
+ Misses 1266 1255 -11
- Partials 348 349 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
b64c1bc
to
7aaf3e0
Compare
7aaf3e0
to
e9c10b5
Compare
e9c10b5
to
ab0226f
Compare
} | ||
if !supportOtm { | ||
return MakeUnavailable(fmt.Errorf("ownership transfer method '%v' is unsupported, supported are: %v", otmClient.Type(), ownership.SupportedOwnerTransferMethods)) | ||
otmClient := findOTMClient(otmClients, ownership.SupportedOwnerTransferMethods) |
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.
This gives you the first matching client, but you can have multiple matches. Is taking the first match always correct?
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.
This is fine. It is not expected that clients add there multiple otm with the same type.
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.
Both otmClients
and deviceSupportedOwnerTransferMethods
are arrays though, so even if you don't have multiple clients of the same type you can have multiple matches.
Lets say that:
otmClients = []{client for ManufacturerCertificate, client for Self}
deviceSupportedOwnerTransferMethods = []{ManufacturerCertificate, Self}
findOTMClient
will always return the first match (client for ManufacturerCertificate
in this case). I don't know what's the expected behavior of the Own
function, so this might or might not be a problem. But the function is dependent on the order of the values in the otmClients
slice, which I think we should at least document.
Also isn't possible that in this example that owning with ManufacturerCertificate
client fails, but owning with Self
would succeed? However, the Self
client won't be tried and the user of the function doesn't know which client was used and failed. I guess a custom Error
type which would have a type of the client used would be best here, so the caller could remove it from the otmClients
slice and retry.
No description provided.