Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces/builtin: reduce duplication and remove cruft in Sanitize{Plug,Slot} #3619
Conversation
zyga
added some commits
Jul 11, 2017
mvo5
reviewed
Jul 25, 2017
Looks good and nice to see this duplication all consolidated into single helpers! Thanks for doing this work. A small question inline, otherwise good.
| @@ -91,3 +91,39 @@ func udevUsbDeviceSnippet(subsystem string, usbVendor int64, usbProduct int64, k | ||
| func udevSnapSecurityName(snapName string, appName string) string { | ||
| return fmt.Sprintf(`snap_%s_%s`, snapName, appName) | ||
| } | ||
| + | ||
| +func ensureSlotIfaceMatch(iface interfaces.Interface, slot *interfaces.Slot) { |
zyga
Jul 25, 2017
Contributor
They are tested indirectly but I'll add a small set of tests. Thanks for spotting that.
codecov-io
commented
Jul 25, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #3619 +/- ##
==========================================
+ Coverage 75.14% 75.19% +0.04%
==========================================
Files 386 386
Lines 33693 33418 -275
==========================================
- Hits 25318 25128 -190
+ Misses 6551 6479 -72
+ Partials 1824 1811 -13
Continue to review full report at Codecov.
|
|
After discussing this with @pedronis I'm going to move the responsibility of checking interface name from |
zyga
added some commits
Jul 27, 2017
| + plug.Ref(), plug.Interface, iface.Name()) | ||
| + } | ||
| + type sanitizer interface { | ||
| + SanitizePlug(plug *Plug) error |
chipaca
Jul 28, 2017
Member
I'd make these interfaces public, to better document the thing (much as for example http.Flusher is public to document that). It adds a path to discovery of this feature.
pedronis
approved these changes
Jul 28, 2017
•
lgtm, as I discussed we probably want to say "core snap" for the time being instead of "operating system snap".
Also I agree with Chipaca's comment, though it seems for the backends we really went the route of secret interfaces which I don't fully understand from a documenting POV.
zyga commentedJul 25, 2017
This branch unifies how Sanitize{Plug,Slot} are implemented across all of the interfaces.
This removes a lot of copy-pasted code and adds some missing calls in other copy-pasted code.
Lastly, because all of the error messages are in a small set of four functions, there is much more
uniformity in how error messages look like.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com