many: selectively swap semantics of plugs and slots #580

Merged
merged 11 commits into from Mar 4, 2016

Conversation

Projects
None yet
3 participants
Contributor

zyga commented Mar 4, 2016

This branch swaps Plugs and Slots around. Unlike a naive approach that would do this globally, the change is applied only to specific places because, ironically, some places already had the "plug connects to slot" order without us noticing.

Most notably the snappy package now applies old-security on the plug (not on the slot). In theclientandinterfaces`` package only comments are moved around since the representation of both types was symmetrical.

The biggest change was in the snap interfaces command where the order of displaying the elements was fully swapped so that the slot side is printed in the first column and all the plugs are printed in the second column.

For reference, "old-security" interface has to be specified under plugs now.

zyga added some commits Mar 4, 2016

snappy: swap Plugs and Slots semantics
Plugs connect (plug into) slots, not the other way around, so let's make
that change now before everyone has to wonder why it's backwards.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces/builtin: swap Plug and Slot semantics
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces: swap Plug and Slot semantics
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
client: swap Plug and Slot semantics
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
cmd/snap: swap Plug and Slot semantics (in snap interfaces)
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
docs: swap Plug and Slot semantics
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
po: refresh translation template
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
- // SlotSecuritySnippet returns the configuration snippet needed by the
- // given security system to allow a snap to use a plug of this interface.
+ // PlugSecuritySnippet returns the configuration snippet needed by the
+ // given security system to allow a snap to use a slot of this interface.
//
// An empty snippet is returned when the plug doesn't require anything
// from the security system to work, in addition to the default
// configuration. ErrUnknownSecurity is returned when the plug cannot
// deal with the requested security system.
@stevenwilkin

stevenwilkin Mar 4, 2016

Member

Should these 2 references to "plug" be "slot" instead?

@zyga

zyga Mar 4, 2016

Contributor

This is confusingly correct IMHO. I re-wrote that paragraph to be much less confusing in the upcoming static security snippets branch.

Here both sides talk about a slot because you "consume a slot" or "provide a slot" and this is exactly what those bits were initially meant to do. I'd ignore it and review the wording on the static/dynamic branch

interfaces/builtin/bool_file_test.go
// Symbolic link traversal is handled correctly
builtin.MockEvalSymlinks(&s.BaseTest, func(path string) (string, error) {
return "", fmt.Errorf("broken symbolic link")
})
- snippet, err := s.iface.SlotSecuritySnippet(s.gpioPlug, s.slot, interfaces.SecurityAppArmor)
+ snippet, err := s.iface.PlugSecuritySnippet(s.gpioPlug, s.slot, interfaces.SecurityAppArmor)
c.Assert(err, ErrorMatches, "cannot compute slot security snippet: broken symbolic link")
@stevenwilkin

stevenwilkin Mar 4, 2016

Member

Slot or plug?

docs/rest.md
- "plugs": {{"snap": "canonical-pi2", "plug": "pin-13"}},
- "slots": {{"snap": "keyboard-lights", "slot": "capslock-led"}}
+ "slots": {{"snap": "canonical-pi2", "plug": "pin-13"}},
+ "plugs": {{"snap": "keyboard-lights", "slot": "capslock-led"}}
@stevenwilkin

stevenwilkin Mar 4, 2016

Member

"slots": ... "slot", "plugs": ... "plug": ?

docs: fix partial slot/plug swap
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga closed this Mar 4, 2016

Contributor

zyga commented Mar 4, 2016

Closing for now to do remaining changes

zyga added some commits Mar 4, 2016

interfaces/builtin: swap plug<->slots in bool-file
This is done in vim with:

    :%s/Plug/YAY/g|%s/Slot/Plug/g|%s/YAY/Slot/g|%s/plug/yay/g|%s/slot/plug/g|%s/yay/slot/g

With a manual pass that maintains argument order in
{Plug,Slot}SecuritySnippet()

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga reopened this Mar 4, 2016

client,interfaces: fix description of Plug
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
$ snap interfaces --i=<interface> [<snap>]
-Lists only plugs and slots of the specific interface.
+Lists only slots and plugs of the specific interface.
@niemeyer

niemeyer Mar 4, 2016

Contributor

Can you please replace this whole text by what's in the spec, just swapping plugs and slots?

It's much easier to understand than what's here.

Contributor

niemeyer commented Mar 4, 2016

LGTM, one comment. Thanks!

zyga added a commit that referenced this pull request Mar 4, 2016

Merge pull request #580 from zyga/secafretni
many: selectively swap semantics of plugs and slots

@zyga zyga merged commit 89d999c into snapcore:master Mar 4, 2016

2 of 3 checks passed

Integration tests No test results found.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.0%) to 71.073%
Details

@zyga zyga deleted the zyga:secafretni branch Mar 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment