Skip to content

Commit

Permalink
Merge pull request #4007 from stolowski/ref-helpers
Browse files Browse the repository at this point in the history
interfaces: add plugRef/slotRef helpers for PlugInfo/SlotInfo
  • Loading branch information
stolowski committed Oct 25, 2017
2 parents d979688 + 3ca4cf3 commit 9871f86
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions interfaces/core.go
Expand Up @@ -35,7 +35,11 @@ type Plug struct {

// Ref returns reference to a plug
func (plug *Plug) Ref() PlugRef {
return PlugRef{Snap: plug.Snap.Name(), Name: plug.Name}
return plugRef(plug.PlugInfo)
}

func plugRef(plugInfo *snap.PlugInfo) PlugRef {
return PlugRef{Snap: plugInfo.Snap.Name(), Name: plugInfo.Name}
}

// Sanitize plug with a given snapd interface.
Expand Down Expand Up @@ -70,7 +74,11 @@ type Slot struct {

// Ref returns reference to a slot
func (slot *Slot) Ref() SlotRef {
return SlotRef{Snap: slot.Snap.Name(), Name: slot.Name}
return slotRef(slot.SlotInfo)
}

func slotRef(slotInfo *snap.SlotInfo) SlotRef {
return SlotRef{Snap: slotInfo.Snap.Name(), Name: slotInfo.Name}
}

// Sanitize slot with a given snapd interface.
Expand Down

0 comments on commit 9871f86

Please sign in to comment.