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

snap: introduce timer service data types and validation #4633

Merged
merged 2 commits into from Feb 13, 2018

Conversation

bboozzoo
Copy link
Collaborator

@bboozzoo bboozzoo commented Feb 7, 2018

Introduce basic data types and validation for timer services.

Timer service is defined in snap.yaml as follows:

  ..
  apps:
    foo:
      command: bin/foo
      daemon: oneshot          # one of simple|forking|oneshot|dbus|notify
      timer: mon,10:00-12:00   # valid timer specification

@bboozzoo bboozzoo changed the title snap: introduce timer service data types and validation snap: introduce service timer data types and validation Feb 7, 2018
@bboozzoo bboozzoo changed the title snap: introduce service timer data types and validation snap: introduce timer service data types and validation Feb 7, 2018
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Introduce basic data types and validation for timer services.

Timer service is defined in snap.yaml as follows:

  ..
  apps:
    foo:
      command: bin/foo
      daemon: oneshot          # one of simple|forking|oneshot|dbus|notify
      timer: mon,10:00-12:00   # valid timer specification

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
@bboozzoo bboozzoo force-pushed the bboozzoo/service-timers-basics branch from 4ee83ab to 24a964f Compare February 7, 2018 14:55
Copy link
Collaborator

@zyga zyga left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -549,11 +558,16 @@ type HookInfo struct {
Slots map[string]*SlotInfo
}

// File returns the path to the file
// File returns the path to the *.socket file
func (socket *SocketInfo) File() string {
return filepath.Join(dirs.SnapServicesDir, socket.App.SecurityTag()+"."+socket.Name+".socket")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick for later, use fmt.Sprintf here. No need to do it now.

func (socket *SocketInfo) File() string {
return filepath.Join(dirs.SnapServicesDir, socket.App.SecurityTag()+"."+socket.Name+".socket")
}

// File returns the path to the *.timer file
func (timer *TimerInfo) File() string {
return filepath.Join(dirs.SnapServicesDir, timer.App.SecurityTag()+".timer")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

@codecov-io
Copy link

Codecov Report

Merging #4633 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #4633      +/-   ##
=========================================
+ Coverage   78.29%   78.3%   +0.01%     
=========================================
  Files         464     464              
  Lines       32939   32955      +16     
=========================================
+ Hits        25789   25807      +18     
+ Misses       5019    5018       -1     
+ Partials     2131    2130       -1
Impacted Files Coverage Δ
snap/info_snap_yaml.go 93.12% <100%> (+0.08%) ⬆️
snap/validate.go 95.72% <100%> (+0.15%) ⬆️
snap/info.go 84.38% <100%> (+0.13%) ⬆️
overlord/hookstate/hookmgr.go 73.14% <0%> (+1.14%) ⬆️

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 53e4a5a...24a964f. Read the comment docs.

Copy link
Contributor

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

Looks nice, thank you!

apps:
foo:
daemon: oneshot
timer: mon,10:00-12:00,mon2-wed3
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious what will happen with timer: is empty. I assume a parser failure?

@mvo5 mvo5 merged commit 3015530 into snapcore:master Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants