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: replace interfaces.Repository.AddSnap with AddAppSet #13772

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

Conversation

andrewphelpsj
Copy link
Collaborator

@andrewphelpsj andrewphelpsj commented Apr 1, 2024

This change will enable us to inject an app set into the interfaces.Connected(Plug|Slot) types, which will allow interfaces to correctly generate label expressions for connected plugs/slots.

@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 add-app-set branch 2 times, most recently from 7098b7c to e21b479 Compare April 2, 2024 14:51
@andrewphelpsj andrewphelpsj force-pushed the add-app-set branch 4 times, most recently from bd45c89 to 97b05af Compare April 8, 2024 17:36
@andrewphelpsj andrewphelpsj force-pushed the add-app-set branch 4 times, most recently from 8bf7bd4 to bdaf052 Compare April 17, 2024 15:22
@andrewphelpsj andrewphelpsj force-pushed the add-app-set branch 3 times, most recently from d09a914 to 7a7134d Compare May 7, 2024 14:41
@andrewphelpsj andrewphelpsj force-pushed the add-app-set branch 2 times, most recently from dfaa7b0 to f33e330 Compare May 15, 2024 07:39
@andrewphelpsj andrewphelpsj force-pushed the add-app-set branch 2 times, most recently from 4a33c39 to 47a6b55 Compare May 17, 2024 12:43

// NewComponentInfo creates a new ComponentInfo.
func NewComponentInfo(cref naming.ComponentRef, ctype ComponentType, version, summary, description string) *ComponentInfo {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any specific reason to remove this function? It is not especially useful right now, but in the past we had problems with not having this sort of function to create structs and we introduced changes like a new field whose value depended partially on other fields, etc. If the struct was created directly in many tests then the changes were very time consuming and annoying.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is used much later in “snap run” to set some environs variables

@@ -1000,10 +953,12 @@ func (r *Repository) AddSnap(snapInfo *snap.Info) error {

snapName := snapInfo.InstanceName()

if r.plugs[snapName] != nil || r.slots[snapName] != nil {
if r.appSets[snapName] != nil || r.plugs[snapName] != nil || r.slots[snapName] != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Should be enough with checking r.appSets[snapName] I guess? Unless AddAppSet is not always called for all snaps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are correct, this invariant should always hold. Would panicking be preferable in this case?

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.

Couple of comments around

snap/component.go Outdated Show resolved Hide resolved
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.

lgtm, doc comment question

@@ -973,23 +923,26 @@ func (r *Repository) SnapSpecification(securitySystem SecuritySystem, appSet *Sn
return spec, nil
}

// AddSnap adds plugs and slots declared by the given snap to the repository.
// AddAppSet adds plugs and slots declared by the given snap to the repository.
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 probably need a bit more updates, as the AppSet is not strictly just about the snap anymore

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 for the changes

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.

thank you

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
3 participants