Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

andrewphelpsj
Copy link
Collaborator

@andrewphelpsj andrewphelpsj commented Apr 1, 2024

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.

@github-actions github-actions bot added the Needs Documentation -auto- Label automatically added which indicates the change needs documentation label Apr 1, 2024
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 2 times, most recently from f9e50ab to 3c1cc60 Compare April 2, 2024 14:51
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 2 times, most recently from 92d8bc4 to db5f741 Compare April 4, 2024 16:48
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 58.60735% with 214 lines in your changes are missing coverage. Please review.

Project coverage is 78.74%. Comparing base (1bad859) to head (db5f741).
Report is 15 commits behind head on master.

Files Patch % Lines
interfaces/ifacetest/backendtest.go 0.00% 64 Missing ⚠️
overlord/ifacestate/handlers.go 48.30% 42 Missing and 19 partials ⚠️
interfaces/ifacetest/app_set.go 38.46% 30 Missing and 2 partials ⚠️
overlord/ifacestate/helpers.go 45.71% 12 Missing and 7 partials ⚠️
interfaces/repo.go 61.70% 12 Missing and 6 partials ⚠️
interfaces/connection.go 33.33% 8 Missing ⚠️
interfaces/snap_app_set.go 93.24% 4 Missing and 1 partial ⚠️
interfaces/kmod/backend.go 71.42% 0 Missing and 2 partials ⚠️
daemon/api_sideload_n_try.go 0.00% 1 Missing ⚠️
interfaces/builtin/modem_manager.go 50.00% 1 Missing ⚠️
... and 3 more

❗ 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     
Flag Coverage Δ
unittests 78.74% <58.60%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 2 times, most recently from 19d258f to 8915966 Compare April 8, 2024 17:41
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 2 times, most recently from fdf150a to 6e0146e Compare April 16, 2024 19:18
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 2 times, most recently from 4985f65 to ca4f30f Compare April 17, 2024 15:22
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 3 times, most recently from a31505b to 4a60a79 Compare May 7, 2024 14:41
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 2 times, most recently from c2179fb to 22cf201 Compare May 15, 2024 07:43
@andrewphelpsj andrewphelpsj force-pushed the app-set-in-connected branch 3 times, most recently from c94234c to 05db36c Compare May 23, 2024 16:25
Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a 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)

Copy link
Collaborator

@pedronis pedronis left a 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.
Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Collaborator

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.
Copy link
Collaborator

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() {
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments

Comment on lines +160 to +167
func appRunnable(app *snap.AppInfo) Runnable {
return Runnable{
CommandName: app.Name,
SecurityTag: app.SecurityTag(),
}
}

func hookRunnable(hook *snap.HookInfo) Runnable {
Copy link
Collaborator

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?

Comment on lines +220 to +222
names = append(names, fmt.Sprintf("+%s.hook.%s", hook.Component.Name, hook.Name))
} else {
names = append(names, fmt.Sprintf(".hook.%s", hook.Name))
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Documentation -auto- Label automatically added which indicates the change needs documentation
Projects
None yet
4 participants