Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
many: refactor in preparation for 'snap start' #3342
Conversation
zyga
changed the title from
this is a refactor branch, in preparation for 'snap start' etc
to
many: refactor in preparation for 'snap start'
May 17, 2017
codecov-io
commented
May 18, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #3342 +/- ##
==========================================
+ Coverage 77.53% 77.65% +0.11%
==========================================
Files 367 367
Lines 25156 25170 +14
==========================================
+ Hits 19504 19545 +41
+ Misses 3904 3880 -24
+ Partials 1748 1745 -3
Continue to review full report at Codecov.
|
| f.ops = append(f.ops, fakeOp{ | ||
| - op: "start-snap-services", | ||
| - name: info.MountDir(), | ||
| + op: "start-snap-services", |
pedronis
May 18, 2017
Contributor
this is a bit "cheating", if one now replaces all the .Services() with nil tests would still pass. We probably want a couple of tests with services in snapstate now and then you can have the ifs, notice that the way to achieve that is to have a name like service-snap handled in backend_test.go in fake ReadInfo
pedronis
May 22, 2017
Contributor
now you can keep name: or something like that, svcs[0].Snap.MountDir()
| @@ -690,10 +690,15 @@ func (m *SnapManager) startSnapServices(t *state.Task, _ *tomb.Tomb) error { | ||
| if err != nil { | ||
| return err | ||
| } | ||
| + svcs := currentInfo.Services() | ||
| + // TODO: |
pedronis
May 18, 2017
Contributor
I fear is better to bite the bullet here given that you need to touch all the tests anyway.
| @@ -280,6 +280,19 @@ func (s *Info) NeedsClassic() bool { | ||
| return s.Confinement == ClassicConfinement | ||
| } | ||
| +// Services returns a list of the apps that have "daemon" set. | ||
| +func (s *Info) Services() []*AppInfo { |
| @@ -482,6 +495,11 @@ func (app *AppInfo) Env() []string { | ||
| return env | ||
| } | ||
| +// IsService returns whether app represents a daemon/service. | ||
| +func (app *AppInfo) IsService() bool { |
chipaca
added some commits
May 17, 2017
| @@ -214,7 +213,7 @@ func refreshAliases(st *state.State, info *snap.Info, curAliases map[string]*Ali | ||
| newAliases = make(map[string]*AliasTarget, len(autoAliases)) | ||
| // apply the current auto-aliases | ||
| for alias, target := range autoAliases { | ||
| - if app := info.Apps[target]; app == nil || wrappers.IsService(app) { | ||
| + if app := info.Apps[target]; app == nil || app.IsService() { |
| - StartSnapServices(info *snap.Info, meter progress.Meter) error | ||
| - StopSnapServices(info *snap.Info, meter progress.Meter) error | ||
| + StartServices(svcs []*snap.AppInfo, meter progress.Meter) error | ||
| + StopServices(svcs []*snap.AppInfo, meter progress.Meter) error |
chipaca commentedMay 17, 2017
wrappers: move {Start,Stop}SnapServices(*snap.Info) to {Start,Stop}Services([]*snap.AppInfo)
snap/info: gave *snap.Info a Services() method which returns a []*snap.AppInfo of services
overlord/snapstate: propagate the refactor up to (but not including) the task level