-
Notifications
You must be signed in to change notification settings - Fork 562
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
many: add a *SnapAppSet to ConnectedPlug/Slot types and use it to build label expressions in interfaces #13773
base: master
Are you sure you want to change the base?
Conversation
f9e50ab
to
3c1cc60
Compare
92d8bc4
to
db5f741
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #13773 +/- ##
==========================================
- Coverage 78.83% 78.74% -0.09%
==========================================
Files 1043 1044 +1
Lines 134470 135006 +536
==========================================
+ Hits 106012 106314 +302
- Misses 21847 22039 +192
- Partials 6611 6653 +42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
19d258f
to
8915966
Compare
fdf150a
to
6e0146e
Compare
4985f65
to
ca4f30f
Compare
a31505b
to
4a60a79
Compare
c2179fb
to
22cf201
Compare
c94234c
to
05db36c
Compare
… interfaces can build a complete label expression, including component hooks
05db36c
to
0356d2d
Compare
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.
LGTM, thanks (I looked at 0356d2d)
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.
did a pass on the last commit
staticAttrs map[string]interface{} | ||
dynamicAttrs map[string]interface{} | ||
} | ||
|
||
// Apps returns all the apps associated with this plug. |
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 doc comment doesn't quite match the name and purpose of the method
@@ -139,8 +156,8 @@ func (plug *ConnectedPlug) Snap() *snap.Info { | |||
} | |||
|
|||
// Apps returns all the apps associated with this plug. | |||
func (plug *ConnectedPlug) Apps() map[string]*snap.AppInfo { | |||
return plug.plugInfo.Apps | |||
func (plug *ConnectedPlug) AppSet() *SnapAppSet { |
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.
same
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 just noticed that this file doesn't respect go conventions, it mixes the definition of the ConnectedPlug and ConnectedSlot methods, instead of having those follow their struct introduction. Maybe we should change this in an immediate follow up
// constructed from the apps and hooks that are associated with the plug. | ||
func (a *SnapAppSet) PlugLabelExpression(plug *ConnectedPlug) string { | ||
func (a *SnapAppSet) plugLabelExpression(plug *ConnectedPlug) string { | ||
// TODO: this is a hack that will not continue to work once component hooks | ||
// are introduced. the methods on SnapAppSet should only be called on | ||
// slots/hooks that originated from the snap that the SnapAppSet was derived | ||
// from. |
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.
is the TODO still relevant?
// TODO: this is a hack that will not continue to work once component hooks | ||
// are introduced. the methods on SnapAppSet should only be called on | ||
// slots/hooks that originated from the snap that the SnapAppSet was derived | ||
// from. | ||
info := a.info | ||
if a.info.InstanceName() != plug.plugInfo.Snap.InstanceName() { |
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.
shouldn't this use plug.appSet now? and the other check go to the constructors of ConnectedPlug?
if a.info.InstanceName() != slot.slotInfo.Snap.InstanceName() { | ||
info = slot.slotInfo.Snap |
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.
same comments
func appRunnable(app *snap.AppInfo) Runnable { | ||
return Runnable{ | ||
CommandName: app.Name, | ||
SecurityTag: app.SecurityTag(), | ||
} | ||
} | ||
|
||
func hookRunnable(hook *snap.HookInfo) Runnable { |
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.
maybe Runnable and this belong in the snap package?
names = append(names, fmt.Sprintf("+%s.hook.%s", hook.Component.Name, hook.Name)) | ||
} else { | ||
names = append(names, fmt.Sprintf(".hook.%s", hook.Name)) |
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.
thought: I wonder if there's a way to rewrite this using Runnables() and some more methods on that?
Now that we have app sets in the interfaces repo, keep a pointer to them in ConnectedPlug/Slot types. Use this to build label expressions in the interfaces. Based on #13772, first relevant commit is 4985f65.