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

cmd: support installing multiple local snaps #11201

Merged
merged 4 commits into from Jan 11, 2022

Conversation

MiguelPires
Copy link
Contributor

Adds cmd support for installing multiple local snaps.

@codecov-commenter
Copy link

Codecov Report

Merging #11201 (c8dabce) into master (63d79a4) will increase coverage by 0.00%.
The diff coverage is 80.88%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11201   +/-   ##
=======================================
  Coverage   78.36%   78.36%           
=======================================
  Files         922      922           
  Lines      105128   105167   +39     
=======================================
+ Hits        82385    82418   +33     
- Misses      17611    17615    +4     
- Partials     5132     5134    +2     
Flag Coverage Δ
unittests 78.36% <80.88%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
client/snap_op.go 73.74% <71.73%> (+0.66%) ⬆️
cmd/snap/cmd_snap_op.go 78.39% <100.00%> (+0.46%) ⬆️
overlord/hookstate/hookmgr.go 74.67% <0.00%> (-0.65%) ⬇️
daemon/api_connections.go 93.58% <0.00%> (+0.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63d79a4...c8dabce. Read the comment docs.

@@ -488,7 +488,7 @@ func (x *cmdInstall) installOne(nameOrPath, desiredName string, opts *client.Sna
var snapName string
var path string

if strings.Contains(nameOrPath, "/") || strings.HasSuffix(nameOrPath, ".snap") || strings.Contains(nameOrPath, ".snap.") {
if isLocalSnap(nameOrPath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, this is much more readable now!

}

// InstallPathMany sideloads the snaps with the given paths,
// returning the UUID of the background operation upon success.
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit weird we called it UUID (I see it's taken from the existing comment) and not just change id...

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

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

This looks good! Could you please add a simple spread test in this PR?

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

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

Thanks for adding the spread test. Looks fine, one more suggestion.

Comment on lines +83 to +86
echo "Install multiple local snaps"
expected="(basic 1.0 installed\stest-snapd-tools 1.0 installed)|(test-snapd-tools 1.0 installed\sbasic 1.0 installed)"
snap install --dangerous test-snapd-tools_1.0_all.snap basic_1.0_all.snap | MATCH -z "$expected"
snap install --devmode test-snapd-tools_1.0_all.snap basic_1.0_all.snap | MATCH -z "$expected"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this test!

client/snap_op.go Show resolved Hide resolved
client/snap_op.go Show resolved Hide resolved
for _, openFile := range files {
openFile.Close()
}
return "", fmt.Errorf("cannot open: %q", path)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

Suggested change
return "", fmt.Errorf("cannot open: %q", path)
return "", fmt.Errorf("cannot open %q: %v", path, err)

(then the old code for installing single file could be updated too).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks good, I'll change both. We can also just print the err itself since os.PathError's message includes the path that the op failed on

Copy link
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

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

Looks good, +1

Copy link
Collaborator

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

LGTM

@mvo5 mvo5 merged commit e5fa7de into snapcore:master Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants